diff --git a/recipe/meta.yaml b/recipe/meta.yaml index d940a040..de9dce85 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -18,13 +18,13 @@ source: - patches/0002-custom-error-message-for-old-sdk.patch # disable feature that requires up-to-date libcxxabi, which we don't ship - patches/0003-disable-_LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPT.patch - # work around https://github.com/llvm/llvm-project/issues/90332 - - patches/0004-Work-around-stray-nostdlib-flags-causing-errors-with.patch # allow chrono implementation to work on osx - - patches/0005-patch-__libcpp_tzdb_directory-to-allow-use-on-osx.patch + - patches/0004-patch-__libcpp_tzdb_directory-to-allow-use-on-osx.patch + # backport https://github.com/llvm/llvm-project/pull/108357 + - patches/0005-runtimes-Probe-for-nostdlib-and-nostdinc-with-the-C-.patch build: - number: 0 + number: 1 skip: true # [win] skip: true # [ppc64le or aarch64] diff --git a/recipe/patches/0001-Fix-ABI-compatibility-with-system.patch b/recipe/patches/0001-Fix-ABI-compatibility-with-system.patch index dddf00f7..22ea1685 100644 --- a/recipe/patches/0001-Fix-ABI-compatibility-with-system.patch +++ b/recipe/patches/0001-Fix-ABI-compatibility-with-system.patch @@ -1,4 +1,4 @@ -From bf8c76c5be4a6923267959f629650d375ffe1fb5 Mon Sep 17 00:00:00 2001 +From a3385409872d1aa20a1001053e91aea8879d06d9 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Tue, 13 Jul 2021 01:57:06 -0500 Subject: [PATCH 1/5] Fix ABI compatibility with system diff --git a/recipe/patches/0002-custom-error-message-for-old-sdk.patch b/recipe/patches/0002-custom-error-message-for-old-sdk.patch index c89eac99..26e53c94 100644 --- a/recipe/patches/0002-custom-error-message-for-old-sdk.patch +++ b/recipe/patches/0002-custom-error-message-for-old-sdk.patch @@ -1,4 +1,4 @@ -From 7a6b8cee3b11db797a01eb2bdd9a0e4c31bf6aca Mon Sep 17 00:00:00 2001 +From 3c17cb1e1b11482a4f57214270fb299e186ff895 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Wed, 29 Dec 2021 19:28:35 -0800 Subject: [PATCH 2/5] custom error message for old sdk diff --git a/recipe/patches/0003-disable-_LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPT.patch b/recipe/patches/0003-disable-_LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPT.patch index cbb03f1f..c4ed0969 100644 --- a/recipe/patches/0003-disable-_LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPT.patch +++ b/recipe/patches/0003-disable-_LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPT.patch @@ -1,4 +1,4 @@ -From 1fa872f42eb17226d5f37425f393c72bc12cfc92 Mon Sep 17 00:00:00 2001 +From 95421fd66d41d1cad4eb8d427a038786a524e950 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Sun, 26 May 2024 22:04:04 +1100 Subject: [PATCH 3/5] disable _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION diff --git a/recipe/patches/0004-Work-around-stray-nostdlib-flags-causing-errors-with.patch b/recipe/patches/0004-Work-around-stray-nostdlib-flags-causing-errors-with.patch deleted file mode 100644 index 73e21dec..00000000 --- a/recipe/patches/0004-Work-around-stray-nostdlib-flags-causing-errors-with.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 2ff612a0e19739e0523c98f6580a09c4dbd6bd73 Mon Sep 17 00:00:00 2001 -From: "H. Vetinari" -Date: Sun, 26 May 2024 13:01:28 +1100 -Subject: [PATCH 4/5] Work around stray `-nostdlib++` flags causing errors with - C compiler - ---- - libcxxabi/cmake/config-ix.cmake | 7 +++++-- - libunwind/cmake/config-ix.cmake | 7 +++++-- - libunwind/src/CMakeLists.txt | 6 ++++-- - 3 files changed, 14 insertions(+), 6 deletions(-) - -diff --git a/libcxxabi/cmake/config-ix.cmake b/libcxxabi/cmake/config-ix.cmake -index 10f2087c68c5..c0e58f8b255c 100644 ---- a/libcxxabi/cmake/config-ix.cmake -+++ b/libcxxabi/cmake/config-ix.cmake -@@ -106,8 +106,11 @@ elseif(ANDROID) - check_library_exists(c __cxa_thread_atexit_impl "" - LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL) - else() -- check_library_exists(dl dladdr "" LIBCXXABI_HAS_DL_LIB) -- check_library_exists(pthread pthread_once "" LIBCXXABI_HAS_PTHREAD_LIB) -+ # misdetected due to https://github.com/llvm/llvm-project/issues/90332 -+ # check_library_exists(dl dladdr "" LIBCXXABI_HAS_DL_LIB) -+ # check_library_exists(pthread pthread_once "" LIBCXXABI_HAS_PTHREAD_LIB) -+ set(LIBCXXABI_HAS_DL_LIB YES) -+ set(LIBCXXABI_HAS_PTHREAD_LIB YES) - check_library_exists(c __cxa_thread_atexit_impl "" - LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL) - endif() -diff --git a/libunwind/cmake/config-ix.cmake b/libunwind/cmake/config-ix.cmake -index 126c872f0d48..ab9ea1d5ce01 100644 ---- a/libunwind/cmake/config-ix.cmake -+++ b/libunwind/cmake/config-ix.cmake -@@ -120,8 +120,11 @@ if(FUCHSIA) - set(LIBUNWIND_HAS_DL_LIB NO) - set(LIBUNWIND_HAS_PTHREAD_LIB NO) - else() -- check_library_exists(dl dladdr "" LIBUNWIND_HAS_DL_LIB) -- check_library_exists(pthread pthread_once "" LIBUNWIND_HAS_PTHREAD_LIB) -+ # misdetected due to https://github.com/llvm/llvm-project/issues/90332 -+ # check_library_exists(dl dladdr "" LIBUNWIND_HAS_DL_LIB) -+ # check_library_exists(pthread pthread_once "" LIBUNWIND_HAS_PTHREAD_LIB) -+ set(LIBUNWIND_HAS_DL_LIB YES) -+ set(LIBUNWIND_HAS_PTHREAD_LIB YES) - endif() - - if(HAIKU) -diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt -index 780430ba70ba..8f53719d4007 100644 ---- a/libunwind/src/CMakeLists.txt -+++ b/libunwind/src/CMakeLists.txt -@@ -168,7 +168,8 @@ if (LIBUNWIND_ENABLE_SHARED) - set_target_properties(unwind_shared - PROPERTIES - LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" -- LINKER_LANGUAGE C -+ # changed from C due to https://github.com/llvm/llvm-project/issues/90332 -+ LINKER_LANGUAGE CXX - OUTPUT_NAME "${LIBUNWIND_SHARED_OUTPUT_NAME}" - VERSION "1.0" - SOVERSION "1" -@@ -214,7 +215,8 @@ if (LIBUNWIND_ENABLE_STATIC) - set_target_properties(unwind_static - PROPERTIES - LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" -- LINKER_LANGUAGE C -+ # changed from C due to https://github.com/llvm/llvm-project/issues/90332 -+ LINKER_LANGUAGE CXX - OUTPUT_NAME "${LIBUNWIND_STATIC_OUTPUT_NAME}" - ) - diff --git a/recipe/patches/0005-patch-__libcpp_tzdb_directory-to-allow-use-on-osx.patch b/recipe/patches/0004-patch-__libcpp_tzdb_directory-to-allow-use-on-osx.patch similarity index 86% rename from recipe/patches/0005-patch-__libcpp_tzdb_directory-to-allow-use-on-osx.patch rename to recipe/patches/0004-patch-__libcpp_tzdb_directory-to-allow-use-on-osx.patch index 29c0d42e..61c6b3c4 100644 --- a/recipe/patches/0005-patch-__libcpp_tzdb_directory-to-allow-use-on-osx.patch +++ b/recipe/patches/0004-patch-__libcpp_tzdb_directory-to-allow-use-on-osx.patch @@ -1,7 +1,7 @@ -From 9d8956c3caafe7460b5b29f469cb9acc8b7a01b9 Mon Sep 17 00:00:00 2001 +From a5762a552aca1ed0f6cf329ebc4c21b5924c09ff Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Wed, 31 Jul 2024 14:57:49 +1100 -Subject: [PATCH 5/5] patch __libcpp_tzdb_directory to allow use on osx +Subject: [PATCH 4/5] patch __libcpp_tzdb_directory to allow use on osx --- libcxx/src/experimental/tzdb.cpp | 4 ---- diff --git a/recipe/patches/0005-runtimes-Probe-for-nostdlib-and-nostdinc-with-the-C-.patch b/recipe/patches/0005-runtimes-Probe-for-nostdlib-and-nostdinc-with-the-C-.patch new file mode 100644 index 00000000..a3ceef2b --- /dev/null +++ b/recipe/patches/0005-runtimes-Probe-for-nostdlib-and-nostdinc-with-the-C-.patch @@ -0,0 +1,210 @@ +From 8c7344b606d21e9680a1467e759888c6a3a8ed00 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Martin=20Storsj=C3=B6?= +Date: Thu, 24 Oct 2024 23:46:04 +0300 +Subject: [PATCH 5/5] [runtimes] Probe for -nostdlib++ and -nostdinc++ with the + C compiler (#108357) + +While these flags semantically are relevant only for C++, we do add them +to CMAKE_REQUIRED_FLAGS if they are detected. All flags in that variable +are used both when testing compilation of C and C++ (and for detecting +libraries, which uses the C compiler driver). + +Therefore, to be sure we safely can add the flags to +CMAKE_REQUIRED_FLAGS, test for the option with the C language. + +This should fix compilation with GCC; newer versions of GCC do support +the -nostdlib++ option, but it's only supported by the C++ compiler +driver, not the C driver. (However, many builds of GCC also do accept +the option with the C driver, if GCC was compiled with Ada support +enabled, see [1]. That's why this issue isn't noticed in all +configurations with GCC.) + +Clang does support these options in both C and C++ driver modes. + +This should fix #90332. + +[1] +https://github.com/llvm/llvm-project/issues/90332#issuecomment-2325099254 +--- + libcxx/cmake/config-ix.cmake | 12 ++++++++---- + libcxxabi/cmake/config-ix.cmake | 12 ++++++++---- + libcxxabi/src/CMakeLists.txt | 4 ++-- + libunwind/cmake/config-ix.cmake | 12 ++++++++---- + libunwind/src/CMakeLists.txt | 2 +- + runtimes/CMakeLists.txt | 12 ++++++++---- + 6 files changed, 35 insertions(+), 19 deletions(-) + +diff --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake +index 998819604de2..582233663c68 100644 +--- a/libcxx/cmake/config-ix.cmake ++++ b/libcxx/cmake/config-ix.cmake +@@ -38,9 +38,13 @@ check_cxx_compiler_flag(-nolibc CXX_SUPPORTS_NOLIBC_FLAG) + # required during compilation (which has the -nostdlib++ or -nodefaultlibs). libc is + # required for the link to go through. We remove sanitizers from the + # configuration checks to avoid spurious link errors. ++# ++# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing ++# compilation of C and C++. Therefore test to make sure that the flags are ++# supported by the C compiler driver, before deciding to include them. + +-check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG) +-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG) ++check_c_compiler_flag(-nostdlib++ C_SUPPORTS_NOSTDLIBXX_FLAG) ++if (C_SUPPORTS_NOSTDLIBXX_FLAG) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") + else() + check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG) +@@ -51,7 +55,7 @@ endif() + + # Only link against compiler-rt manually if we use -nodefaultlibs, since + # otherwise the compiler will do the right thing on its own. +-if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG) ++if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG) + if (LIBCXX_USE_COMPILER_RT) + include(HandleCompilerRT) + find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY +@@ -81,7 +85,7 @@ if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG) + endif() + endif() + +-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG) ++if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG) + if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all") + endif () +diff --git a/libcxxabi/cmake/config-ix.cmake b/libcxxabi/cmake/config-ix.cmake +index 10f2087c68c5..ab74ad79a654 100644 +--- a/libcxxabi/cmake/config-ix.cmake ++++ b/libcxxabi/cmake/config-ix.cmake +@@ -22,9 +22,13 @@ endif () + # required during compilation (which has the -nodefaultlibs). libc is + # required for the link to go through. We remove sanitizers from the + # configuration checks to avoid spurious link errors. ++# ++# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing ++# compilation of C and C++. Therefore test to make sure that the flags are ++# supported by the C compiler driver, before deciding to include them. + +-check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG) +-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG) ++check_c_compiler_flag(-nostdlib++ C_SUPPORTS_NOSTDLIBXX_FLAG) ++if (C_SUPPORTS_NOSTDLIBXX_FLAG) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") + else() + check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG) +@@ -35,7 +39,7 @@ endif() + + # Only link against compiler-rt manually if we use -nodefaultlibs, since + # otherwise the compiler will do the right thing on its own. +-if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG) ++if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG) + if (LIBCXXABI_HAS_C_LIB) + list(APPEND CMAKE_REQUIRED_LIBRARIES c) + endif () +@@ -71,7 +75,7 @@ if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG) + endif() + endif() + +-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG) ++if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG) + if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all") + endif () +diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt +index 1e06b8cbf084..22b51c4e7fda 100644 +--- a/libcxxabi/src/CMakeLists.txt ++++ b/libcxxabi/src/CMakeLists.txt +@@ -91,7 +91,7 @@ if (ANDROID AND ANDROID_PLATFORM_LEVEL LESS 21) + endif() + + # Setup flags. +-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG) ++if (C_SUPPORTS_NOSTDLIBXX_FLAG) + add_link_flags_if_supported(-nostdlib++) + else() + add_link_flags_if_supported(-nodefaultlibs) +@@ -167,7 +167,7 @@ if (LIBCXXABI_USE_LLVM_UNWINDER) + endif() + endif() + target_link_libraries(cxxabi_shared_objects PRIVATE cxx-headers ${LIBCXXABI_LIBRARIES}) +-if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG) ++if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG) + target_link_libraries(cxxabi_shared_objects PRIVATE ${LIBCXXABI_BUILTINS_LIBRARY}) + endif() + target_link_libraries(cxxabi_shared_objects PUBLIC cxxabi-headers) +diff --git a/libunwind/cmake/config-ix.cmake b/libunwind/cmake/config-ix.cmake +index 126c872f0d48..88a13b4ec0e4 100644 +--- a/libunwind/cmake/config-ix.cmake ++++ b/libunwind/cmake/config-ix.cmake +@@ -34,9 +34,13 @@ endif() + # required during compilation (which has the -nostdlib++ or -nodefaultlibs). libc is + # required for the link to go through. We remove sanitizers from the + # configuration checks to avoid spurious link errors. ++# ++# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing ++# compilation of C and C++. Therefore test to make sure that the flags are ++# supported by the C compiler driver, before deciding to include them. + +-llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG) +-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG) ++llvm_check_compiler_linker_flag(C "-nostdlib++" C_SUPPORTS_NOSTDLIBXX_FLAG) ++if (C_SUPPORTS_NOSTDLIBXX_FLAG) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") + else() + llvm_check_compiler_linker_flag(C "-nodefaultlibs" C_SUPPORTS_NODEFAULTLIBS_FLAG) +@@ -47,7 +51,7 @@ endif() + + # Only link against compiler-rt manually if we use -nodefaultlibs, since + # otherwise the compiler will do the right thing on its own. +-if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG) ++if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG) + if (LIBUNWIND_HAS_C_LIB) + list(APPEND CMAKE_REQUIRED_LIBRARIES c) + endif () +@@ -82,7 +86,7 @@ if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG) + endif() + endif() + +-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG) ++if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG) + if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all") + endif () +diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt +index 780430ba70ba..09d23e967493 100644 +--- a/libunwind/src/CMakeLists.txt ++++ b/libunwind/src/CMakeLists.txt +@@ -66,7 +66,7 @@ set(LIBUNWIND_SOURCES + ${LIBUNWIND_ASM_SOURCES}) + + # Generate library list. +-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG) ++if (C_SUPPORTS_NOSTDLIBXX_FLAG) + add_link_flags_if_supported(-nostdlib++) + else() + if (LIBUNWIND_USE_COMPILER_RT) +diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt +index 830165c799c2..8db2b3fb9309 100644 +--- a/runtimes/CMakeLists.txt ++++ b/runtimes/CMakeLists.txt +@@ -143,12 +143,16 @@ endif() + # Check for -nostdlib++ first; if there's no C++ standard library yet, + # all check_cxx_compiler_flag commands will fail until we add -nostdlib++ + # (or -nodefaultlibs). +-llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG) +-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG) ++# ++# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing ++# compilation of C and C++. Therefore test to make sure that the flags are ++# supported by the C compiler driver, before deciding to include them. ++llvm_check_compiler_linker_flag(C "-nostdlib++" C_SUPPORTS_NOSTDLIBXX_FLAG) ++if (C_SUPPORTS_NOSTDLIBXX_FLAG) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") + endif() +-check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG) +-if (CXX_SUPPORTS_NOSTDINCXX_FLAG) ++check_c_compiler_flag(-nostdinc++ C_SUPPORTS_NOSTDINCXX_FLAG) ++if (C_SUPPORTS_NOSTDINCXX_FLAG) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++") + endif() +