Building Swift fails on M1 MBA

Is building the Swift compiler on Apple Silicon Macs supported yet?

I'm currently seeing a failure in clang-rt attempting to build with an M1 MacBook Air:

[371/1854][ 20%][11.945s] Building C object lib/tsan/CMakeFiles/clang_rt.tsan_osx_dynamic.dir/rtl/tsan_rtl_aarch64.S.o
FAILED: lib/tsan/CMakeFiles/clang_rt.tsan_osx_dynamic.dir/rtl/tsan_rtl_aarch64.S.o 
/Users/toon/GitHub/build/Ninja-ReleaseAssert/llvm-macosx-arm64/./bin/clang -Dclang_rt_tsan_osx_dynamic_EXPORTS -I/Users/toon/GitHub/llvm-project/compiler-rt/lib/tsan/.. -x c  -Wall -Wno-unused-parameter -O3 -DNDEBUG -arch arm64 -isysroot /Applications/ -fPIC  -stdlib=libc++ -mmacosx-version-min=10.9 -isysroot /Applications/ -fno-lto -fPIC -fno-builtin -fno-exceptions -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fPIE -fno-rtti -Wframe-larger-than=530 -Wglobal-constructors --sysroot=. -MD -MT lib/tsan/CMakeFiles/clang_rt.tsan_osx_dynamic.dir/rtl/tsan_rtl_aarch64.S.o -MF lib/tsan/CMakeFiles/clang_rt.tsan_osx_dynamic.dir/rtl/tsan_rtl_aarch64.S.o.d -o lib/tsan/CMakeFiles/clang_rt.tsan_osx_dynamic.dir/rtl/tsan_rtl_aarch64.S.o -c /Users/toon/GitHub/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S
/Users/toon/GitHub/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S:7:1: error: expected identifier or '('
.align  2
1 error generated.
[380/1854][ 20%][13.385s] Building CXX object lib/tsan/CMakeFiles/clang_rt.tsan_osx_dynamic.dir/rtl/tsan_interceptors_posix.cpp.o
ninja: build stopped: subcommand failed.
[3808/3859][ 98%][2001.846s] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/index/Background.cpp.o
FAILED: tools/clang/runtime/compiler-rt-stamps/compiler-rt-build 

Any guidance - even just a "wait, that isn't supported publicly yet" would be helpful. Thanks!

It looks like there was a bug in some cmake workaround goop. Does this PR help?

1 Like

Thanks for the pointer! Yep, that gets me past libunwind, at least.


Looks like the next issue is some architecture confusion. It's trying to lipo together macosx/x86_64/libswiftCompatibility50.a (which contains x86_64 and arm64) +
macosx/arm64/libswiftCompatibility50.a (which contains arm64) +
macosx/arm64e/libswiftCompatibility50.a (which contains arm64 and arm64e).

... and erroring because this would be multiple arm64 segments in the resulting fat library. For my own sanity I really try to avoid build system debugging, so I'll leave it for now for someone else to figure out. :slight_smile:


arm64e isn't supported for third-party code anyway, currently, so you could try just disabling building the arm64e slice.

Terms of Service

Privacy Policy

Cookie Policy