From 674441c3d46a5467664421726aa1a887f575fdf5 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Fri, 4 Oct 2024 14:33:07 +0100 Subject: [PATCH] [Musl] Add back missing autolink arguments, fix CFPosixSpawnFileActionsChdir. We need a handful more autolink arguments; these were in a previous PR, but seem to have gone missing at some point during the re-core. Additionally, Musl has the `posix_spawn_file_actions_addchdir_np()` function rather than the non-`_np()` version. Fixes #5089. --- CMakeLists.txt | 1 + Sources/CoreFoundation/CFPlatform.c | 2 +- Sources/FoundationNetworking/CMakeLists.txt | 11 ++++++++++- Sources/FoundationXML/CMakeLists.txt | 7 +++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fbdee6ae6..256536f92b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) option(BUILD_SHARED_LIBS "build shared libraries" ON) +option(BUILD_FULLY_STATIC "build fully static" NO) # Optionally build tools (on by default) but only when building shared libraries if(BUILD_SHARED_LIBS) diff --git a/Sources/CoreFoundation/CFPlatform.c b/Sources/CoreFoundation/CFPlatform.c index b13b778c32..69631185ba 100644 --- a/Sources/CoreFoundation/CFPlatform.c +++ b/Sources/CoreFoundation/CFPlatform.c @@ -2283,7 +2283,7 @@ CF_EXPORT int _CFPosixSpawnFileActionsChdir(_CFPosixSpawnFileActionsRef file_act // Glibc versions prior to 2.29 don't support posix_spawn_file_actions_addchdir_np, impacting: // - Amazon Linux 2 (EoL mid-2025) return ENOSYS; - #elif defined(__GLIBC__) || TARGET_OS_DARWIN || defined(__FreeBSD__) || defined(__ANDROID__) + #elif defined(__GLIBC__) || TARGET_OS_DARWIN || defined(__FreeBSD__) || defined(__ANDROID__) || defined(__musl__) // Pre-standard posix_spawn_file_actions_addchdir_np version available in: // - Solaris 11.3 (October 2015) // - Glibc 2.29 (February 2019) diff --git a/Sources/FoundationNetworking/CMakeLists.txt b/Sources/FoundationNetworking/CMakeLists.txt index 90e5ddeef1..6ad40968dc 100644 --- a/Sources/FoundationNetworking/CMakeLists.txt +++ b/Sources/FoundationNetworking/CMakeLists.txt @@ -61,7 +61,16 @@ if(NOT BUILD_SHARED_LIBS) target_compile_options(FoundationNetworking PRIVATE "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend curl>") target_compile_options(FoundationNetworking PRIVATE - "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend swiftSynchronization>") + "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend swiftSynchronization>") + + if(BUILD_FULLY_STATIC) + target_compile_options(FoundationNetworking + PRIVATE + "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend crypto>" + "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend ssl>" + "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend z>") + endif() + endif() set_target_properties(FoundationNetworking PROPERTIES diff --git a/Sources/FoundationXML/CMakeLists.txt b/Sources/FoundationXML/CMakeLists.txt index 72021afb38..5c8a0fb301 100644 --- a/Sources/FoundationXML/CMakeLists.txt +++ b/Sources/FoundationXML/CMakeLists.txt @@ -37,6 +37,13 @@ if(NOT BUILD_SHARED_LIBS) "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend xml2>") target_compile_options(FoundationXML PRIVATE "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend swiftSynchronization>") + + if(BUILD_FULLY_STATIC) + target_compile_options(FoundationXML + PRIVATE + "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend z>") + endif() + endif() set_target_properties(FoundationXML PROPERTIES