Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ FROM sdk-libc AS sdk-rust

USER root
RUN \
mkdir -p /usr/libexec/rust && \
chown -R builder:builder /usr/libexec/rust
mkdir -p /usr/libexec/{rust,llvm} && \
chown -R builder:builder /usr/libexec/{rust,llvm}

ARG HOST_ARCH
ENV VENDOR="bottlerocket"
Expand Down Expand Up @@ -332,7 +332,10 @@ COPY ./configs/rust/targets ./targets
COPY ./configs/rust/config.toml.in ./
RUN \
sed -e "s,@HOST_TRIPLE@,${HOST_ARCH}-unknown-linux-gnu,g" config.toml.in > config.toml && \
RUSTUP_DIST_SERVER=example:// RUST_TARGET_PATH=${PWD}/targets python3 ./x.py install && \
RUSTUP_DIST_SERVER=example:// RUST_TARGET_PATH=${PWD}/targets python3 ./x.py install

# Copy target configs into the installed Rust environment.
RUN \
for arch in x86_64 aarch64 ; do \
for libc in gnu musl ; do \
cp \
Expand All @@ -341,6 +344,11 @@ RUN \
done ; \
done

# Copy out the LLVM toolchain that was built along with Rust.
RUN \
rm -rf "build/${HOST_ARCH}-unknown-linux-gnu/llvm/build" && \
rsync -aq "build/${HOST_ARCH}-unknown-linux-gnu/llvm/" /usr/libexec/llvm/

RUN \
install -p -m 0644 -Dt licenses COPYRIGHT LICENSE-*

Expand All @@ -349,6 +357,21 @@ ENV PATH="/usr/libexec/rust/bin:$PATH" LD_LIBRARY_PATH="/usr/libexec/rust/lib"

# =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^=

FROM scratch AS sdk-llvm

# Copy the LLVM install directly to `/usr`, so clang can auto-discover the
# GCC target toolchains.
COPY --from=sdk-rust /usr/libexec/llvm/ /usr/

# =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^=

# Merge the LLVM install with the rest of our toolchains and C libraries for
# later use by the AWS-LC builds.
FROM sdk-libc AS sdk-libc-llvm
COPY --from=sdk-llvm / /

# =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^=

FROM sdk AS sdk-grub

USER root
Expand Down Expand Up @@ -474,7 +497,7 @@ RUN \

# =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^=

FROM sdk-libc AS sdk-go-prep
FROM sdk-libc-llvm AS sdk-go-prep

# Set up the environment for building.
ENV GOOS="linux"
Expand Down Expand Up @@ -953,7 +976,6 @@ USER root
RUN \
dnf -y install --setopt=install_weak_deps=False \
ccache \
clang \
createrepo_c \
dosfstools \
e2fsprogs \
Expand All @@ -967,6 +989,7 @@ RUN \
groff \
kpartx \
less \
libbpf-devel \
libcap-devel \
libkcapi-hmaccalc \
lz4 \
Expand All @@ -978,6 +1001,7 @@ RUN \
protobuf-compiler \
protobuf-devel \
python3-devel \
python3-pyelftools \
python3-jinja2 \
python3-virt-firmware \
qemu-img \
Expand Down Expand Up @@ -1117,12 +1141,15 @@ COPY --from=sdk-libc-musl / /
# "sdk-libc-gnu" has the GNU C library and headers.
COPY --from=sdk-libc-gnu / /

# "sdk-rust" has our Rust toolchain with the required targets.
# "sdk-rust" has our Rust toolchains with the required targets.
COPY --chown=0:0 --from=sdk-rust /usr/libexec/rust/ /usr/libexec/rust/
COPY --chown=0:0 --from=sdk-rust \
/home/builder/rust/licenses/ \
/usr/share/licenses/rust/

# "sdk-llvm" has our LLVM toolchain.
COPY --chown=0:0 --from=sdk-llvm / /

# "sdk-go" has the Go toolchain and standard library builds.
COPY --chown=0:0 --from=sdk-go-1.25 /home/builder/sdk-go/bin /usr/libexec/go-1.25/bin/
COPY --chown=0:0 --from=sdk-go-1.25 /home/builder/sdk-go/lib /usr/libexec/go-1.25/lib/
Expand Down
4 changes: 4 additions & 0 deletions configs/rust/config.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ debuginfo-level-std = 2
rpath = false

[llvm]
download-ci-llvm = false
static-libstdcpp = false
targets = "AArch64;BPF;X86"
clang = true
link-shared = true

[install]
prefix = "/usr/libexec/rust"
Expand Down