From 6d714642ff48c7caa45bca983e1783eb8e176541 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Mon, 8 Jul 2024 12:38:14 +1100 Subject: [PATCH] add more context to patches; merge fixes for stray `-nostdlib++` --- recipe/meta.yaml | 8 ++- ...001-Support-legacy-standalone-builds.patch | 2 +- ...02-Fix-ABI-compatibility-with-system.patch | 2 +- ...003-custom-error-message-for-old-sdk.patch | 2 +- ...AVAILABILITY_HAS_INIT_PRIMARY_EXCEPT.patch | 19 +++++-- ...y-nostdlib-flags-causing-errors-with.patch | 53 +++++++++++++++++++ ...age-for-libunwind-to-avoid-running-i.patch | 32 ----------- ...-misdetection-of-dl-pthread-on-linux.patch | 24 --------- 8 files changed, 74 insertions(+), 68 deletions(-) create mode 100644 recipe/patches/0006-Work-around-stray-nostdlib-flags-causing-errors-with.patch delete mode 100644 recipe/patches/0006-set-CXX-as-language-for-libunwind-to-avoid-running-i.patch delete mode 100644 recipe/patches/0007-avoid-misdetection-of-dl-pthread-on-linux.patch diff --git a/recipe/meta.yaml b/recipe/meta.yaml index dbb1b1c..82cf2ba 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -16,12 +16,10 @@ source: # See https://discourse.llvm.org/t/shipping-custom-libc-on-macos/58606 - patches/0002-Fix-ABI-compatibility-with-system.patch # [sys_abi == "pre-12"] - patches/0003-custom-error-message-for-old-sdk.patch - # fix for https://github.com/llvm/llvm-project/issues/77653 + # disable feature that requires up-to-date libcxxabi, which we don't ship - patches/0005-disable-_LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPT.patch - # GCC's C linker does not understand -nostdlib++; needs CXX - - patches/0006-set-CXX-as-language-for-libunwind-to-avoid-running-i.patch - # something broke detection of dladdr on linux - - patches/0007-avoid-misdetection-of-dl-pthread-on-linux.patch + # work around https://github.com/llvm/llvm-project/issues/90332 + - patches/0006-Work-around-stray-nostdlib-flags-causing-errors-with.patch build: number: 0 diff --git a/recipe/patches/0001-Support-legacy-standalone-builds.patch b/recipe/patches/0001-Support-legacy-standalone-builds.patch index 9b6d5aa..8914f94 100644 --- a/recipe/patches/0001-Support-legacy-standalone-builds.patch +++ b/recipe/patches/0001-Support-legacy-standalone-builds.patch @@ -1,7 +1,7 @@ From bf0dac8954fed53dcc579ccf564dd011e11616b2 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Tue, 18 May 2021 19:51:28 -0500 -Subject: [PATCH 1/7] Support legacy standalone builds +Subject: [PATCH 1/5] Support legacy standalone builds --- libcxx/src/CMakeLists.txt | 17 +++++++++++++++++ diff --git a/recipe/patches/0002-Fix-ABI-compatibility-with-system.patch b/recipe/patches/0002-Fix-ABI-compatibility-with-system.patch index ea1da26..abd02b2 100644 --- a/recipe/patches/0002-Fix-ABI-compatibility-with-system.patch +++ b/recipe/patches/0002-Fix-ABI-compatibility-with-system.patch @@ -1,7 +1,7 @@ From b1113a136e91b0788e2fa28e578142e45016eae9 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Tue, 13 Jul 2021 01:57:06 -0500 -Subject: [PATCH 2/7] Fix ABI compatibility with system +Subject: [PATCH 2/5] Fix ABI compatibility with system --- libcxx/src/locale.cpp | 16 ++++++++-------- diff --git a/recipe/patches/0003-custom-error-message-for-old-sdk.patch b/recipe/patches/0003-custom-error-message-for-old-sdk.patch index 41288c2..987b89b 100644 --- a/recipe/patches/0003-custom-error-message-for-old-sdk.patch +++ b/recipe/patches/0003-custom-error-message-for-old-sdk.patch @@ -1,7 +1,7 @@ From 7e2722ee435b20f9445be40ace0f5298126ae23c Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Wed, 29 Dec 2021 19:28:35 -0800 -Subject: [PATCH 3/7] custom error message for old sdk +Subject: [PATCH 3/5] custom error message for old sdk Co-Authored-By: H. Vetinari --- diff --git a/recipe/patches/0005-disable-_LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPT.patch b/recipe/patches/0005-disable-_LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPT.patch index 301f6e3..eef2403 100644 --- a/recipe/patches/0005-disable-_LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPT.patch +++ b/recipe/patches/0005-disable-_LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPT.patch @@ -1,11 +1,22 @@ -From 5499430ec91578805ae0ca5fd5c994f29e41b01d Mon Sep 17 00:00:00 2001 +From 4744d322ef96d67b8543897b49ec8897d2633a1a Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Sun, 26 May 2024 22:04:04 +1100 -Subject: [PATCH 5/7] disable _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION +Subject: [PATCH 4/5] disable _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION unconditionally -https://github.com/llvm/llvm-project/issues/77653 -https://github.com/llvm/llvm-project/issues/86077 +When _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS is not defined, things +work as expected: i.e. the feature is only used on macOS that vendors LLVM>=18. + +Our general policy of setting `-D_LIBCPP_DISABLE_AVAILABILITY` (which causes +the above macro to be defined) wherever newer C++ features are needed works +fine because we ship our own libcxx. In this case however, the required symbols +(`___cxa_init_primary_exception` etc.) is in libcxxabi, which we intentionally +don't ship ourselves. + +Therefore, we must disable this feature unconditionally, at least until our +macOS baseline is >=15.0, as we rely on the libcxxabi shipped by the system. + +See also https://github.com/llvm/llvm-project/issues/77653 & https://github.com/llvm/llvm-project/issues/86077 --- libcxx/include/__availability | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/patches/0006-Work-around-stray-nostdlib-flags-causing-errors-with.patch b/recipe/patches/0006-Work-around-stray-nostdlib-flags-causing-errors-with.patch new file mode 100644 index 0000000..f424c4e --- /dev/null +++ b/recipe/patches/0006-Work-around-stray-nostdlib-flags-causing-errors-with.patch @@ -0,0 +1,53 @@ +From 6a49c1d89912796cd7ea3f4a9e3eb606ca553257 Mon Sep 17 00:00:00 2001 +From: "H. Vetinari" +Date: Sun, 26 May 2024 13:01:28 +1100 +Subject: [PATCH 5/5] Work around stray `-nostdlib++` flags causing errors with + C compiler + +--- + libunwind/cmake/config-ix.cmake | 7 +++++-- + libunwind/src/CMakeLists.txt | 6 ++++-- + 2 files changed, 9 insertions(+), 4 deletions(-) + +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/0006-set-CXX-as-language-for-libunwind-to-avoid-running-i.patch b/recipe/patches/0006-set-CXX-as-language-for-libunwind-to-avoid-running-i.patch deleted file mode 100644 index 3fc4556..0000000 --- a/recipe/patches/0006-set-CXX-as-language-for-libunwind-to-avoid-running-i.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 7d1809e27c49dadf14b791cdc93a1ea58a2d8def Mon Sep 17 00:00:00 2001 -From: "H. Vetinari" -Date: Sun, 26 May 2024 13:01:28 +1100 -Subject: [PATCH 6/7] set CXX as language for libunwind to avoid running into - unknown flags for CC - ---- - libunwind/src/CMakeLists.txt | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt -index 780430ba70ba..2cf2c8c0f1f7 100644 ---- a/libunwind/src/CMakeLists.txt -+++ b/libunwind/src/CMakeLists.txt -@@ -168,7 +168,7 @@ if (LIBUNWIND_ENABLE_SHARED) - set_target_properties(unwind_shared - PROPERTIES - LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" -- LINKER_LANGUAGE C -+ LINKER_LANGUAGE CXX - OUTPUT_NAME "${LIBUNWIND_SHARED_OUTPUT_NAME}" - VERSION "1.0" - SOVERSION "1" -@@ -214,7 +214,7 @@ if (LIBUNWIND_ENABLE_STATIC) - set_target_properties(unwind_static - PROPERTIES - LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" -- LINKER_LANGUAGE C -+ LINKER_LANGUAGE CXX - OUTPUT_NAME "${LIBUNWIND_STATIC_OUTPUT_NAME}" - ) - diff --git a/recipe/patches/0007-avoid-misdetection-of-dl-pthread-on-linux.patch b/recipe/patches/0007-avoid-misdetection-of-dl-pthread-on-linux.patch deleted file mode 100644 index e8e9e63..0000000 --- a/recipe/patches/0007-avoid-misdetection-of-dl-pthread-on-linux.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 8ca66527c9f7930a153ee8be487aa77734277967 Mon Sep 17 00:00:00 2001 -From: "H. Vetinari" -Date: Sun, 26 May 2024 15:35:03 +1100 -Subject: [PATCH 7/7] avoid misdetection of dl/pthread on linux - ---- - libunwind/cmake/config-ix.cmake | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/libunwind/cmake/config-ix.cmake b/libunwind/cmake/config-ix.cmake -index 126c872f0d48..7b5ff47ac011 100644 ---- a/libunwind/cmake/config-ix.cmake -+++ b/libunwind/cmake/config-ix.cmake -@@ -120,8 +120,8 @@ 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) -+ set(LIBUNWIND_HAS_DL_LIB YES) -+ set(LIBUNWIND_HAS_PTHREAD_LIB YES) - endif() - - if(HAIKU)