Skip to content

Commit 706af64

Browse files
committed
Fix target triple on macOS
With the release of Xcode 15, a new linker was introduced and with it came warnings from the linker on macOS specifically. It appears that the new linker is stricter in which target triples it considers valid. Specifically, it looks like the minimum deployment target is required. E.g., `aarch64-apple-darwin23.3.0` is valid, while `aarch64-apple-darwin` is not. See also: * https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking * crystal-lang/crystal#13846
1 parent 5aeefaf commit 706af64

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

omnibus/config/software/crystal.rb

+3-5
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,12 @@
6868
mkdir ".build"
6969
copy "#{output_bin}_x86_64", ".build/crystal"
7070

71-
# Compile for ARM64. Apple's clang only understands arm64, LLVM uses aarch64,
72-
# so we need to sub out aarch64 in our calls to Apple tools
73-
env["CXXFLAGS"] << " -target arm64-apple-darwin"
7471
make "deps", env: env
7572

76-
make "crystal stats=true release=true target=aarch64-apple-darwin FLAGS=\"#{crflags}\" CRYSTAL_CONFIG_TARGET=aarch64-apple-darwin CRYSTAL_CONFIG_LIBRARY_PATH= O=#{output_path}", env: env
73+
crtarget = "arm64-apple-macosx#{ENV["MACOSX_DEPLOYMENT_TARGET"]}"
74+
make "crystal stats=true release=true target=#{crtarget} FLAGS=\"#{crflags}\" CRYSTAL_CONFIG_TARGET=#{crtarget} CRYSTAL_CONFIG_LIBRARY_PATH= O=#{output_path}", env: env
7775

78-
command "clang #{output_path}/crystal.o -o #{output_bin}_arm64 -target arm64-apple-darwin src/llvm/ext/llvm_ext.o `llvm-config --libs --system-libs --ldflags 2>/dev/null` -lstdc++ -lpcre2-8 -lgc -lpthread -levent -liconv -ldl -v", env: env
76+
command "clang #{output_path}/crystal.o -o #{output_bin}_arm64 -target #{crtarget} src/llvm/ext/llvm_ext.o `llvm-config --libs --system-libs --ldflags 2>/dev/null` -lstdc++ -lpcre2-8 -lgc -lpthread -levent -liconv -ldl -v", env: env
7977
delete "#{output_path}/crystal.o"
8078

8179
# Lipo them up

omnibus/config/software/shards.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@
9696
make "clean", env: env
9797

9898
# Build for ARM64
99-
crflags += " --cross-compile --target aarch64-apple-darwin"
99+
crtarget = "arm64-apple-macosx#{ENV["MACOSX_DEPLOYMENT_TARGET"]}"
100+
crflags += " --cross-compile --target #{crtarget}"
100101
make "bin/shards SHARDS=false CRYSTAL=#{install_dir}/bin/crystal FLAGS='#{crflags}'", env: env
101-
command "clang bin/shards.o -o bin/shards_arm64 -target arm64-apple-darwin -L#{install_dir}/embedded/lib -lyaml -lpcre2-8 -lgc -lpthread -levent -liconv -ldl", env: env
102+
command "clang bin/shards.o -o bin/shards_arm64 -target #{crtarget} -L#{install_dir}/embedded/lib -lyaml -lpcre2-8 -lgc -lpthread -levent -liconv -ldl", env: env
102103

103104
# Lipo them up
104105
command "lipo -create -output bin/shards bin/shards_x86_64 bin/shards_arm64"

0 commit comments

Comments
 (0)