Skip to content

Commit 85c5a6e

Browse files
karwakateinoigakukun
authored andcommitted
Remove fakeld (#26)
* Remove fakeld It isn't needed if we don't try to build dynamic libraries for WASM. * Don't build StdlibUnittestFoundationExtras when cross-compiling on Darwin * Build static SDK overlay on WASI
1 parent 03e9a10 commit 85c5a6e

File tree

6 files changed

+17
-21
lines changed

6 files changed

+17
-21
lines changed

CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -822,13 +822,9 @@ endif()
822822
# Should we cross-compile the standard library for WebAssembly (WASI)?
823823
is_sdk_requested(WASI swift_build_wasm)
824824
if(swift_build_wasm AND NOT "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "WASI")
825-
#if ("${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
826-
# message(FATAL_ERROR "You must set SWIFT_ANDROID_NDK_PATH to cross-compile the Swift runtime for Android")
827-
#endif()
828-
#if (NOT ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin" OR "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux"))
829-
# message(FATAL_ERROR "A Darwin or Linux host is required to build the Swift runtime for Android")
830-
#endif()
831-
825+
if(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY OR SWIFT_BUILD_DYNAMIC_STDLIB)
826+
message(FATAL_ERROR "Unable to build dynamic overlay/stdlib for WASI. WASM does not support dynamic linking.")
827+
endif()
832828
if("${SWIFT_SDK_WASI_ARCHITECTURES}" STREQUAL "")
833829
set(SWIFT_SDK_WASI_ARCHITECTURES wasm32)
834830
endif()

build-linux.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export sourcedir=$PWD/..
1212
-DCMAKE_RANLIB='$sourcedir/wasi-sdk/bin/llvm-ranlib' \
1313
" \
1414
--build-stdlib-deployment-targets "wasi-wasm32" \
15+
--build-swift-dynamic-sdk-overlay false \
16+
--build-swift-dynamic-stdlib false \
17+
--build-swift-static-sdk-overlay \
1518
--build-swift-static-stdlib \
1619
--install-destdir="$sourcedir/install" \
1720
--install-prefix="/opt/swiftwasm-sdk" \

build-mac.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export sourcedir=$PWD/..
1515
" \
1616
--build-stdlib-deployment-targets "wasi-wasm32" \
1717
--build-swift-dynamic-sdk-overlay false \
18-
--build-swift-static-sdk-overlay false \
18+
--build-swift-dynamic-stdlib false \
19+
--build-swift-static-sdk-overlay \
1920
--build-swift-static-stdlib \
2021
--llvm-targets-to-build "X86;WebAssembly" \
2122
--stdlib-deployment-targets "wasi-wasm32" \

cmake/modules/AddSwift.cmake

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,7 @@ function(_add_variant_link_flags)
531531
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
532532
# FIXME: On Apple platforms, find_program needs to look for "ld64.lld"
533533
find_program(LDLLD_PATH "ld.lld")
534-
if("${SWIFT_SDK_${LFLAGS_SDK}_OBJECT_FORMAT}" STREQUAL "WASM")
535-
list(APPEND result "-fuse-ld=${CMAKE_SOURCE_DIR}/fakeld")
536-
elseif((SWIFT_ENABLE_LLD_LINKER AND LDLLD_PATH AND NOT APPLE) OR
534+
if((SWIFT_ENABLE_LLD_LINKER AND LDLLD_PATH AND NOT APPLE) OR
537535
("${LFLAGS_SDK}" STREQUAL "WINDOWS" AND
538536
NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WINDOWS"))
539537
list(APPEND result "-fuse-ld=lld")
@@ -1320,6 +1318,12 @@ function(_add_swift_library_single target name)
13201318
list(APPEND c_compile_flags -D_WINDLL)
13211319
endif()
13221320
endif()
1321+
# Double-check that we're not trying to build a dynamic library for WASM.
1322+
if(SWIFTLIB_SINGLE_SDK MATCHES WASM)
1323+
if(libkind STREQUAL SHARED)
1324+
message(FATAL_ERROR "WASM does not support shared libraries.")
1325+
endif()
1326+
endif()
13231327
_add_variant_link_flags(
13241328
SDK "${SWIFTLIB_SINGLE_SDK}"
13251329
ARCH "${SWIFTLIB_SINGLE_ARCHITECTURE}"

fakeld

Lines changed: 0 additions & 9 deletions
This file was deleted.

stdlib/private/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ if(SWIFT_BUILD_SDK_OVERLAY)
1818

1919
add_subdirectory(OSLog)
2020

21-
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
21+
list_intersect("${SWIFT_APPLE_PLATFORMS}" "${SWIFT_SDKS}" building_darwin_sdks)
22+
if(building_darwin_sdks)
2223
add_subdirectory(StdlibUnittestFoundationExtras)
2324
if (SWIFT_INCLUDE_TESTS)
2425
add_subdirectory(SwiftReflectionTest)

0 commit comments

Comments
 (0)