[libcxx-commits] [PATCH] D112126: [libunwind] Try to add -unwindlib=none while configuring and building libunwind

Petr Hosek via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 25 11:22:13 PDT 2021


phosek added a comment.

In D112126#3084664 <https://reviews.llvm.org/D112126#3084664>, @mstorsjo wrote:

> In D112126#3084606 <https://reviews.llvm.org/D112126#3084606>, @ldionne wrote:
>
>> Also TBH the more I look at it, the more I think that `check_c_compiler_flag` and the similar utilities provided by CMake out of the box don't work that well for our use case, since we run without a toolchain. Maybe we should consider moving away from those in the runtimes.
>
> That's indeed possible - here we could wrap e.g. this
>
>   set(CMAKE_REQUIRED_FLAGS_ORIG "${CMAKE_REQUIRED_FLAGS}")
>   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none")
>   check_c_compiler_flag("" LIBUNWIND_SUPPORTS_UNWINDLIB_NONE_FLAG)
>   if (NOT LIBUNWIND_SUPPORTS_UNWINDLIB_NONE_FLAG)
>     set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_ORIG}")
>   endif()
>
> into a macro - which might be beneficial for some of the other checks (`-nostdlib++` and `-nodefaultlibs` too) in some scenarios.

That's the strategy I've been considering as well.



================
Comment at: libunwind/cmake/config-ix.cmake:20-25
+set(CMAKE_REQUIRED_FLAGS_ORIG "${CMAKE_REQUIRED_FLAGS}")
+set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none")
+check_c_compiler_flag("" LIBUNWIND_SUPPORTS_UNWINDLIB_NONE_FLAG)
+if (NOT LIBUNWIND_SUPPORTS_UNWINDLIB_NONE_FLAG)
+  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_ORIG}")
+endif()
----------------
You could also use `cmake_push_check_state` and `cmake_pop_check_state` to save and restore the state instead of separate variable, but either way is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112126



More information about the libcxx-commits mailing list