Skip to content

Commit af61a0e

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 4ad17cf commit af61a0e

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
@@ -784,13 +784,9 @@ endif()
784784
# Should we cross-compile the standard library for WebAssembly (WASI)?
785785
is_sdk_requested(WASI swift_build_wasm)
786786
if(swift_build_wasm AND NOT "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "WASI")
787-
#if ("${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
788-
# message(FATAL_ERROR "You must set SWIFT_ANDROID_NDK_PATH to cross-compile the Swift runtime for Android")
789-
#endif()
790-
#if (NOT ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin" OR "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux"))
791-
# message(FATAL_ERROR "A Darwin or Linux host is required to build the Swift runtime for Android")
792-
#endif()
793-
787+
if(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY OR SWIFT_BUILD_DYNAMIC_STDLIB)
788+
message(FATAL_ERROR "Unable to build dynamic overlay/stdlib for WASI. WASM does not support dynamic linking.")
789+
endif()
794790
if("${SWIFT_SDK_WASI_ARCHITECTURES}" STREQUAL "")
795791
set(SWIFT_SDK_WASI_ARCHITECTURES wasm32)
796792
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
@@ -582,9 +582,7 @@ function(_add_variant_link_flags)
582582
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
583583
# FIXME: On Apple platforms, find_program needs to look for "ld64.lld"
584584
find_program(LDLLD_PATH "ld.lld")
585-
if("${SWIFT_SDK_${LFLAGS_SDK}_OBJECT_FORMAT}" STREQUAL "WASM")
586-
list(APPEND result "-fuse-ld=${CMAKE_SOURCE_DIR}/fakeld")
587-
elseif((SWIFT_ENABLE_LLD_LINKER AND LDLLD_PATH AND NOT APPLE) OR
585+
if((SWIFT_ENABLE_LLD_LINKER AND LDLLD_PATH AND NOT APPLE) OR
588586
("${LFLAGS_SDK}" STREQUAL "WINDOWS" AND
589587
NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WINDOWS"))
590588
list(APPEND result "-fuse-ld=lld")
@@ -1404,6 +1402,12 @@ function(_add_swift_library_single target name)
14041402
list(APPEND c_compile_flags -D_WINDLL)
14051403
endif()
14061404
endif()
1405+
# Double-check that we're not trying to build a dynamic library for WASM.
1406+
if(SWIFTLIB_SINGLE_SDK MATCHES WASM)
1407+
if(libkind STREQUAL SHARED)
1408+
message(FATAL_ERROR "WASM does not support shared libraries.")
1409+
endif()
1410+
endif()
14071411
_add_variant_link_flags(
14081412
SDK "${SWIFTLIB_SINGLE_SDK}"
14091413
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)