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

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 25 08:37:51 PDT 2021


mstorsjo added a comment.

In D112126#3084606 <https://reviews.llvm.org/D112126#3084606>, @ldionne wrote:

> Honestly, this feels a bit messy to me.

I don't deny that, but it's also not entirely possible to make it very simple (given the tools available in cmake) for the bare-bootstrap case when nothing is present to begin with.

> At some point I had a patch to set `CMAKE_TRY_COMPILE_TARGET_TYPE` to `STATIC` for all runtimes, unconditionally. We ended up not doing it over some concerns about the correctness of the change, however perhaps we should re-consider that?

That's not possible, unfortunately. We have checks like `check_library_exists(c fopen "" LIBUNWIND_HAS_C_LIB)` - if you set `CMAKE_TRY_COMPILE_TARGET_TYPE` to `STATIC`, then this becomes a false positive, succeeding on every platform, everywhere. So because we _do_ want to do linker checks, but in a controlled manner, I'm afraid we do need to do things in a "messy" to detect things in the right order.

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


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