Skip to content

Commit afb4f9a

Browse files
committed
Explicitly specify target for Darwin Intel build
By default uses the target of the system where the script is executed. If run darwin build on MacOS M1 laptop, it generates 2 arm binaries. And command `lito` returns error that both files have same arch. Reproduction of the problem: ``` $ llvm-config --host-target arm64-apple-darwin23.0.0 $ make crystal stats=true release=true Using /usr/local/bin/llvm-config [version= 15.0.7] CRYSTAL_CONFIG_BUILD_COMMIT="1f592eca6" CRYSTAL_CONFIG_PATH='$ORIGIN/../share/crystal/src' SOURCE_DATE_EPOCH="1699639716" CRYSTAL_CONFIG_LIBRARY_PATH= ./bin/crystal build --no-debug -D strict_multi_assign .... $ file .../crystal/embedded/bin/crystal .../crystal/embedded/bin/crystal: Mach-O 64-bit executable arm64 ```
1 parent 9d6e645 commit afb4f9a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

omnibus/config/software/crystal.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@
5858
copy "#{Dir.pwd}/crystal-#{ohai['os']}-#{ohai['kernel']['machine']}/embedded/bin/crystal", ".build/crystal"
5959

6060
# Compile for Intel
61-
command "make crystal stats=true release=true FLAGS=\"#{crflags}\" CRYSTAL_CONFIG_LIBRARY_PATH= O=#{output_path}", env: env
61+
command "make crystal stats=true release=true target=x86_64-apple-darwin FLAGS=\"#{crflags}\" CRYSTAL_CONFIG_LIBRARY_PATH= O=#{output_path}", env: env
6262
move output_bin, "#{output_bin}_x86_64"
63+
block { raise "Could not build crystal x86_64" unless File.exist?("#{output_bin}_x86_64") }
6364

6465
# Clean up
6566
make "clean_cache clean", env: env
@@ -77,6 +78,7 @@
7778

7879
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
7980
delete "#{output_path}/crystal.o"
81+
block { raise "Could not build crystal arm64" unless File.exist?("#{output_bin}_arm64") }
8082

8183
# Lipo them up
8284
command "lipo -create -output #{output_bin} #{output_bin}_x86_64 #{output_bin}_arm64"

0 commit comments

Comments
 (0)