[clang] [compiler-rt] [libcxx] [cmake] Add hexagon-linux cmake cache files (PR #98712)

Brian Cain via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 15 21:07:35 PDT 2024


================
@@ -0,0 +1,25 @@
+
+set(CMAKE_EXE_LINKER_FLAGS "-lclang_rt.builtins-hexagon -nostdlib" CACHE STRING "")
+set(CMAKE_SHARED_LINKER_FLAGS "-lclang_rt.builtins-hexagon -nostdlib" CACHE STRING "")
----------------
androm3da wrote:

The first failure encountered when I remove these is related to `C_SUPPORTS_NODEFAULTLIBS_FLAG`.

And I think it's `llvm_check_compiler_linker_flag(C "-nodefaultlibs" C_SUPPORTS_NODEFAULTLIBS_FLAG)` from `llvm-project/libunwind/cmake/config-ix.cmake` failing.

Sorry if I'm being dense here but if the compiler feature test tries to build an executable using `-nodefaultlibs` but without providing the necessary libraries to satisfy a trivial C executable, wouldn't we expect it to fail?  I mean, I guess other compilers must be succeeding here, so I'll have to try and understand how.  Or maybe it could be that `-nodefaultlibs` is mishandled by the hexagon driver?  I guess I'd figure it would remove at least `-lc` though, which seems like it should fail something like this.

```
Change Dir: /local/mnt/workspace/upstream/toolchain_for_hexagon/obj_libs/CMakeFiles/CMakeScratch/TryCompile-z4nhCq

Run Build Command(s):/pkg/qct/software/ninja/1.8.2/ninja cmTC_11433 && [1/2] Building C object CMakeFiles/cmTC_11433.dir/src.c.o
[2/2] Linking C executable cmTC_11433
FAILED: cmTC_11433 
: && /local/mnt/workspace/upstream/toolchain_for_hexagon/clang+llvm-19.0.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/bin/hexagon-unknown-linux-musl-clang --target=hexagon-unknown-linux-musl -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections  --start-no-unused-arguments --unwindlib=none --end-no-unused-arguments -nodefaultlibs  CMakeFiles/cmTC_11433.dir/src.c.o -o cmTC_11433   && :
ld.lld: error: undefined symbol: __libc_start_main
>>> referenced by crt1.c
>>>               /local/mnt/workspace/upstream/toolchain_for_hexagon/clang+llvm-19.0.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/bin/../target/hexagon-unknown-linux-musl//usr/lib/crt1.o:(_start_c)
>>> referenced by crt1.c
>>>               /local/mnt/workspace/upstream/toolchain_for_hexagon/clang+llvm-19.0.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/bin/../target/hexagon-unknown-linux-musl//usr/lib/crt1.o:(_start_c)
hexagon-unknown-linux-musl-clang: error: hexagon-ld command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.


Source file was:
int main(void) { return 0; }

```

https://github.com/llvm/llvm-project/pull/98712


More information about the cfe-commits mailing list