From be323ed3e2754f2688f4919c1bd44139bf1ad5b7 Mon Sep 17 00:00:00 2001 From: Sonic Build Admin Date: Fri, 12 Sep 2025 02:05:13 +0000 Subject: [PATCH] Add rust to buster #### Why I did it Rust was added to bookworm, but is missing in bullseye build. Sonic-swss-common needs rust to build after https://github.com/sonic-net/sonic-swss-common/pull/1044, and byster vs build failures were seen due to missing rust. ##### Work item tracking - Microsoft ADO **(number only)**: #### How I did it #### How to verify it #### Which release branch to backport (provide reason below if selected) - [ ] 202205 - [ ] 202211 - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [ ] 202505 #### Tested branch (Please provide the tested image version) - [ ] - [ ] #### Description for the changelog #### Link to config_db schema for YANG module changes #### A picture of a cute animal (not mandatory but encouraged) --- sonic-slave-buster/Dockerfile.j2 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sonic-slave-buster/Dockerfile.j2 b/sonic-slave-buster/Dockerfile.j2 index b65a1a0895..2a3e203c77 100644 --- a/sonic-slave-buster/Dockerfile.j2 +++ b/sonic-slave-buster/Dockerfile.j2 @@ -672,3 +672,15 @@ LABEL "com.azure.dev.pipelines.agent.handler.node.path"="/usr/bin/node" ARG bazelisk_url=https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-{{ CONFIGURED_ARCH }} RUN curl -fsSL -o /usr/local/bin/bazel ${bazelisk_url} && chmod 755 /usr/local/bin/bazel {% endif -%} + +# Install Rust +ARG RUST_ROOT=/usr/.cargo +RUN RUSTUP_HOME=$RUST_ROOT CARGO_HOME=$RUST_ROOT bash -c 'curl --proto "=https" -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.86.0 -y' +{% if CROSS_BUILD_ENVIRON == "y" and CONFIGURED_ARCH == "armhf" %} +RUN mkdir -p /.cargo && $RUST_ROOT/bin/rustup target add armv7-unknown-linux-gnueabihf && echo "[target.armv7-unknown-linux-gnueabihf]\nlinker = \"arm-linux-gnueabihf-gcc\"" >> /.cargo/config.toml +{% endif -%} +{% if CROSS_BUILD_ENVIRON == "y" and CONFIGURED_ARCH == "arm64" %} +RUN mkdir -p /.cargo && $RUST_ROOT/bin/rustup target add aarch64-unknown-linux-gnu && echo "[target.aarch64-unknown-linux-gnu]\nlinker = \"aarch64-linux-gnu-gcc\"" >> /.cargo/config.toml +{% endif -%} +ENV RUSTUP_HOME $RUST_ROOT +ENV PATH $PATH:$RUST_ROOT/bin