diff --git a/.cargo/config-release.toml b/.cargo/config-release.toml index faab5e6c57..fa2932fecb 100644 --- a/.cargo/config-release.toml +++ b/.cargo/config-release.toml @@ -5,7 +5,10 @@ rustflags = ["-C", "target-feature=-crt-static"] [target.x86_64-unknown-linux-musl] -rustflags = ["-C", "target-feature=-crt-static"] +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=x86-64-v3"] [target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc" diff --git a/.cargo/config.toml b/.cargo/config.toml index 18bc8e4064..307582b0ad 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -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" diff --git a/Dockerfile b/Dockerfile index 5c8ac67655..5b2ff5882a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -114,9 +114,28 @@ RUN TOOLCHAIN_VERSION="$(grep channel rust-toolchain.toml | awk '{print $3}' | t ONBUILD ENV HOME=/root ONBUILD ENV CARGO_HOME=$HOME/.cargo -# Configure Rust toolchain +ONBUILD ARG CARGO_BUILD_PROFILE=dev + +# Configure Rust toolchain and C / C++ compiler +RUN <> /root/env +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=x86-64-v3" >> /root/env + echo "export CXXFLAGS=-march=x86-64-v3" >> /root/env + echo "export PORTABLE=x86-64-v3" >> /root/env + else + echo "export CFLAGS=-march=x86-64" >> /root/env + echo "export CXXFLAGS=-march=x86-64" >> /root/env + echo "export PORTABLE=x86-64" >> /root/env + fi +else + echo "export PORTABLE=1" >> /root/env +fi +EOS # Install protoc - protobuf compiler # The one shipped with Alpine does not work @@ -258,14 +277,15 @@ WORKDIR /tmp/rocksdb # sccache -s # EOS +# Select whether we want dev or release +# This variable will be also visibe in next stages +ONBUILD ARG CARGO_BUILD_PROFILE=dev + RUN --mount=type=secret,id=AWS <