Skip to content

[runtimes] remove workaround for old CMake when setting --unwindlib=none #93429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

h-vetinari
Copy link
Contributor

Noticed a left-over for old CMake, irrelevant now that the baseline version moved to 3.20.

@h-vetinari h-vetinari requested a review from a team as a code owner May 26, 2024 22:43
@llvmbot llvmbot added the cmake Build system in general and CMake in particular label May 26, 2024
@h-vetinari
Copy link
Contributor Author

h-vetinari commented May 26, 2024

Hm, this seems to affect some feature detection (and constraints) later on, though I don't see why/how removing the specification of --unwindlib=none to the driver (leaving it only to the linker) would cause that:

if (LIBUNWIND_ENABLE_SHARED AND
NOT (CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG AND
CXX_SUPPORTS_FUNWIND_TABLES_FLAG))
message(FATAL_ERROR
"Compiler doesn't support generation of unwind tables if exception "
"support is disabled. Building libunwind DSO with runtime dependency "
"on C++ ABI library is not supported.")
endif()

@ldionne
Copy link
Member

ldionne commented Jun 11, 2024

I think something else is going on. The CMake configuration as a whole is failing, the logs show:

-- Performing Test CXX_SUPPORTS_NOSTDLIBXX_FLAG - Failed
-- Performing Test CXX_SUPPORTS_NOSTDINCXX_FLAG
-- Performing Test CXX_SUPPORTS_NOSTDINCXX_FLAG - Failed

This shouldn't be affected by this patch, but somehow it is.

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW this LGTM if we can make it work -- this is a great cleanup, thanks for noticing.

@h-vetinari
Copy link
Contributor Author

The CMake configuration as a whole is failing, the logs show:

The interesting thing is that everything past that check is failing, which somehow looks like it's corrupting some (CMake's?) state somehow:

-- Performing Test CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG
-- Performing Test CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG - Success
-- Performing Test CXX_SUPPORTS_NOSTDLIBXX_FLAG
-- Performing Test CXX_SUPPORTS_NOSTDLIBXX_FLAG - Failed
-- Performing Test CXX_SUPPORTS_NOSTDINCXX_FLAG
-- Performing Test CXX_SUPPORTS_NOSTDINCXX_FLAG - Failed
-- [everything after that fails]

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jun 20, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 20, 2024

@llvm/pr-subscribers-libunwind
@llvm/pr-subscribers-offload
@llvm/pr-subscribers-libcxx

@llvm/pr-subscribers-clang

Author: None (h-vetinari)

Changes

Noticed a left-over for old CMake, irrelevant now that the baseline version moved to 3.20.


Full diff: https://github.com/llvm/llvm-project/pull/93429.diff

6 Files Affected:

  • (modified) clang/tools/driver/CMakeLists.txt (+2-2)
  • (modified) llvm/cmake/modules/AddLLVM.cmake (+2-2)
  • (modified) llvm/cmake/modules/HandleLLVMOptions.cmake (+3-3)
  • (modified) llvm/cmake/modules/HandleLLVMStdlib.cmake (+3-3)
  • (removed) llvm/cmake/modules/LLVMCheckLinkerFlag.cmake (-28)
  • (modified) runtimes/CMakeLists.txt (+1-21)
diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt
index 290bf2a42536d..018605c2fd4f2 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -107,7 +107,7 @@ endif()
 
 if(CLANG_ORDER_FILE AND
     (LLVM_LINKER_IS_APPLE OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
-  include(LLVMCheckLinkerFlag)
+  include(CheckLinkerFlag)
 
   if (LLVM_LINKER_IS_APPLE OR (LLVM_LINKER_IS_LLD AND APPLE))
     set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
@@ -118,7 +118,7 @@ if(CLANG_ORDER_FILE AND
   endif()
 
   # This is a test to ensure the actual order file works with the linker.
-  llvm_check_linker_flag(CXX ${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS)
+  check_linker_flag(CXX ${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS)
 
   # Passing an empty order file disables some linker layout optimizations.
   # To work around this and enable workflows for re-linking when the order file
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 03f4e1f190fd9..cac5470435d91 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -327,8 +327,8 @@ function(add_link_opts target_name)
       elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND LLVM_LINKER_IS_SOLARISLD)
         # Support for ld -z discard-unused=sections was only added in
         # Solaris 11.4.  GNU ld ignores it, but warns every time.
-        include(LLVMCheckLinkerFlag)
-        llvm_check_linker_flag(CXX "-Wl,-z,discard-unused=sections" LINKER_SUPPORTS_Z_DISCARD_UNUSED)
+        include(CheckLinkerFlag)
+        check_linker_flag(CXX "-Wl,-z,discard-unused=sections" LINKER_SUPPORTS_Z_DISCARD_UNUSED)
         if (LINKER_SUPPORTS_Z_DISCARD_UNUSED)
           set_property(TARGET ${target_name} APPEND_STRING PROPERTY
                        LINK_FLAGS " -Wl,-z,discard-unused=sections")
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 99d848ba3d853..4ec9dc3a3b571 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1061,8 +1061,8 @@ if (LLVM_USE_SPLIT_DWARF AND
   if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
       CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
     add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-gsplit-dwarf>)
-    include(LLVMCheckLinkerFlag)
-    llvm_check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX)
+    include(CheckLinkerFlag)
+    check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX)
     append_if(LINKER_SUPPORTS_GDB_INDEX "-Wl,--gdb-index"
       CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
   endif()
@@ -1084,7 +1084,7 @@ endif()
 # lld doesn't print colored diagnostics when invoked from Ninja
 if (UNIX AND CMAKE_GENERATOR MATCHES "Ninja")
   include(LLVMCheckLinkerFlag)
-  llvm_check_linker_flag(CXX "-Wl,--color-diagnostics" LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
+  check_linker_flag(CXX "-Wl,--color-diagnostics" LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
   append_if(LINKER_SUPPORTS_COLOR_DIAGNOSTICS "-Wl,--color-diagnostics"
     CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
 endif()
diff --git a/llvm/cmake/modules/HandleLLVMStdlib.cmake b/llvm/cmake/modules/HandleLLVMStdlib.cmake
index 7afc10cff74ff..a7e138aa0789b 100644
--- a/llvm/cmake/modules/HandleLLVMStdlib.cmake
+++ b/llvm/cmake/modules/HandleLLVMStdlib.cmake
@@ -13,12 +13,12 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED)
   endfunction()
 
   include(CheckCXXCompilerFlag)
-  include(LLVMCheckLinkerFlag)
+  include(CheckLinkerFlag)
   set(LLVM_LIBCXX_USED 0)
   if(LLVM_ENABLE_LIBCXX)
     if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
       check_cxx_compiler_flag("-stdlib=libc++" CXX_COMPILER_SUPPORTS_STDLIB)
-      llvm_check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
+      check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
       if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB)
         append("-stdlib=libc++"
           CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
@@ -36,7 +36,7 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED)
     if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
       check_cxx_compiler_flag("-static-libstdc++"
                               CXX_COMPILER_SUPPORTS_STATIC_STDLIB)
-      llvm_check_linker_flag(CXX "-static-libstdc++" CXX_LINKER_SUPPORTS_STATIC_STDLIB)
+      check_linker_flag(CXX "-static-libstdc++" CXX_LINKER_SUPPORTS_STATIC_STDLIB)
       if(CXX_COMPILER_SUPPORTS_STATIC_STDLIB AND
         CXX_LINKER_SUPPORTS_STATIC_STDLIB)
         append("-static-libstdc++"
diff --git a/llvm/cmake/modules/LLVMCheckLinkerFlag.cmake b/llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
deleted file mode 100644
index e09bbc66f2d26..0000000000000
--- a/llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-include(CheckLinkerFlag OPTIONAL)
-
-if (COMMAND check_linker_flag)
-  macro(llvm_check_linker_flag)
-    check_linker_flag(${ARGN})
-  endmacro()
-else()
-  # Until the minimum CMAKE version is 3.18
-
-  include(CheckCXXCompilerFlag)
-
-  # cmake builtin compatible, except we assume lang is C or CXX
-  function(llvm_check_linker_flag lang flag out_var)
-    cmake_policy(PUSH)
-    cmake_policy(SET CMP0056 NEW)
-    set(_CMAKE_EXE_LINKER_FLAGS_SAVE ${CMAKE_EXE_LINKER_FLAGS})
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}")
-    if("${lang}" STREQUAL "C")
-      check_c_compiler_flag("" ${out_var})
-    elseif("${lang}" STREQUAL "CXX")
-      check_cxx_compiler_flag("" ${out_var})
-    else()
-      message(FATAL_ERROR "\"${lang}\" is not C or CXX")
-    endif()
-    set(CMAKE_EXE_LINKER_FLAGS ${_CMAKE_EXE_LINKER_FLAGS_SAVE})
-    cmake_policy(POP)
-  endfunction()
-endif()
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index 24f4851169591..15f9334776e05 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -116,27 +116,7 @@ filter_prefixed("${CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} C
 # brittle. We should ideally move this to runtimes/CMakeLists.txt.
 llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
 if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
-  set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
-  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none")
-  # TODO: When we can require CMake 3.14, we should use
-  # CMAKE_REQUIRED_LINK_OPTIONS here. Until then, we need a workaround:
-  # When using CMAKE_REQUIRED_FLAGS, this option gets added both to
-  # compilation and linking commands. That causes warnings in the
-  # compilation commands during cmake tests. This is normally benign, but
-  # when testing whether -Werror works, that test fails (due to the
-  # preexisting warning).
-  #
-  # Therefore, before we can use CMAKE_REQUIRED_LINK_OPTIONS, check if we
-  # can use --start-no-unused-arguments to silence the warnings about
-  # --unwindlib=none during compilation.
-  #
-  # We must first add --unwindlib=none to CMAKE_REQUIRED_FLAGS above, to
-  # allow this subsequent test to succeed, then rewrite CMAKE_REQUIRED_FLAGS
-  # below.
-  check_c_compiler_flag("--start-no-unused-arguments" C_SUPPORTS_START_NO_UNUSED_ARGUMENTS)
-  if (C_SUPPORTS_START_NO_UNUSED_ARGUMENTS)
-    set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS} --start-no-unused-arguments --unwindlib=none --end-no-unused-arguments")
-  endif()
+  set(CMAKE_REQUIRED_LINK_OPTIONS "${CMAKE_REQUIRED_LINK_OPTIONS} --unwindlib=none")
 endif()
 
 # Disable use of the installed C++ standard library when building runtimes.

@h-vetinari h-vetinari requested a review from a team as a code owner June 20, 2024 11:00
@llvmbot llvmbot added compiler-rt libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. libunwind openmp:libomp OpenMP host runtime offload labels Jun 20, 2024
@h-vetinari
Copy link
Contributor Author

Found some more CMake cruft... Unfortunately, it doesn't improve the situation with libunwind, but at least that means I should be able to break this out into a separate PR.

@h-vetinari
Copy link
Contributor Author

I think the riddle may be explained by @mstorsjo's excellent commit message from 4169b52 (which I just found):

If the CMake requirement is bumped to 3.14, we could use
CMAKE_REQUIRED_LINK_OPTIONS instead, removing the need for the
--{start,end}-no-unused-arguments options. (However, do note that
CMAKE_REQUIRED_LINK_OPTIONS is problematic in combination with
CMAKE_TRY_COMPILE_TARGET_TYPE set to STATIC_LIBRARY; see
https://gitlab.kitware.com/cmake/cmake/-/issues/23454.)

... which is indeed what libunwind specifies:

set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

@mstorsjo
Copy link
Member

Hm, this seems to affect some feature detection (and constraints) later on, though I don't see why/how removing the specification of --unwindlib=none to the driver (leaving it only to the linker) would cause that:

if (LIBUNWIND_ENABLE_SHARED AND
NOT (CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG AND
CXX_SUPPORTS_FUNWIND_TABLES_FLAG))
message(FATAL_ERROR
"Compiler doesn't support generation of unwind tables if exception "
"support is disabled. Building libunwind DSO with runtime dependency "
"on C++ ABI library is not supported.")
endif()

I actually tested doing this cleanup back around when I wrote this - sorry I never got around to amending the comment here explaining what has to be done. The case with libunwind is a bit non-obvious.

I rebased my test change from 2022, see mstorsjo@runtimes-link-options-unwindlib-none. Can you try this out and see if it fixes the issue you're seeing?

…ng of the --unwindlib=none option

This avoids passing the option unnecessarily to compilation commands
(where it causes warnings).

This fails in practice with libunwind, where setting
CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY breaks it, as
the option from CMAKE_REQUIRED_LINK_OPTIONS ends up passed to the "ar"
tool too.
@h-vetinari
Copy link
Contributor Author

Haha, just when I realized the key to the whole thing - luckily my comment won the race condition at least. ;-)

Thanks a lot for the fix, I've pulled it into the PR (also rebased on main while I'm at it) - and CI didn't fail as previously, so this looks great! Thank you!

@mstorsjo
Copy link
Member

Thanks a lot for the fix, I've pulled it into the PR (also rebased on main while I'm at it) - and CI didn't fail as previously, so this looks great! Thank you!

Ok, good! Btw, it might be good to add a reference to https://gitlab.kitware.com/cmake/cmake/-/issues/23454 in the new commit message too (or perhaps even in a comment in libunwind/CMakeLists.txt?), to clarify that this is indeed not a bug but expected behaviour.

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The CI failures are flakes.

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think some of the libunwind failures on BuildKite are legitimate. See https://buildkite.com/llvm-project/libcxx-ci/builds/35920.

@h-vetinari
Copy link
Contributor Author

Actually, I think some of the libunwind failures on BuildKite are legitimate. See https://buildkite.com/llvm-project/libcxx-ci/builds/35920.

Yeah, it looks like the picolib-noexceptions build is still trying to actually build the exceptions, and then fails to find the symbols when linking. I've tried looking for anything that would switch arm/pico or the "-mthumb" that's in Armv7Thumb-no-exceptions.cmake which sets the baseline config for that job.

I do not think I'll be able to fix this without some help, or at least pointers.

@ldionne
Copy link
Member

ldionne commented Jun 21, 2024

I looked into it and I don't quite understand. We should definitely be building with -fno-exceptions in that configuration (and I can see that in the logs), so I don't understand why we have things like:

| ld.lld: error: undefined symbol: __cxa_begin_catch
| >>> referenced by cxa_handlers.cpp:63 (/home/tcwg-buildbot/worker/linaro-aarch64-libcxx-02/llvm-project/libcxx-ci/build/armv7m-picolibc-no-exceptions/../../libcxxabi/src/cxa_handlers.cpp:63)
| >>>               cxa_handlers.cpp.obj:(std::__terminate(void (*)())) in archive /home/tcwg-buildbot/worker/linaro-aarch64-libcxx-02/llvm-project/libcxx-ci/build/armv7m-picolibc-no-exceptions/lib/libc++abi.a

There should not be references to these functions since we're building without exceptions.

Pinging the bot owner @mplatings

@DavidSpickett
Copy link
Collaborator

Linaro will look into this.

Reproducing the build is quite easy if you do want to look yourselves in the meantime:

<llvm project root>$ ./libcxx/utils/ci/run-buildbot armv7m-picolibc-no-exceptions

You'll need a recent qemu-system-arm installed to run the tests, I have 8.1.3 locally. Picolib is downloaded and built for you by the script.

@antmox
Copy link
Contributor

antmox commented Jun 24, 2024

I may be missing something, but it looks like the armv7m-picolibc-no-exceptions issue is still related to https://gitlab.kitware.com/cmake/cmake/-/issues/23454

I notice that once the --unwindlib=none flag is added to CMAKE_REQUIRED_LINK_OPTIONS, it is also added to ar commands during the next cmake tests (starting with CXX_SUPPORTS_NOSTDLIBXX_FLAG).
Failing these tests will result in fno-exceptions not being used later

This is probably due to the fact that for Armv7M-picolibc, CMAKE_TRY_COMPILE_TARGET_TYPE is set to STATIC_LIBRARY here: https://github.com/llvm/llvm-project/blob/main/libcxx/cmake/caches/Armv7M-picolibc.cmake#L7C35-L7C49

w.r.t. interference between CMAKE_REQUIRED_LINK_OPTIONS and static libraries
@h-vetinari h-vetinari requested a review from a team as a code owner June 27, 2024 07:32
@h-vetinari
Copy link
Contributor Author

So I've been trying to follow down the rabbit hole of the failing flag checks, and it seems the combination of CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG plus https://gitlab.kitware.com/cmake/cmake/-/issues/23454 has a wider blast radius than anticipated.

I'm not claiming that adding the _previous_CMAKE_{REQUIRED_LINK_OPTIONS,TRY_COMPILE_TARGET_TYPE} dance everywhere is the right approach here, but it was - so far - the obvious path to just try to get things green again. It's conceivable though that it would be easier to simply shift the detection of CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG until after the other flag checks have been performed? 🤔

@mstorsjo
Copy link
Member

So I've been trying to follow down the rabbit hole of the failing flag checks, and it seems the combination of CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG plus https://gitlab.kitware.com/cmake/cmake/-/issues/23454 has a wider blast radius than anticipated.

I'm not claiming that adding the _previous_CMAKE_{REQUIRED_LINK_OPTIONS,TRY_COMPILE_TARGET_TYPE} dance everywhere is the right approach here, but it was - so far - the obvious path to just try to get things green again. It's conceivable though that it would be easier to simply shift the detection of CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG until after the other flag checks have been performed? 🤔

That's probably not possible...

The point is that when bootstrapping a new sysroot from scratch (i.e. building the initial libunwind etc), in a configuration where libunwind is linked in automatically, every test that tries to do linking will fail (as it implicitly tries to link in libunwind, which does not exist yet). Therefore, we need to add --unwindlib=none as an additional linker flag, as soon as possible, so that all following cmake checks will get the right result.

Also, in general, setting CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY in too wide a context will also give false positive checks, for cases where we intentionally want to check whether linking some library works and is found. But perhaps the way you do it here, adding it in a narrow context only when doing specific checks, is the right way? I'm not sure...

So that cmake issue seems to be really, really unfortunate here. :-( I wonder if the cure is worse than the disease here - and if it would be better to just keep what we have now - and simplify it only if cmake adds something like CMAKE_REQUIRED_DYNAMIC_LINK_OPTIONS or so.

@h-vetinari
Copy link
Contributor Author

So that cmake issue seems to be really, really unfortunate here. :-( I wonder if the cure is worse than the disease here [...]

Yup, that's a distinct possibility IMO...

[...] and if it would be better to just keep what we have now - and simplify it only if cmake adds something like CMAKE_REQUIRED_DYNAMIC_LINK_OPTIONS or so.

It would probably make sense to report back on the CMake issue how big the fallout from this is? Perhaps the CMake devs would reconsider, or at least take it as an indicator for the necessity of CMAKE_REQUIRED_DYNAMIC_LINK_OPTIONS? I think you understand the problem space much better than me (I'm mostly stumbling around in a dark room TBH), so if you could do that that would be great!

ldionne pushed a commit that referenced this pull request Jul 31, 2024
Broken out from #93429

Somewhat closing the loop opened by 7017e6c.

Co-authored-by: Ryan Prichard <[email protected]>
@h-vetinari h-vetinari marked this pull request as draft August 12, 2024 05:38
@h-vetinari
Copy link
Contributor Author

I'm trying another approach here (now that #96171 showed we cannot get rid of llvm_check_compiler_linker_flag anyway) -- instead of doing the manual work-arounds for the linker flags & static targets everywhere, teach the existing function to do it (optionally).

There's not so many callers in the code base that this looks infeasible per se, but people might want to design the API differently (e.g. have a dedicated helper function for the case under consideration here). I'm also expecting this to break in various ways until I've figured out the right invocations everywhere. There's also several implementations of {target_,}add_flag_if_supported, which might have to expose similar arguments. Or we unify all those functions as well. Happy to iterate, or have someone else take over - I'll be the first to admit that CMake is not my forte 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category cmake Build system in general and CMake in particular compiler-rt libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. libunwind offload openmp:libomp OpenMP host runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants