[PATCH] D112112: [libunwind] Link with -unwindlib=none

Harald van Dijk via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 20 12:09:56 PDT 2021


hvdijk added a comment.

In D112112#3075970 <https://reviews.llvm.org/D112112#3075970>, @mstorsjo wrote:

> If you try my version of the patch, does it work if you omit setting `-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY`? It does for me.

It does not, it fails as it does unpatched, as it does on earlier versions as well:

  -- The C compiler identification is Clang 13.0.0
  -- The CXX compiler identification is Clang 13.0.0
  -- The ASM compiler identification is Clang
  -- Found assembler: /usr/bin/clang
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - failed
  -- Check for working C compiler: /usr/bin/clang
  -- Check for working C compiler: /usr/bin/clang - broken
  CMake Error at /usr/share/cmake-3.21/Modules/CMakeTestCCompiler.cmake:69 (message):
    The C compiler
  
      "/usr/bin/clang"
  
    is not able to compile a simple test program.
  
    It fails with the following output:
  
      Change Dir: /h/libunwind-13.0.0-build-x64/CMakeFiles/CMakeTmp
  
      Run Build Command(s):/usr/bin/make -f Makefile cmTC_591df/fast && /usr/bin/make  -f CMakeFiles/cmTC_591df.dir/build.make CMakeFiles/cmTC_591df.dir/build
      make[1]: Entering directory '/h/libunwind-13.0.0-build-x64/CMakeFiles/CMakeTmp'
      Building C object CMakeFiles/cmTC_591df.dir/testCCompiler.c.o
      /usr/bin/clang  -m64   -O2  -MD -MT CMakeFiles/cmTC_591df.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_591df.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_591df.dir/testCCompiler.c.o -c /h/libunwind-13.0.0-build-x64/CMakeFiles/CMakeTmp/testCCompiler.c
      Linking C executable cmTC_591df
      /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_591df.dir/link.txt --verbose=1
      /usr/bin/clang  -m64 -O2  -Wl,-O1 -Wl,--as-needed -s  CMakeFiles/cmTC_591df.dir/testCCompiler.c.o -o cmTC_591df
      ld.lld: error: unable to find library -l:libunwind.so
      ld.lld: error: unable to find library -l:libunwind.so
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      make[1]: *** [CMakeFiles/cmTC_591df.dir/build.make:100: cmTC_591df] Error 1
      make[1]: Leaving directory '/h/libunwind-13.0.0-build-x64/CMakeFiles/CMakeTmp'
      make: *** [Makefile:127: cmTC_591df/fast] Error 2
  
  
  
  
  
    CMake will not be able to correctly generate this project.
  Call Stack (most recent call first):
    CMakeLists.txt:24 (project)
  
  
  -- Configuring incomplete, errors occurred!
  See also "/h/libunwind-13.0.0-build-x64/CMakeFiles/CMakeOutput.log".
  See also "/h/libunwind-13.0.0-build-x64/CMakeFiles/CMakeError.log".



> I’ve experimented with setting `-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY` when building some of the runtimes, but in my experience, it broke other things (making tests falsely succeed as it doesn’t test linking, enabling things that won’t work in the end).

It's a special option needed in special circumstances, to be handled with care. The situation here is that clang was installed from the split tarball, configured to use compiler-rt and libunwind rather than libgcc and libgcc_s, and that clang is then used to install compiler-rt and libunwind. That means that while configuring compiler-rt and libunwind, the compiler is broken for most link steps by design, but it is good enough to build and install the core compiler-rt bits (`libclang_rt.builtins`, `clang_rt.crtbegin`, `clang_rt.crtend`) and libunwind. Once they are installed, everything else, including the rest of cmopiler-rt, should then be configued without `-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112112/new/

https://reviews.llvm.org/D112112



More information about the llvm-commits mailing list