-# Now that we've done our last non-LTO build, turn on LTO in CFLAGS as well
-export BASE_CFLAGS="-ffile-prefix-map=$HOME/.cargo= -frandom-seed=42"
+export BASE_CFLAGS="-ffile-prefix-map=$HOME/.cargo="
+
+BASE_CFLAGS="$BASE_CFLAGS -frandom-seed=42"
+LOCAL_CFLAGS="-Wall -Wno-nullability-completeness -pthread -Iinclude/"
+
+if [ "$HOST_PLATFORM" = "host: x86_64-apple-darwin" ]; then
+ LOCAL_CFLAGS="$LOCAL_CFLAGS -isysroot$(xcrun --show-sdk-path)"
+ BASE_CFLAGS="$BASE_CFLAGS -isysroot$(xcrun --show-sdk-path)"
+ # Targeting aarch64 appears to be supported only starting with Big Sur, so check it before use
+ clang -o /dev/null -target=aarch64-apple-darwin -mcpu=apple-a14 genbindings_path_map_test_file.c > /dev/null 2>&1 &&
+ export CFLAGS_aarch64_apple_darwin="$BASE_CFLAGS -target=aarch64-apple-darwin -mcpu=apple-a14"
+fi
+
+rm genbindings_path_map_test_file.c
+