From 3506f58a89de211823dcee98eb698dfcc1414fc5 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 7 Aug 2024 05:10:42 +0000 Subject: [PATCH 01/12] [CMake] Use LIBXML2_INCLUDE_DIR instead of hardcoding /usr/include/libxml2 `find_package(LibXml2 REQUIRED)` sets `LIBXML2_INCLUDE_DIR` to the correct include directory for the libxml2 headers. Use this variable instead of hardcoding `/usr/include/libxml2`. This allows the build to work with custom libxml2 builds on WASI. --- Sources/_CFXMLInterface/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/_CFXMLInterface/CMakeLists.txt b/Sources/_CFXMLInterface/CMakeLists.txt index d6e63a3f59..d550a520f1 100644 --- a/Sources/_CFXMLInterface/CMakeLists.txt +++ b/Sources/_CFXMLInterface/CMakeLists.txt @@ -20,7 +20,7 @@ target_include_directories(_CFXMLInterface ../CoreFoundation/include PRIVATE ../CoreFoundation/internalInclude - /usr/include/libxml2/) + ${LIBXML2_INCLUDE_DIR}) target_compile_options(_CFXMLInterface INTERFACE "$<$:SHELL:-Xcc -fmodule-map-file=${CMAKE_CURRENT_SOURCE_DIR}/../CoreFoundation/include/module.modulemap>" From fef108320304306b2765df0f839dafabdbf714bd Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 7 Aug 2024 05:13:38 +0000 Subject: [PATCH 02/12] [CMake] Disable libdispatch & threads, enable some emulations on WASI This commit disables libdispatch and threads on WASI, and enables wasi-libc emulation features. --- CMakeLists.txt | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index edb6cf06f9..2bce742627 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,7 @@ endif() # System dependencies find_package(dispatch CONFIG) -if(NOT dispatch_FOUND) +if(NOT dispatch_FOUND AND NOT CMAKE_SYSTEM_NAME STREQUAL WASI) if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") set(DEFAULT_DISPATCH_INCLUDE_PATH "/usr/lib/swift") elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") @@ -113,7 +113,6 @@ find_package(CURL REQUIRED) list(APPEND _Foundation_common_build_flags "-DDEPLOYMENT_RUNTIME_SWIFT" "-DCF_BUILDING_CF" - "-DDEPLOYMENT_ENABLE_LIBDISPATCH" "-DHAVE_STRUCT_TIMESPEC" "-Wno-shorten-64-to-32" "-Wno-deprecated-declarations" @@ -126,16 +125,10 @@ list(APPEND _Foundation_common_build_flags "-Wno-switch" "-fblocks") -if(CMAKE_SYSTEM_NAME STREQUAL "WASI") - list(APPEND _Foundation_common_build_flags - "-D_WASI_EMULATED_SIGNAL" - "-DHAVE_STRLCPY" - "-DHAVE_STRLCAT" - ) -else() - list(APPEND _Foundation_common_build_flags - "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS" - ) +if(NOT CMAKE_SYSTEM_NAME STREQUAL WASI) + list(APPEND _Foundation_common_build_flags + "-DDEPLOYMENT_ENABLE_LIBDISPATCH" + "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS") endif() if(NOT "${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC") @@ -168,16 +161,17 @@ list(APPEND _Foundation_swift_build_flags "-Xfrontend" "-require-explicit-sendable") -if(CMAKE_SYSTEM_NAME STREQUAL "WASI") - list(APPEND _Foundation_swift_build_flags - "-D_WASI_EMULATED_SIGNAL" - "-DHAVE_STRLCPY" - "-DHAVE_STRLCAT" - ) +if(CMAKE_SYSTEM_NAME STREQUAL WASI) + # Enable wasi-libc emulation features + set(WASI_EMULATION_DEFS _WASI_EMULATED_MMAN _WASI_EMULATED_SIGNAL _WASI_EMULATED_PROCESS_CLOCKS) + foreach(def ${WASI_EMULATION_DEFS}) + list(APPEND _Foundation_swift_build_flags "SHELL:-Xcc -D${def}") + list(APPEND _Foundation_common_build_flags "-D${def}") + endforeach() else() - list(APPEND _Foundation_swift_build_flags - "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS" - ) + # Assume we have threads on other platforms + list(APPEND _Foundation_swift_build_flags + "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS") endif() if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") From 27310f474957020b3083605083d86c93a812b42a Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 7 Aug 2024 05:15:39 +0000 Subject: [PATCH 03/12] [CMake] Exclude FoundationNetworking and _CFURLSessionInterface on WASI Because networking is not a part of WASI Preview 1. We can add it back when it is available. --- Sources/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 0ee266a4bc..29b9244065 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -14,10 +14,14 @@ add_subdirectory(CoreFoundation) add_subdirectory(_CFXMLInterface) -add_subdirectory(_CFURLSessionInterface) +if(NOT CMAKE_SYSTEM_NAME STREQUAL "WASI") + add_subdirectory(_CFURLSessionInterface) +endif() add_subdirectory(Foundation) add_subdirectory(FoundationXML) -add_subdirectory(FoundationNetworking) +if(NOT CMAKE_SYSTEM_NAME STREQUAL "WASI") + add_subdirectory(FoundationNetworking) +endif() if(FOUNDATION_BUILD_TOOLS) add_subdirectory(plutil) endif() From 164af81d45dfff66d8d409f5f6bd946cb3987bc4 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 7 Aug 2024 05:34:51 +0000 Subject: [PATCH 04/12] [wasm] Include CFPreferences.h, CFRunLoop.h, and CFStream.h in WASI builds Those headers has been imported by Swift side through `CoreFoundation/Base.subproj/SwiftRuntime/CoreFoundation.h` since 44031b5a0e96ad91eada2261db2d3890818fe1d0 but we switched to use CoreFoundation.h directly after the recore, and the header was not updated in 44031b5a0e96ad91eada2261db2d3890818fe1d0 --- Sources/CoreFoundation/include/CoreFoundation.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Sources/CoreFoundation/include/CoreFoundation.h b/Sources/CoreFoundation/include/CoreFoundation.h index a66e7e614d..64313f0b9f 100644 --- a/Sources/CoreFoundation/include/CoreFoundation.h +++ b/Sources/CoreFoundation/include/CoreFoundation.h @@ -58,9 +58,7 @@ #include "CFLocale.h" #include "CFNumber.h" #include "CFNumberFormatter.h" -#if !TARGET_OS_WASI #include "CFPreferences.h" -#endif #include "CFPropertyList.h" #include "CFSet.h" #include "CFString.h" @@ -76,13 +74,17 @@ #include "ForSwiftFoundationOnly.h" -#if TARGET_OS_OSX || TARGET_OS_IPHONE || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_OSX || TARGET_OS_IPHONE || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_WASI +# if !TARGET_OS_WASI #include "CFMessagePort.h" #include "CFPlugIn.h" +# endif #include "CFRunLoop.h" #include "CFStream.h" +# if !TARGET_OS_WASI #include "CFSocket.h" #include "CFMachPort.h" +# endif #include "CFAttributedString.h" #include "CFNotificationCenter.h" From f91a759124ea50b491c3fe0fa8ecf34b39de6c20 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 7 Aug 2024 05:39:34 +0000 Subject: [PATCH 05/12] [wasm] Fix the new CFString.c compilation error on WASI Treat WASI as an usual Unix-like system --- Sources/CoreFoundation/CFString.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/CoreFoundation/CFString.c b/Sources/CoreFoundation/CFString.c index 94a6c86d15..f8899e1589 100644 --- a/Sources/CoreFoundation/CFString.c +++ b/Sources/CoreFoundation/CFString.c @@ -35,7 +35,7 @@ #include #include #include -#if TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD +#if TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WASI #include #endif #if TARGET_OS_WASI From 27efb0c4dcc1de3669bd7adf8a9a7b42f4c6cf80 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 7 Aug 2024 05:40:24 +0000 Subject: [PATCH 06/12] [wasm] Build the vendored version of BlocksRuntime on WASI We had been using the vendored BlocksRuntime on WASI, but the build configuration was removed during the recore. This change restores the vendored BlocksRuntime build configuration on WASI. --- .../BlockRuntime/CMakeLists.txt | 37 +++++++++++++++++++ Sources/CoreFoundation/CMakeLists.txt | 6 +++ Sources/_CFXMLInterface/CMakeLists.txt | 4 ++ 3 files changed, 47 insertions(+) create mode 100644 Sources/CoreFoundation/BlockRuntime/CMakeLists.txt diff --git a/Sources/CoreFoundation/BlockRuntime/CMakeLists.txt b/Sources/CoreFoundation/BlockRuntime/CMakeLists.txt new file mode 100644 index 0000000000..afcd826aed --- /dev/null +++ b/Sources/CoreFoundation/BlockRuntime/CMakeLists.txt @@ -0,0 +1,37 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift open source project +## +## Copyright (c) 2024 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 +## +## See LICENSE.txt for license information +## See CONTRIBUTORS.md for the list of Swift project authors +## +## SPDX-License-Identifier: Apache-2.0 +## +##===----------------------------------------------------------------------===## + +# Build the vendored version of the BlocksRuntime library, which is used by +# platforms that don't support libdispatch. + +add_library(BlocksRuntime + data.c + runtime.c) + +target_include_directories(BlocksRuntime PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include + # For CFTargetConditionals.h + ${CMAKE_CURRENT_SOURCE_DIR}/../include) + +set_target_properties(BlocksRuntime PROPERTIES + POSITION_INDEPENDENT_CODE FALSE) + +add_library(BlocksRuntime::BlocksRuntime ALIAS BlocksRuntime) + +if(NOT BUILD_SHARED_LIBS) + set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS BlocksRuntime) + install(TARGETS BlocksRuntime + ARCHIVE DESTINATION lib/swift$<$>:_static>/${SWIFT_SYSTEM_NAME} + LIBRARY DESTINATION lib/swift$<$>:_static>/${SWIFT_SYSTEM_NAME}) +endif() diff --git a/Sources/CoreFoundation/CMakeLists.txt b/Sources/CoreFoundation/CMakeLists.txt index e366005f72..c73891b264 100644 --- a/Sources/CoreFoundation/CMakeLists.txt +++ b/Sources/CoreFoundation/CMakeLists.txt @@ -118,6 +118,12 @@ target_link_libraries(CoreFoundation _FoundationICU dispatch) +if(CMAKE_SYSTEM_NAME STREQUAL WASI) + # On WASI, we use vendored BlocksRuntime instead of the one from libdispatch + add_subdirectory(BlockRuntime) + target_link_libraries(CoreFoundation PRIVATE BlocksRuntime) +endif() + set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS CoreFoundation) # Copy Headers to known directory for direct client (XCTest) test builds diff --git a/Sources/_CFXMLInterface/CMakeLists.txt b/Sources/_CFXMLInterface/CMakeLists.txt index d550a520f1..9ca0c27900 100644 --- a/Sources/_CFXMLInterface/CMakeLists.txt +++ b/Sources/_CFXMLInterface/CMakeLists.txt @@ -33,6 +33,10 @@ target_link_libraries(_CFXMLInterface PRIVATE dispatch LibXml2::LibXml2) +if(CMAKE_SYSTEM_NAME STREQUAL WASI) + target_link_libraries(_CFXMLInterface PRIVATE BlocksRuntime) +endif() + if(NOT BUILD_SHARED_LIBS) set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS _CFXMLInterface) install(TARGETS _CFXMLInterface From f0a363172fe22093e5d65a004203199db398733f Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 7 Aug 2024 05:41:37 +0000 Subject: [PATCH 07/12] [wasm] `strlcpy` and `strlcat` are available in wasi-libc Mark them available on WASI. Otherwise, the `static inline` implementations are activated and the build fails with multiple definitions. --- .../CoreFoundation/internalInclude/CoreFoundation_Prefix.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sources/CoreFoundation/internalInclude/CoreFoundation_Prefix.h b/Sources/CoreFoundation/internalInclude/CoreFoundation_Prefix.h index 9ef8f64a6c..dea3b57537 100644 --- a/Sources/CoreFoundation/internalInclude/CoreFoundation_Prefix.h +++ b/Sources/CoreFoundation/internalInclude/CoreFoundation_Prefix.h @@ -109,6 +109,11 @@ typedef char * Class; #include #endif +#if TARGET_OS_WASI +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#endif + #if TARGET_OS_WIN32 #define BOOL WINDOWS_BOOL From 8176d11c41fc96500692f3bc59f8a0609b08cfa6 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 7 Aug 2024 06:06:22 +0000 Subject: [PATCH 08/12] [Build] Repair WASI build with SwiftPM --- Package.swift | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Package.swift b/Package.swift index 1477aefd00..dc86631a79 100644 --- a/Package.swift +++ b/Package.swift @@ -39,14 +39,12 @@ let coreFoundationBuildSettings: [CSetting] = [ .headerSearchPath("internalInclude"), .define("DEBUG", .when(configuration: .debug)), .define("CF_BUILDING_CF"), - .define("DEPLOYMENT_ENABLE_LIBDISPATCH"), + .define("DEPLOYMENT_ENABLE_LIBDISPATCH", .when(platforms: platformsWithThreads)), .define("DEPLOYMENT_RUNTIME_SWIFT"), .define("HAVE_STRUCT_TIMESPEC"), .define("SWIFT_CORELIBS_FOUNDATION_HAS_THREADS", .when(platforms: platformsWithThreads)), .define("_GNU_SOURCE", .when(platforms: [.linux, .android])), .define("_WASI_EMULATED_SIGNAL", .when(platforms: [.wasi])), - .define("HAVE_STRLCPY", .when(platforms: [.wasi])), - .define("HAVE_STRLCAT", .when(platforms: [.wasi])), .unsafeFlags([ "-Wno-shorten-64-to-32", "-Wno-deprecated-declarations", @@ -78,8 +76,6 @@ let interfaceBuildSettings: [CSetting] = [ .define("SWIFT_CORELIBS_FOUNDATION_HAS_THREADS", .when(platforms: platformsWithThreads)), .define("_GNU_SOURCE", .when(platforms: [.linux, .android])), .define("_WASI_EMULATED_SIGNAL", .when(platforms: [.wasi])), - .define("HAVE_STRLCPY", .when(platforms: [.wasi])), - .define("HAVE_STRLCAT", .when(platforms: [.wasi])), .unsafeFlags([ "-Wno-shorten-64-to-32", "-Wno-deprecated-declarations", @@ -161,7 +157,8 @@ let package = Package( .product(name: "FoundationEssentials", package: "swift-foundation"), "Foundation", "CoreFoundation", - "_CFXMLInterface" + "_CFXMLInterface", + .target(name: "BlocksRuntime", condition: .when(platforms: [.wasi])), ], path: "Sources/FoundationXML", exclude: [ @@ -187,6 +184,7 @@ let package = Package( name: "CoreFoundation", dependencies: [ .product(name: "_FoundationICU", package: "swift-foundation-icu"), + .target(name: "BlocksRuntime", condition: .when(platforms: [.wasi])), ], path: "Sources/CoreFoundation", exclude: [ @@ -195,6 +193,17 @@ let package = Package( ], cSettings: coreFoundationBuildSettings ), + .target( + name: "BlocksRuntime", + path: "Sources/CoreFoundation/BlockRuntime", + exclude: [ + "CMakeLists.txt" + ], + cSettings: [ + // For CFTargetConditionals.h + .headerSearchPath("../include"), + ] + ), .target( name: "_CFXMLInterface", dependencies: [ From e5104c30858832ae1a26cc65c221b091d3f651cb Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 7 Aug 2024 06:12:47 +0000 Subject: [PATCH 09/12] Use `__builtin_return_address` instead of `__builtin_frame_address` We accidentally changed it to `__builtin_frame_address` in 7f382649f9052da61b6c1054a5e06fa6f345ddc8 but we should keep it as `__builtin_return_address` as it was before. --- Sources/CoreFoundation/CFBundle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/CoreFoundation/CFBundle.c b/Sources/CoreFoundation/CFBundle.c index 05afe9888e..607c7bd925 100644 --- a/Sources/CoreFoundation/CFBundle.c +++ b/Sources/CoreFoundation/CFBundle.c @@ -600,7 +600,7 @@ CFBundleRef CFBundleGetBundleWithIdentifier(CFStringRef bundleID) { #if TARGET_OS_WASI hint = NULL; #else - hint = __builtin_frame_address(0); + hint = __builtin_return_address(0); #endif return _CFBundleGetBundleWithIdentifier(bundleID, hint); } From a1b9c39eb44478cdbabfcbb889752445c63031b9 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 7 Aug 2024 15:48:14 +0000 Subject: [PATCH 10/12] [CMake] Not even try to find libdispatch on WASI --- CMakeLists.txt | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bce742627..058fb31156 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,18 +93,22 @@ if(NOT SwiftFoundation_MODULE_TRIPLE) endif() # System dependencies -find_package(dispatch CONFIG) -if(NOT dispatch_FOUND AND NOT CMAKE_SYSTEM_NAME STREQUAL WASI) - if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") - set(DEFAULT_DISPATCH_INCLUDE_PATH "/usr/lib/swift") - elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") - set(DEFAULT_DISPATCH_INCLUDE_PATH "$ENV{SDKROOT}usr/include") + +# We know libdispatch is always unavailable on WASI +if(NOT CMAKE_SYSTEM_NAME STREQUAL WASI) + find_package(dispatch CONFIG) + if(NOT dispatch_FOUND) + if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") + set(DEFAULT_DISPATCH_INCLUDE_PATH "/usr/lib/swift") + elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(DEFAULT_DISPATCH_INCLUDE_PATH "$ENV{SDKROOT}usr/include") + endif() + set(DISPATCH_INCLUDE_PATH "${DEFAULT_DISPATCH_INCLUDE_PATH}" CACHE STRING "A path to where you can find libdispatch headers") + message("-- dispatch_DIR not found, using dispatch from SDK at ${DISPATCH_INCLUDE_PATH}") + list(APPEND _Foundation_common_build_flags + "-I${DISPATCH_INCLUDE_PATH}" + "-I${DISPATCH_INCLUDE_PATH}/Block") endif() - set(DISPATCH_INCLUDE_PATH "${DEFAULT_DISPATCH_INCLUDE_PATH}" CACHE STRING "A path to where you can find libdispatch headers") - message("-- dispatch_DIR not found, using dispatch from SDK at ${DISPATCH_INCLUDE_PATH}") - list(APPEND _Foundation_common_build_flags - "-I${DISPATCH_INCLUDE_PATH}" - "-I${DISPATCH_INCLUDE_PATH}/Block") endif() find_package(LibXml2 REQUIRED) find_package(CURL REQUIRED) From 965246eebdb263f1ac0d8f42723821a82570b31c Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 7 Aug 2024 16:40:22 +0000 Subject: [PATCH 11/12] [CMake] Build BlocksRuntime as object library To avoid shippig BlocksRuntime as a separate library, build it as an object library and include it in CoreFoundation static archive. --- Sources/CoreFoundation/BlockRuntime/CMakeLists.txt | 13 ++++--------- Sources/CoreFoundation/CMakeLists.txt | 1 + 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Sources/CoreFoundation/BlockRuntime/CMakeLists.txt b/Sources/CoreFoundation/BlockRuntime/CMakeLists.txt index afcd826aed..fe5e13bb7c 100644 --- a/Sources/CoreFoundation/BlockRuntime/CMakeLists.txt +++ b/Sources/CoreFoundation/BlockRuntime/CMakeLists.txt @@ -15,7 +15,9 @@ # Build the vendored version of the BlocksRuntime library, which is used by # platforms that don't support libdispatch. -add_library(BlocksRuntime +# Build the BlocksRuntime as an object library, shipped as a part +# of libCoreFoundation. +add_library(BlocksRuntime OBJECT data.c runtime.c) @@ -27,11 +29,4 @@ target_include_directories(BlocksRuntime PUBLIC set_target_properties(BlocksRuntime PROPERTIES POSITION_INDEPENDENT_CODE FALSE) -add_library(BlocksRuntime::BlocksRuntime ALIAS BlocksRuntime) - -if(NOT BUILD_SHARED_LIBS) - set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS BlocksRuntime) - install(TARGETS BlocksRuntime - ARCHIVE DESTINATION lib/swift$<$>:_static>/${SWIFT_SYSTEM_NAME} - LIBRARY DESTINATION lib/swift$<$>:_static>/${SWIFT_SYSTEM_NAME}) -endif() +set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS BlocksRuntime) diff --git a/Sources/CoreFoundation/CMakeLists.txt b/Sources/CoreFoundation/CMakeLists.txt index c73891b264..71e7c2f00d 100644 --- a/Sources/CoreFoundation/CMakeLists.txt +++ b/Sources/CoreFoundation/CMakeLists.txt @@ -121,6 +121,7 @@ target_link_libraries(CoreFoundation if(CMAKE_SYSTEM_NAME STREQUAL WASI) # On WASI, we use vendored BlocksRuntime instead of the one from libdispatch add_subdirectory(BlockRuntime) + # Add BlocksRuntime object library to CoreFoundation static archive target_link_libraries(CoreFoundation PRIVATE BlocksRuntime) endif() From 3b8485a75c5fd9a7f7877961ceadbc6521dcf563 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 8 Aug 2024 17:09:49 +0000 Subject: [PATCH 12/12] [CMake] Remove POSITION_INDEPENDENT_CODE=FALSE from BlocksRuntime We ported BlocksRuntime CMakeLists.txt from the state of 02b7d8f0c141b9accdade1922a080898d2d0e0a2 but we don't find any reason to set POSITION_INDEPENDENT_CODE=FALSE for BlocksRuntime. --- Sources/CoreFoundation/BlockRuntime/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/Sources/CoreFoundation/BlockRuntime/CMakeLists.txt b/Sources/CoreFoundation/BlockRuntime/CMakeLists.txt index fe5e13bb7c..47779784e7 100644 --- a/Sources/CoreFoundation/BlockRuntime/CMakeLists.txt +++ b/Sources/CoreFoundation/BlockRuntime/CMakeLists.txt @@ -26,7 +26,4 @@ target_include_directories(BlocksRuntime PUBLIC # For CFTargetConditionals.h ${CMAKE_CURRENT_SOURCE_DIR}/../include) -set_target_properties(BlocksRuntime PROPERTIES - POSITION_INDEPENDENT_CODE FALSE) - set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS BlocksRuntime)