Skip to content

Commit c28ea44

Browse files
MaxDesiatovshahmishal
authored andcommitted
CMake: fix builds for Apple Silicon hosts
(cherry picked from commit 0b86753)
1 parent d833812 commit c28ea44

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ elseif("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)")
772772
#
773773
# Primary variant is always OSX; even on iOS hosts.
774774
set(SWIFT_PRIMARY_VARIANT_SDK_default "OSX")
775-
set(SWIFT_PRIMARY_VARIANT_ARCH_default "x86_64")
775+
set(SWIFT_PRIMARY_VARIANT_ARCH_default "${CMAKE_HOST_SYSTEM_PROCESSOR}")
776776

777777
endif()
778778

docs/HowToGuides/GettingStarted.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,13 @@ Phew, that's a lot to digest! Now let's proceed to the actual build itself!
245245
- Via Ninja:
246246
```sh
247247
utils/build-script --skip-build-benchmarks \
248-
--skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "x86_64" \
248+
--skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \
249249
--sccache --release-debuginfo --test
250250
```
251251
- Via Xcode:
252252
```sh
253253
utils/build-script --skip-build-benchmarks \
254-
--skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "x86_64" \
254+
--skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \
255255
--sccache --release-debuginfo --test \
256256
--xcode
257257
```
@@ -350,7 +350,8 @@ git push --set-upstream my-remote my-branch
350350
### First time Xcode setup
351351
352352
If you used `--xcode` earlier, you will see an Xcode project generated under
353-
`../build/Xcode-RelWithDebInfoAssert/swift-macosx-x86_64`. When you open the
353+
`../build/Xcode-RelWithDebInfoAssert/swift-macosx-x86_64` (or
354+
`../build/Xcode-RelWithDebInfoAssert/swift-macosx-arm64` on Apple Silicon Macs). When you open the
354355
project, Xcode might helpfully suggest "Automatically Create Schemes". Most of
355356
those schemes are not required in day-to-day work, so you can instead manually
356357
select the following schemes:
@@ -375,12 +376,12 @@ Now that you have made some changes, you will need to rebuild...
375376
376377
To rebuild the compiler:
377378
```sh
378-
ninja -C ../build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64 swift-frontend
379+
ninja -C ../build/Ninja-RelWithDebInfoAssert/swift-macosx-$(uname -m) swift-frontend
379380
```
380381
381382
To rebuild everything, including the standard library:
382383
```sh
383-
ninja -C ../build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64
384+
ninja -C ../build/Ninja-RelWithDebInfoAssert/swift-macosx-$(uname -m)
384385
```
385386
386387
### Incremental builds with Xcode
@@ -396,7 +397,7 @@ build should be much faster than the from-scratch build at the beginning.
396397
Now check if the version string has been updated:
397398
398399
```sh
399-
../build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/bin/swift-frontend --version
400+
../build/Ninja-RelWithDebInfoAssert/swift-macosx-$(uname -m)/bin/swift-frontend --version
400401
```
401402
402403
This should print your updated version string.
@@ -439,22 +440,22 @@ There are two main ways to run tests:
439440
```sh
440441
# Rebuild all test dependencies and run all tests under test/.
441442
utils/run-test --lit ../llvm-project/llvm/utils/lit/lit.py \
442-
../build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/test-macosx-x86_64
443+
../build/Ninja-RelWithDebInfoAssert/swift-macosx-$(uname -m)/test-macosx-$(uname -m)
443444
444445
# Rebuild all test dependencies and run tests containing "MyTest".
445446
utils/run-test --lit ../llvm-project/llvm/utils/lit/lit.py \
446-
../build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/test-macosx-x86_64 \
447+
../build/Ninja-RelWithDebInfoAssert/swift-macosx-$(uname -m)/test-macosx-$(uname -m) \
447448
--filter="MyTest"
448449
```
449450
2. `lit.py`: lit doesn't know anything about dependencies. It just runs tests.
450451
```sh
451452
# Run all tests under test/.
452453
../llvm-project/llvm/utils/lit/lit.py -s -vv \
453-
../build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/test-macosx-x86_64
454+
../build/Ninja-RelWithDebInfoAssert/swift-macosx-$(uname -m)/test-macosx-$(uname -m)
454455
455456
# Run tests containing "MyTest"
456457
../llvm-project/llvm/utils/lit/lit.py -s -vv \
457-
../build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/test-macosx-x86_64 \
458+
../build/Ninja-RelWithDebInfoAssert/swift-macosx-$(uname -m)/test-macosx-$(uname -m) \
458459
--filter="MyTest"
459460
```
460461
The `-s` and `-vv` flags print a progress bar and the executed commands

0 commit comments

Comments
 (0)