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

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 20 12:56:26 PDT 2021


mstorsjo added a comment.

In D112112#3076064 <https://reviews.llvm.org/D112112#3076064>, @hvdijk wrote:

> 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:
>
>   -- 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.

Ah, I see. Can you try by adding `-DCMAKE_C_COMPILER_WORKS=TRUE -DCMAKE_CXX_COMPILER_WORKS=TRUE`? That waives this particular failure.

> 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.

Yes, this is pretty much exactly my setup too (but targeting mingw).

> Once they are installed, everything else, including the rest of compiler-rt, should then be configued without `-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY`.

`-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY` is too blunt an instrument for this, for my configurations (targeting mingw). If I build libunwind with that set, linking the shared libunwind fails with these errors:

  lld: error: unable to find library -lc
  lld: error: unable to find library -ldl
  lld: error: unable to find library -ldl

Because libunwind does have checks for whether e.g. `-lc` and `-ldl` work, and these give false positives with that setting. So if one were to use `CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY`, it would have to be turned on and off over specific sections in the cmakefiles. But with D112126 <https://reviews.llvm.org/D112126> and `-DCMAKE_C_COMPILER_WORKS=TRUE -DCMAKE_CXX_COMPILER_WORKS=TRUE`, without touching `CMAKE_TRY_COMPILE_TARGET_TYPE`, it does work for me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112112



More information about the libcxx-commits mailing list