[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 03:52:00 PDT 2021


mstorsjo added a comment.

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

> If inspecting `CMakeFiles/CMakeError.log` to see what happened when testing the `-unwindlib=none` flag, I find this:
>
>   Performing C SOURCE FILE Test LIBUNWIND_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG failed with the following output:
>   Change Dir: /build/llvm-project/libunwind/build-i686-shared/CMakeFiles/CMakeTmp
>   
>   Run Build Command(s):/usr/bin/ninja cmTC_94016 && [1/2] Building C object CMakeFiles/cmTC_94016.dir/src.c.obj
>   [2/2] Linking C executable cmTC_94016.exe
>   FAILED: cmTC_94016.exe
>   : && /opt/llvm-mingw/bin/i686-w64-mingw32-clang   CMakeFiles/cmTC_94016.dir/src.c.obj -o cmTC_94016.exe -Wl,--out-implib,libcmTC_94016.dll.a -Wl,--major-image-version,0,--minor-image-version,0  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && :
>   lld: error: unable to find library -lunwind
>   lld: error: unable to find library -lunwind
>   clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
>   ninja: build stopped: subcommand failed.
>
> During this particular test, CMake does apply the tested flag, `-unwindlib=none`, when compiling the test object (`CMakeFiles/cmTC_94016.dir/src.c.obj`) although that's not visible in the log. But it's not applying that flag when it does linking of the test executable. See e.g. https://gitlab.kitware.com/cmake/cmake/-/issues/15934 for discussion on that issue.
>
> I'm curious to know how it succeeds in your case, if it's linking in `-lunwind` explicitly when linking the final libunwind library, but not while trying the `check_c_compiler_flag()`. Is it a case where `-lunwind` is added implicitly only when linking as C++ but not C? (As far as I've read the clang driver, if it adds it implicitly for either of them, it should add it for both.)

FWIW, it seems like there's more useful info in `CMakeFiles/CMakeError.log` about what compile command it did use, when testing `check_c_compiler_flag(-unwindlib=none)`, if using the makefile generator instead of the ninja one - as ninja hides the commands that are run except for the commands that actually resulted in an error.


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