Skip to content

Commit 7485f33

Browse files
Nemo157syphar
authored andcommitted
Use mold for faster linking in docker build
1 parent d452dd4 commit 7485f33

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

dockerfiles/Dockerfile

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ FROM ubuntu:22.04 AS build
1414
# Install packaged dependencies
1515
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
1616
build-essential git curl cmake gcc g++ pkg-config libmagic-dev \
17-
libssl-dev zlib1g-dev ca-certificates
17+
libssl-dev zlib1g-dev ca-certificates mold clang
1818

1919
# Install the stable toolchain with rustup
2020
RUN curl https://sh.rustup.rs >/tmp/rustup-init && \
2121
chmod +x /tmp/rustup-init && \
2222
/tmp/rustup-init -y --no-modify-path --default-toolchain stable --profile minimal
2323
ENV PATH=/root/.cargo/bin:$PATH
2424

25+
# Configure linking to use mold instead for speed (need to use clang because gcc
26+
# is too old on this image)
27+
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=clang
28+
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS=-Clink-arg=-fuse-ld=mold
29+
2530
# Build the dependencies in a separate step to avoid rebuilding all of them
2631
# every time the source code changes. This takes advantage of Docker's layer
2732
# caching, and it works by copying the Cargo.{toml,lock} with dummy source code

0 commit comments

Comments
 (0)