diff --git a/Automation.js b/Automation.js index 93372ba..915eabf 100644 --- a/Automation.js +++ b/Automation.js @@ -96,6 +96,8 @@ module.exports = class Automation extends Tool { this.install() } else if (action == "assets") { this.assets() + } else if (action == "stage2") { + this.stage2() } else if (action == "stage3") { this.stage3() } else { diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e17544..7663388 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.72] - 2021-09-17 +* #110 Fixes build issues on Apple M1 Silicon. + ## [1.0.71] - 2021-07-11 * #124 Updated to use Swift 5.4.2 diff --git a/Patches/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake.diff b/Patches/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake.diff new file mode 100644 index 0000000..dc93bc5 --- /dev/null +++ b/Patches/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake.diff @@ -0,0 +1,36 @@ +diff --git a/stdlib/cmake/modules/AddSwiftStdlib.cmake b/stdlib/cmake/modules/AddSwiftStdlib.cmake +index 38191b01a64d67222b1ffbd8617ea0a96594e7aa..fb5afce4814afd49bf2d257ecdd5e4cd299326f9 100644 +--- a/stdlib/cmake/modules/AddSwiftStdlib.cmake ++++ b/stdlib/cmake/modules/AddSwiftStdlib.cmake +@@ -2046,6 +2046,16 @@ function(add_swift_target_library name) + list(APPEND THIN_INPUT_TARGETS ${VARIANT_NAME}) + endif() + endif() ++ ++ if(sdk IN_LIST SWIFT_APPLE_PLATFORMS) ++ # See: https://github.com/apple/swift/pull/38415/files ++ # In the past, we relied on unsetting globally ++ # CMAKE_OSX_ARCHITECTURES to ensure that CMake would ++ # not add the -arch flag ++ # This is no longer the case when running on Apple Silicon, ++ # when CMake will enforce a default (see https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5291) ++ set_property(TARGET ${VARIANT_NAME} PROPERTY OSX_ARCHITECTURES "${arch}") ++ endif() + endforeach() + + # Configure module-only targets +@@ -2483,6 +2493,14 @@ function(add_swift_target_executable name) + endif() + + if(${sdk} IN_LIST SWIFT_APPLE_PLATFORMS) ++ # See: https://github.com/apple/swift/pull/38415/files ++ # In the past, we relied on unsetting globally ++ # CMAKE_OSX_ARCHITECTURES to ensure that CMake would ++ # not add the -arch flag ++ # This is no longer the case when running on Apple Silicon, ++ # when CMake will enforce a default (see https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5291) ++ set_property(TARGET ${VARIANT_NAME} PROPERTY OSX_ARCHITECTURES "${arch}") ++ + add_custom_command_target(unused_var2 + COMMAND "codesign" "-f" "-s" "-" "${SWIFT_RUNTIME_OUTPUT_INTDIR}/${VARIANT_NAME}" + CUSTOM_TARGET_NAME "${VARIANT_NAME}_signed" diff --git a/Readme.md b/Readme.md index 005393a..95575c7 100644 --- a/Readme.md +++ b/Readme.md @@ -2,15 +2,15 @@ ## Requirements -- macOS 11.3 -- Xcode 12.5 -- Android Studio 4.1.3 -- Android NDK 21.4.7075529 -- Node 14.16.1 (node -v). Newer versions may also work, but not tested. -- CMake 3.20.2 (cmake --version) +- macOS 11.5.2 +- Xcode 12.5.1 +- Android Studio 2020.3.1 +- Android NDK (See version number in file `NDK_VERSION` in the root of this repository) +- Node 14.17.3 (node -v). Newer versions may also work, but not tested. +- CMake 3.21.2 (cmake --version) - Ninja 1.10.2 (ninja --version) - autoconf 2.71 (autoconf --version) -- aclocal 1.16.3 (aclocal --version) +- aclocal 1.16.4 (aclocal --version) - glibtool 2.4.6 (glibtool --version) - pkg-config 0.29.2 (pkg-config --version) diff --git a/VERSION b/VERSION index 1edd062..eea6f62 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.71 +1.0.72 diff --git a/lib/Builders/LLBBuilder.js b/lib/Builders/LLBBuilder.js index ce91447..ece8f99 100644 --- a/lib/Builders/LLBBuilder.js +++ b/lib/Builders/LLBBuilder.js @@ -26,6 +26,7 @@ const Builder = require("../Builder"); const Component = require("../Components"); const Archs = require("../Archs"); const SwiftBuilder = require("./SwiftBuilder"); +const os = require('os'); module.exports = class LLBBuilder extends Builder { constructor() { @@ -35,6 +36,10 @@ module.exports = class LLBBuilder extends Builder { // See: ToolChain/Sources/spm/Utilities/build-using-cmake executeConfigure() { const swift = new SwiftBuilder(); + let hostArch = "x86_64" + if (os.arch().includes("arm")) { + hostArch = "arm64" + } var cmd = ` cd ${this.paths.builds} && cmake @@ -42,13 +47,13 @@ module.exports = class LLBBuilder extends Builder { -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/ - -D CMAKE_Swift_FLAGS="-Xlinker -v -Xfrontend -target -Xfrontend x86_64-apple-macos10.10 -target x86_64-apple-macos10.10 -v" + -D CMAKE_Swift_FLAGS="-Xlinker -v -Xfrontend -target -Xfrontend ${hostArch}-apple-macos10.10 -target ${hostArch}-apple-macos10.10 -v" // -D CMAKE_Swift_FLAGS="-Xfrontend -target-cpu -Xfrontend x86-64 -target-cpu x86-64 -Xlinker -v -Xlinker -arch -Xlinker x86_64 -Xfrontend -target -Xfrontend x86_64-apple-macos10.10 -target x86_64-apple-macos10.10 -sdk ${this.paths.xcMacOsSdkPath} -v" // See: https://github.com/apple/swift-driver#building-with-cmake -D LLBUILD_SUPPORT_BINDINGS=Swift - -D CMAKE_OSX_ARCHITECTURES=x86_64 + -D CMAKE_OSX_ARCHITECTURES=${hostArch} // Otherwise it fails to link one of dylib. -D BUILD_SHARED_LIBS=false diff --git a/lib/Builders/SwiftBuilder.js b/lib/Builders/SwiftBuilder.js index 36bcadb..5cdbfcc 100644 --- a/lib/Builders/SwiftBuilder.js +++ b/lib/Builders/SwiftBuilder.js @@ -162,6 +162,10 @@ module.exports = class SwiftBuilder extends Builder { this.executeCommands(cmd); } + configurePatches(/** @type {Boolean} */ shouldEnable) { + this.configurePatch(`${this.paths.patches}/stdlib/cmake/modules/AddSwiftStdlib.cmake.diff`, shouldEnable) + } + executeBuild() { this.execute(`cd ${this.paths.builds} && ninja -j${this.numberOfJobs}`); }