Skip to content

Commit

Permalink
Merge 00801dd into dc6fe4f
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun authored Oct 15, 2019
2 parents dc6fe4f + 00801dd commit c41bc18
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 34 deletions.
15 changes: 5 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ ENABLE_LANGUAGE(C)
include(SwiftUtils)
include(CheckSymbolExists)

# WebAssembly: hack: use llvm-ar for creating static libraries; Ubuntu's GNU ar doesn't work with wasm-ld
set(CMAKE_AR "${SWIFT_WASM_WASI_SDK_PATH}/bin/llvm-ar")

#
# User-configurable options that control the inclusion and default build
# behavior for components which may not strictly be necessary (tools, examples,
Expand Down Expand Up @@ -660,13 +657,6 @@ endif()
# Configure SDKs.
#

if(XCODE)
# FIXME: Cannot cross-compile the standard library using Xcode. Xcode
# insists on passing -mmacosx-version-min to the compiler, and we need
# to pass -mios-version-min. Clang sees both options and complains.
set(SWIFT_SDKS "OSX")
endif()

# FIXME: the parameters we specify in SWIFT_SDKS are lacking architecture specifics,
# so we need to hard-code it. For example, the SDK for Android is just 'ANDROID',
# which we assume below to be armv7.
Expand Down Expand Up @@ -814,6 +804,11 @@ if(swift_build_wasm AND NOT "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "WASM")
# message(FATAL_ERROR "A Darwin or Linux host is required to build the Swift runtime for Android")
#endif()

if (NOT ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin"))
# WebAssembly: hack: use llvm-ar for creating static libraries; Ubuntu's GNU ar doesn't work with wasm-ld
set(CMAKE_AR "${SWIFT_WASM_WASI_SDK_PATH}/bin/llvm-ar")
endif()

if("${SWIFT_SDK_WASM_ARCHITECTURES}" STREQUAL "")
set(SWIFT_SDK_WASM_ARCHITECTURES wasm32)
endif()
Expand Down
111 changes: 94 additions & 17 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ jobs:
sourcedir="$PWD"
cd swift
utils/update-checkout --clone --scheme wasm
git checkout $BUILD_SOURCEBRANCHNAME || git checkout $SYSTEM_PULLREQUEST_SOURCEBRANCH
utils/build-script --release --wasm \
--llvm-targets-to-build "X86;WebAssembly" \
--build-swift-dynamic-sdk-overlay false \
--build-swift-static-sdk-overlay false \
--wasm-wasi-sdk "/opt/wasi-sdk" \
--wasm-icu-uc "todo" \
--wasm-icu-uc-include "$sourcedir/icu_out/include" \
Expand All @@ -61,16 +64,9 @@ jobs:
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: swiftwasm-sdk
- task: GitHubRelease@0
inputs:
gitHubConnection: swiftwasm-release
tagSource: manual
tag: $(Build.BuildNumber)
assets: |
$(Build.ArtifactStagingDirectory)/*
artifactName: swiftwasm-sdk-linux

- job: macOS
- job: macOS_Ninja
timeoutInMinutes: 0
pool:
vmImage: 'macOS-10.14'
Expand All @@ -92,8 +88,13 @@ jobs:
- checkout: self
path: swift-source/swift
- script: |
wget -O wasisdk.deb "https://github.com/swiftwasm/wasi-sdk/releases/download/20190421.6/wasi-sdk_3.19gefb17cb478f9.m_amd64.deb"
sudo dpkg -i wasisdk.deb
wget -O wasi-sdk.tar.gz https://github.com/swiftwasm/wasi-sdk/releases/download/20190421.6/wasi-sdk-3.19gefb17cb478f9.m-linux.tar.gz
tar xfz wasi-sdk.tar.gz
mv wasi-sdk-3.19gefb17cb478f9+m/opt/wasi-sdk ./wasi-sdk
# Link sysroot/usr/include to sysroot/include because Darwin sysroot doesn't
# find header files in sysroot/include but sysroot/usr/include
mkdir wasi-sdk/share/sysroot/usr/
ln -s ../include wasi-sdk/share/sysroot/usr/include
wget -O icu.tar.xz "https://github.com/swiftwasm/icu4c-wasi/releases/download/20190421.3/icu4c-wasi.tar.xz"
tar xf icu.tar.xz
workingDirectory: $(Pipeline.Workspace)/swift-source
Expand All @@ -102,11 +103,78 @@ jobs:
sourcedir="$PWD"
cd swift
utils/update-checkout --clone --scheme wasm
git checkout $BUILD_SOURCEBRANCHNAME || git checkout $SYSTEM_PULLREQUEST_SOURCEBRANCH
utils/build-script --release --wasm \
--verbose \
--skip-build-benchmarks \
--build-swift-dynamic-sdk-overlay false \
--build-swift-static-sdk-overlay false \
--llvm-targets-to-build "X86;WebAssembly" \
--stdlib-deployment-targets "macosx-x86_64" \
--extra-cmake-options="-DSWIFT_WASM_WASI_SDK_PATH=/usr/local/opt/llvm" \
--wasm-wasi-sdk "/opt/wasi-sdk" \
--wasm-wasi-sdk "$sourcedir/wasi-sdk" \
--wasm-icu-uc "todo" \
--wasm-icu-uc-include "$sourcedir/icu_out/include" \
--wasm-icu-i18n "todo" \
--wasm-icu-i18n-include "todo" \
--wasm-icu-data "todo" \
--build-swift-static-stdlib \
--install-swift \
--install-prefix="/opt/swiftwasm-sdk" \
--install-destdir="$sourcedir/install" \
--installable-package="$sourcedir/swiftwasm-mac.tar.gz"
cp "$sourcedir/swiftwasm-mac.tar.gz" "$BUILD_ARTIFACTSTAGINGDIRECTORY/"
displayName: Build swiftc
timeoutInMinutes: 0
workingDirectory: $(Pipeline.Workspace)/swift-source
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: swiftwasm-sdk-macos
- job: macOS_Xcode
timeoutInMinutes: 0
pool:
vmImage: 'macOS-10.14'
steps:
- script: |
brew install ninja
displayName: Install dependencies via apt-get
- script: |
wget -O cmake-3.15.3-Darwin-x86_64.tar.gz "https://github.com/Kitware/CMake/releases/download/v3.15.3/cmake-3.15.3-Linux-x86_64.s://github.com/Kitware/CMake/releases/download/v3.15.3/cmake-3.15.3-Darwin-x86_64.tar.gz"
tar xfvz cmake-3.15.3-Darwin-x86_64.tar.gz
sudo ln -sf ./cmake-3.15.3-Darwin-x86_64/CMake.app/Contents/bin/* /usr/local/bin
cmake --version
displayName: Install CMake v3.15.3
- script: |
mkdir -p swift-source/swift
displayName: Create swift-source workspace
workingDirectory: $(Pipeline.Workspace)
- checkout: self
path: swift-source/swift
- script: |
wget -O wasi-sdk.tar.gz https://github.com/swiftwasm/wasi-sdk/releases/download/20190421.6/wasi-sdk-3.19gefb17cb478f9.m-linux.tar.gz
tar xfz wasi-sdk.tar.gz
mv wasi-sdk-3.19gefb17cb478f9+m/opt/wasi-sdk ./wasi-sdk
# Link sysroot/usr/include to sysroot/include because Darwin sysroot doesn't
# find header files in sysroot/include but sysroot/usr/include
mkdir wasi-sdk/share/sysroot/usr/
ln -s ../include wasi-sdk/share/sysroot/usr/include
wget -O icu.tar.xz "https://github.com/swiftwasm/icu4c-wasi/releases/download/20190421.3/icu4c-wasi.tar.xz"
tar xf icu.tar.xz
workingDirectory: $(Pipeline.Workspace)/swift-source
displayName: Install wasi-sdk and icu4c-wasi
- script: |
sourcedir="$PWD"
cd swift
utils/update-checkout --clone --scheme wasm
git checkout $BUILD_SOURCEBRANCHNAME || git checkout $SYSTEM_PULLREQUEST_SOURCEBRANCH
utils/build-script --release --wasm --xcode \
--verbose \
--skip-build-benchmarks \
--build-swift-dynamic-sdk-overlay false \
--build-swift-static-sdk-overlay false \
--llvm-targets-to-build "X86;WebAssembly" \
--wasm-wasi-sdk "$sourcedir/wasi-sdk" \
--wasm-icu-uc "todo" \
--wasm-icu-uc-include "$sourcedir/icu_out/include" \
--wasm-icu-i18n "todo" \
Expand All @@ -125,11 +193,20 @@ jobs:
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: swiftwasm-sdk
artifactName: swiftwasm-sdk-macos
- job: UploadArtifacts
dependsOn:
- Ubuntu
- macOS_Ninja
steps:
- task: DownloadBuildArtifacts@0
inputs:
downloadType: 'specific'
itemPattern: '**'
downloadPath: $(Build.ArtifactStagingDirectory)
- task: GitHubRelease@0
inputs:
gitHubConnection: swiftwasm-release
tagSource: manual
tag: $(Build.BuildNumber)
assets: |
$(Build.ArtifactStagingDirectory)/*
assets: $(Build.ArtifactStagingDirectory)/*/*
2 changes: 1 addition & 1 deletion cmake/modules/FindICU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ foreach(MODULE ${ICU_FIND_COMPONENTS})
HINTS ${PC_ICU_${MODULE}_LIBRARY_DIRS})
endforeach()

foreach(sdk ANDROID;FREEBSD;LINUX;WINDOWS;HAIKU)
foreach(sdk ANDROID;FREEBSD;LINUX;WINDOWS;HAIKU;WASM)
foreach(MODULE ${ICU_FIND_COMPONENTS})
string(TOUPPER "${MODULE}" MODULE)
if("${SWIFT_${sdk}_${SWIFT_HOST_VARIANT_ARCH}_ICU_${MODULE}_INCLUDE}" STREQUAL "")
Expand Down
2 changes: 1 addition & 1 deletion fakeld
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
import sys
def outputname():
for i in range(len(sys.argv)):
Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if(SWIFT_BUILD_STATIC_STDLIB)
set(ICU_STATICLIB "TRUE")
else()
set(ICU_STATICLIB "FALSE")
find_package(ICU REQUIRED COMPONENTS uc i18n)
#find_package(ICU REQUIRED COMPONENTS uc i18n)
get_filename_component(ICU_UC_LIBDIR "${ICU_UC_LIBRARIES}" DIRECTORY)
get_filename_component(ICU_I18N_LIBDIR "${ICU_I18N_LIBRARIES}" DIRECTORY)
endif()
Expand Down
4 changes: 4 additions & 0 deletions stdlib/public/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ add_swift_target_library(swiftImageRegistrationObjectCOFF
TARGET_SDKS ${COFF_SDKS}
INSTALL_IN_COMPONENT none)

if(WASM IN_LIST SWIFT_CONFIGURED_SDKS)
set(CMAKE_OSX_SYSROOT "${SWIFT_WASM_WASI_SDK_PATH}")
endif()

foreach(sdk ${SWIFT_CONFIGURED_SDKS})
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}")
Expand Down
4 changes: 0 additions & 4 deletions utils/swift_build_support/swift_build_support/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,6 @@ def host_target():
if machine == 'x86_64':
return StdlibDeploymentTarget.Haiku.x86_64

elif system == 'Wasm':
if machine == 'wasm32':
return StdlibDeploymentTarget.Wasm.wasm32

raise NotImplementedError('System "%s" with architecture "%s" is not '
'supported' % (system, machine))

Expand Down

0 comments on commit c41bc18

Please sign in to comment.