Skip to content

Commit

Permalink
chore: release uses target-cpu=x86-64-v3
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Dec 4, 2024
1 parent 8f7431b commit 3a04aa0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .cargo/config-release.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
rustflags = ["-C", "target-feature=-crt-static"]

[target.x86_64-unknown-linux-musl]
rustflags = ["-C", "target-feature=-crt-static", "-C", "target-cpu=haswell"]
rustflags = ["-C", "target-feature=-crt-static", "-C", "target-cpu=x86-64-v3"]

[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "target-feature=-crt-static", "-C", "target-cpu=haswell"]
rustflags = ["-C", "target-feature=-crt-static", "-C", "target-cpu=x86-64-v3"]

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
19 changes: 18 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,24 @@
rustflags = ["-C", "target-feature=-crt-static", "--cfg", "tokio_unstable"]

[target.x86_64-unknown-linux-musl]
rustflags = ["-C", "target-feature=-crt-static", "--cfg", "tokio_unstable"]
rustflags = [
"-C",
"target-feature=-crt-static",
"--cfg",
"tokio_unstable",
"-C",
"target-cpu=x86-64",
]

[target.x86_64-unknown-linux-gnu]
rustflags = [
"-C",
"target-feature=-crt-static",
"--cfg",
"tokio_unstable",
"-C",
"target-cpu=x86-64",
]

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
Expand Down
17 changes: 6 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,16 @@ echo 'source $HOME/.cargo/env' >> /root/env
# Enable gcc / g++ optimizations
if [[ "$TARGETARCH" == "amd64" ]] ; then
if [[ "${CARGO_BUILD_PROFILE}" == "release" ]] ; then
echo "export CFLAGS=-march=haswell" >> /root/env
echo "export CXXFLAGS=-march=haswell" >> /root/env
echo "export CFLAGS=-march=x86-64-v3" >> /root/env
echo "export CXXFLAGS=-march=x86-64-v3" >> /root/env
echo "PORTABLE=x86-64-v3" >> /root/env
else
echo "export CFLAGS=-march=x86-64" >> /root/env
echo "export CXXFLAGS=-march=x86-64" >> /root/env
echo "PORTABLE=1" >> /root/env
fi
else
echo "PORTABLE=1" >> /root/env
fi
EOS

Expand Down Expand Up @@ -282,15 +286,6 @@ set -ex -o pipefail
git clone https://github.com/facebook/rocksdb.git -b v8.10.2 --depth 1 .
source /root/env

# For x86-64 release, tune the build to use haswell optimizations.
# It requires 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
# FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
if [[ "$TARGETARCH" == "amd64" ]] && [[ "$CARGO_BUILD_PROFILE" == "release" ]] ; then
export PORTABLE=haswell
else
export PORTABLE=1
fi

make -j$(nproc) static_lib
mkdir -p /opt/rocksdb/usr/local/lib
cp librocksdb.a /opt/rocksdb/usr/local/lib/
Expand Down

0 comments on commit 3a04aa0

Please sign in to comment.