Skip building x86_64 release binaries on M1 Macs
authorMatt Corallo <git@bluematt.me>
Thu, 12 May 2022 20:55:17 +0000 (20:55 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 13 May 2022 16:05:11 +0000 (16:05 +0000)
genbindings.sh

index b7d7566a081b7cffb1d95c8f080d84f971c13183..155269b39f06f91afe8e38f2b47be2fb07f7ccf6 100755 (executable)
@@ -540,17 +540,20 @@ if [ "$CLANGPP" != "" -a "$LLD" != "" ]; then
                LINK_ARG_FLAGS="$LINK_ARG_FLAGS -C link-arg="-isysroot$(xcrun --show-sdk-path)" -C link-arg=-mmacosx-version-min=10.9"
                RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14 -C embed-bitcode=yes -C linker-plugin-lto -C lto -C linker=$CLANG $LINK_ARG_FLAGS -C link-arg=-mcpu=apple-a14" CARGO_PROFILE_RELEASE_LTO=true cargo build $CARGO_BUILD_ARGS -v --release --target aarch64-apple-darwin
        fi
-       export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS -O3 -fPIC -fembed-bitcode -march=sandybridge -mcpu=sandybridge -mtune=sandybridge"
-       # Rust doesn't recognize CFLAGS changes, so we need to clean build artifacts
-       cargo clean --release
-       CARGO_PROFILE_RELEASE_LTO=true RUSTFLAGS="$RUSTFLAGS -C embed-bitcode=yes -C linker-plugin-lto -C lto -C linker=$CLANG $LINK_ARG_FLAGS -C link-arg=-march=sandybridge -C link-arg=-mcpu=sandybridge -C link-arg=-mtune=sandybridge" cargo build $CARGO_BUILD_ARGS -v --release
-
-       if [ "$2" = "true" ]; then
-               $CLANGPP $LOCAL_CFLAGS -flto -fuse-ld=$LLD -O2 demo.cpp target/release/libldk.a -ldl
-               strip ./a.out
-               echo "C++ Bin size and runtime with cross-language LTO:"
-               ls -lha a.out
-               time ./a.out > /dev/null
+       # If we're on an M1 don't bother building X86 binaries
+       if [ "$HOST_PLATFORM" != "aarch64-apple-darwin" ]; then
+               export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS -O3 -fPIC -fembed-bitcode -march=sandybridge -mcpu=sandybridge -mtune=sandybridge"
+               # Rust doesn't recognize CFLAGS changes, so we need to clean build artifacts
+               cargo clean --release
+               CARGO_PROFILE_RELEASE_LTO=true RUSTFLAGS="$RUSTFLAGS -C embed-bitcode=yes -C linker-plugin-lto -C lto -C linker=$CLANG $LINK_ARG_FLAGS -C link-arg=-march=sandybridge -C link-arg=-mcpu=sandybridge -C link-arg=-mtune=sandybridge" cargo build $CARGO_BUILD_ARGS -v --release
+
+               if [ "$2" = "true" ]; then
+                       $CLANGPP $LOCAL_CFLAGS -flto -fuse-ld=$LLD -O2 demo.cpp target/release/libldk.a -ldl
+                       strip ./a.out
+                       echo "C++ Bin size and runtime with cross-language LTO:"
+                       ls -lha a.out
+                       time ./a.out > /dev/null
+               fi
        fi
 else
        if [ "$CFLAGS_aarch64_apple_darwin" != "" ]; then