Skip to content
This repository has been archived by the owner on Aug 14, 2022. It is now read-only.

Commit

Permalink
#110 M1 chip fixes
Browse files Browse the repository at this point in the history
commit 674ef01
Author: Vlad Gorlov <[email protected]>
Date:   Fri Sep 17 15:57:09 2021 +0200

    #110 M1 chip fixes.

commit 0364e27
Author: Vlad Gorlov <[email protected]>
Date:   Fri Sep 17 14:40:32 2021 +0200

    #110 M1 chip fixes.

commit 2bef968
Author: Vlad Gorlov <[email protected]>
Date:   Fri Sep 17 09:54:37 2021 +0200

    #110 M1 chip fixes.
  • Loading branch information
vgorloff committed Sep 17, 2021
1 parent 978e989 commit 9677a31
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Automation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
36 changes: 36 additions & 0 deletions Patches/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake.diff
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 7 additions & 7 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.71
1.0.72
9 changes: 7 additions & 2 deletions lib/Builders/LLBBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -35,20 +36,24 @@ 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
-G Ninja
-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
Expand Down
4 changes: 4 additions & 0 deletions lib/Builders/SwiftBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
Expand Down

0 comments on commit 9677a31

Please sign in to comment.