Skip to content

Commit 544fd44

Browse files
committed
Don't force targeting sandybridge on all platforms
This should fix building on macOS when using upstream clang.
1 parent c151119 commit 544fd44

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

genbindings.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,19 @@ rm genbindings_path_map_test_file.c
6868
case "$ENV_TARGET" in
6969
"x86_64"*)
7070
export RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=sandybridge"
71-
export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS -march=sandybridge -mcpu=sandybridge -mtune=sandybridge"
71+
export BASE_HOST_CFLAGS="$BASE_HOST_CFLAGS -march=sandybridge -mcpu=sandybridge -mtune=sandybridge"
72+
export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS"
7273
;;
7374
"aarch64_apple_darwin")
7475
export RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14"
75-
export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS -mcpu=apple-a14"
76+
export BASE_HOST_CFLAGS="$BASE_HOST_CFLAGS -mcpu=apple-a14"
77+
export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS"
7678
;;
7779
*)
7880
# Assume this isn't targeted at another host and build for the host's CPU.
7981
export RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=native"
80-
export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS -mcpu=native"
82+
export BASE_HOST_CFLAGS="$BASE_HOST_CFLAGS -mcpu=native"
83+
export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS"
8184
;;
8285
esac
8386

@@ -497,7 +500,7 @@ if [ "$CLANGPP" != "" ]; then
497500
# The cc-rs crate tries to force -fdata-sections and -ffunction-sections on, which
498501
# breaks -fembed-bitcode, so we turn off cc-rs' default flags and specify exactly
499502
# what we want here.
500-
export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS -fPIC -fembed-bitcode -march=sandybridge -mcpu=sandybridge -mtune=sandybridge"
503+
export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS -fPIC -fembed-bitcode"
501504
export CRATE_CC_NO_DEFAULTS=true
502505
fi
503506

@@ -550,7 +553,7 @@ if [ "$CLANGPP" != "" -a "$LLD" != "" ]; then
550553
fi
551554
# If we're on an M1 don't bother building X86 binaries
552555
if [ "$HOST_PLATFORM" != "aarch64-apple-darwin" ]; then
553-
export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS -O3 -fPIC -fembed-bitcode -march=sandybridge -mcpu=sandybridge -mtune=sandybridge"
556+
export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS -O3 -fPIC -fembed-bitcode"
554557
# Rust doesn't recognize CFLAGS changes, so we need to clean build artifacts
555558
cargo clean --release
556559
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

0 commit comments

Comments
 (0)