Skip to content

Commit

Permalink
add more context to patches; merge fixes for stray -nostdlib++
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Jul 8, 2024
1 parent e73c219 commit 6d71464
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 68 deletions.
8 changes: 3 additions & 5 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion recipe/patches/0001-Support-legacy-standalone-builds.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From bf0dac8954fed53dcc579ccf564dd011e11616b2 Mon Sep 17 00:00:00 2001
From: Isuru Fernando <isuruf@gmail.com>
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 +++++++++++++++++
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From b1113a136e91b0788e2fa28e578142e45016eae9 Mon Sep 17 00:00:00 2001
From: Isuru Fernando <isuruf@gmail.com>
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 ++++++++--------
Expand Down
2 changes: 1 addition & 1 deletion recipe/patches/0003-custom-error-message-for-old-sdk.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 7e2722ee435b20f9445be40ace0f5298126ae23c Mon Sep 17 00:00:00 2001
From: Isuru Fernando <isuruf@gmail.com>
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 <h.vetinari@gmx.com>
---
Expand Down
Original file line number Diff line number Diff line change
@@ -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" <h.vetinari@gmx.com>
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(-)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
From 6a49c1d89912796cd7ea3f4a9e3eb606ca553257 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <h.vetinari@gmx.com>
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}"
)

This file was deleted.

This file was deleted.

0 comments on commit 6d71464

Please sign in to comment.