From 74771e29d05f6ceea161a61030b721e4a054d7fc Mon Sep 17 00:00:00 2001 From: Ken Gorab Date: Mon, 18 Nov 2024 20:41:54 -0500 Subject: [PATCH] Fix abraw script to work for macos/linux --- projects/compiler/scripts/abraw | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/projects/compiler/scripts/abraw b/projects/compiler/scripts/abraw index 59e29e75..e1db83e6 100755 --- a/projects/compiler/scripts/abraw +++ b/projects/compiler/scripts/abraw @@ -83,14 +83,17 @@ $(echo "$compiler_bin $filepath $outfile") qbe -o "$dotabradir/$outfile.s" "$dotabradir/$outfile.ssa" -CFLAGS="-Wno-override-module" +CFLAGS_COMMON="-Wno-override-module" if [[ "$OSTYPE" == "darwin"* ]]; then - # Ignore linker warnings. For some reason libgc.a has warnings on macos - CFLAGS="$CFLAGS -Wl,-w -fcall-saved-x18" + # There are a few differences in behavior on macos vs linux. + # 1. ignore linker warnings. For some reason libgc.a has warnings on macos + # 2. fix behavior of platform-specific x18 register to be properly general-purpose + # 3. for some reason, libgc.a needs to be first (this is not the case on linux) + clang "$abra_root/include/libgc.a" "$dotabradir/$outfile.s" -o "$dotabradir/$outfile" -lm $CFLAGS_COMMON -Wl,-w -fcall-saved-x18 +else + clang "$dotabradir/$outfile.s" "$abra_root/include/libgc.a" -o "$dotabradir/$outfile" -lm $CFLAGS_COMMON fi -clang $abra_root/include/libgc.a "$dotabradir/$outfile.s" -o "$dotabradir/$outfile" -lm $CFLAGS - if [[ "$run" == "true" ]]; then $(echo "$dotabradir/$outfile $@") fi