Skip to content

Commit

Permalink
Remove fakeld (#26)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
karwa authored and kateinoigakukun committed Jan 24, 2020
1 parent 15029eb commit 4a76eaf
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
10 changes: 3 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -784,13 +784,9 @@ endif()
# Should we cross-compile the standard library for WebAssembly (WASI)?
is_sdk_requested(WASI swift_build_wasm)
if(swift_build_wasm AND NOT "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "WASI")
#if ("${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
# message(FATAL_ERROR "You must set SWIFT_ANDROID_NDK_PATH to cross-compile the Swift runtime for Android")
#endif()
#if (NOT ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin" OR "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux"))
# message(FATAL_ERROR "A Darwin or Linux host is required to build the Swift runtime for Android")
#endif()

if(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY OR SWIFT_BUILD_DYNAMIC_STDLIB)
message(FATAL_ERROR "Unable to build dynamic overlay/stdlib for WASI. WASM does not support dynamic linking.")
endif()
if("${SWIFT_SDK_WASI_ARCHITECTURES}" STREQUAL "")
set(SWIFT_SDK_WASI_ARCHITECTURES wasm32)
endif()
Expand Down
3 changes: 3 additions & 0 deletions build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export sourcedir=$PWD/..
-DCMAKE_RANLIB='$sourcedir/wasi-sdk/bin/llvm-ranlib' \
" \
--build-stdlib-deployment-targets "wasi-wasm32" \
--build-swift-dynamic-sdk-overlay false \
--build-swift-dynamic-stdlib false \
--build-swift-static-sdk-overlay \
--build-swift-static-stdlib \
--install-destdir="$sourcedir/install" \
--install-prefix="/opt/swiftwasm-sdk" \
Expand Down
3 changes: 2 additions & 1 deletion build-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export sourcedir=$PWD/..
" \
--build-stdlib-deployment-targets "wasi-wasm32" \
--build-swift-dynamic-sdk-overlay false \
--build-swift-static-sdk-overlay false \
--build-swift-dynamic-stdlib false \
--build-swift-static-sdk-overlay \
--build-swift-static-stdlib \
--llvm-targets-to-build "X86;WebAssembly" \
--stdlib-deployment-targets "wasi-wasm32" \
Expand Down
10 changes: 7 additions & 3 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,7 @@ function(_add_variant_link_flags)
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
# FIXME: On Apple platforms, find_program needs to look for "ld64.lld"
find_program(LDLLD_PATH "ld.lld")
if("${SWIFT_SDK_${LFLAGS_SDK}_OBJECT_FORMAT}" STREQUAL "WASM")
list(APPEND result "-fuse-ld=${CMAKE_SOURCE_DIR}/fakeld")
elseif((SWIFT_ENABLE_LLD_LINKER AND LDLLD_PATH AND NOT APPLE) OR
if((SWIFT_ENABLE_LLD_LINKER AND LDLLD_PATH AND NOT APPLE) OR
("${LFLAGS_SDK}" STREQUAL "WINDOWS" AND
NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WINDOWS"))
list(APPEND result "-fuse-ld=lld")
Expand Down Expand Up @@ -1404,6 +1402,12 @@ function(_add_swift_library_single target name)
list(APPEND c_compile_flags -D_WINDLL)
endif()
endif()
# Double-check that we're not trying to build a dynamic library for WASM.
if(SWIFTLIB_SINGLE_SDK MATCHES WASM)
if(libkind STREQUAL SHARED)
message(FATAL_ERROR "WASM does not support shared libraries.")
endif()
endif()
_add_variant_link_flags(
SDK "${SWIFTLIB_SINGLE_SDK}"
ARCH "${SWIFTLIB_SINGLE_ARCHITECTURE}"
Expand Down
9 changes: 0 additions & 9 deletions fakeld

This file was deleted.

3 changes: 2 additions & 1 deletion stdlib/private/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ if(SWIFT_BUILD_SDK_OVERLAY)

add_subdirectory(OSLog)

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
list_intersect("${SWIFT_APPLE_PLATFORMS}" "${SWIFT_SDKS}" building_darwin_sdks)
if(building_darwin_sdks)
add_subdirectory(StdlibUnittestFoundationExtras)
if (SWIFT_INCLUDE_TESTS)
add_subdirectory(SwiftReflectionTest)
Expand Down

0 comments on commit 4a76eaf

Please sign in to comment.