Skip to content

Commit d8424f6

Browse files
committed
Auto merge of #74922 - joshtriplett:ninja-by-default, r=Mark-Simulacrum
Set ninja=true by default Ninja substantially improves LLVM build time. On a 96-way system, using Make took 248s, and using Ninja took 161s, a 35% improvement. We already require a variety of tools to build Rust. If someone wants to build without Ninja (for instance, to minimize the set of packages required to bootstrap a new target), they can easily set `ninja=false` in `config.toml`. Our defaults should help people build Rust (and LLVM) faster, to speed up development.
2 parents 17fb125 + 8b501e3 commit d8424f6

File tree

42 files changed

+58
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+58
-15
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ jobs:
583583
- name: dist-x86_64-apple
584584
env:
585585
SCRIPT: "./x.py dist"
586-
RUST_CONFIGURE_ARGS: "--target=aarch64-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc"
586+
RUST_CONFIGURE_ARGS: "--target=aarch64-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false"
587587
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
588588
MACOSX_DEPLOYMENT_TARGET: 10.7
589589
NO_LLVM_ASSERTIONS: 1
@@ -594,7 +594,7 @@ jobs:
594594
- name: dist-x86_64-apple-alt
595595
env:
596596
SCRIPT: "./x.py dist"
597-
RUST_CONFIGURE_ARGS: "--enable-extended --enable-profiler --set rust.jemalloc"
597+
RUST_CONFIGURE_ARGS: "--enable-extended --enable-profiler --set rust.jemalloc --set llvm.ninja=false"
598598
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
599599
MACOSX_DEPLOYMENT_TARGET: 10.7
600600
NO_LLVM_ASSERTIONS: 1
@@ -604,7 +604,7 @@ jobs:
604604
- name: x86_64-apple
605605
env:
606606
SCRIPT: "./x.py --stage 2 test"
607-
RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc"
607+
RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false"
608608
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
609609
MACOSX_DEPLOYMENT_TARGET: 10.8
610610
MACOSX_STD_DEPLOYMENT_TARGET: 10.7

README.md

+1

config.toml.example

+2-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@
4949
# dynamic version to be available.
5050
#static-libstdcpp = false
5151

52-
# Tell the LLVM build system to use Ninja instead of the platform default for
53-
# the generated build system. This can sometimes be faster than make, for
54-
# example.
55-
#ninja = false
52+
# Whether to use Ninja to build LLVM. This runs much faster than make.
53+
#ninja = true
5654

5755
# LLVM targets to build support for.
5856
# Note: this is NOT related to Rust compilation targets. However, as Rust is

src/bootstrap/builder/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ fn configure(host: &[&str], target: &[&str]) -> Config {
88
config.save_toolstates = None;
99
config.skip_only_host_steps = false;
1010
config.dry_run = true;
11+
config.ninja = false;
1112
// try to avoid spurious failures in dist where we create/delete each others file
1213
let dir = config
1314
.out

src/bootstrap/config.rs

+1
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ impl Config {
450450
pub fn default_opts() -> Config {
451451
let mut config = Config::default();
452452
config.llvm_optimize = true;
453+
config.ninja = true;
453454
config.llvm_version_check = true;
454455
config.backtrace = true;
455456
config.rust_optimize = true;

src/bootstrap/sanity.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,16 @@ pub fn check(build: &mut Build) {
100100
if build.config.ninja {
101101
// Some Linux distros rename `ninja` to `ninja-build`.
102102
// CMake can work with either binary name.
103-
if cmd_finder.maybe_have("ninja-build").is_none() {
104-
cmd_finder.must_have("ninja");
103+
if cmd_finder.maybe_have("ninja-build").is_none()
104+
&& cmd_finder.maybe_have("ninja").is_none()
105+
{
106+
eprintln!(
107+
"
108+
Couldn't find required command: ninja
109+
You should install ninja, or set ninja=false in config.toml
110+
"
111+
);
112+
std::process::exit(1);
105113
}
106114
}
107115

src/ci/azure-pipelines/auto.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
# version that we're using, 8.2, cannot compile LLVM for OSX 10.7.
3838
x86_64-apple:
3939
SCRIPT: ./x.py --stage 2 test
40-
INITIAL_RUST_CONFIGURE_ARGS: --build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc
40+
INITIAL_RUST_CONFIGURE_ARGS: --build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false
4141
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
4242
MACOSX_DEPLOYMENT_TARGET: 10.8
4343
MACOSX_STD_DEPLOYMENT_TARGET: 10.7
@@ -46,7 +46,7 @@ jobs:
4646

4747
dist-x86_64-apple:
4848
SCRIPT: ./x.py dist
49-
INITIAL_RUST_CONFIGURE_ARGS: --target=aarch64-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc
49+
INITIAL_RUST_CONFIGURE_ARGS: --target=aarch64-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false
5050
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
5151
MACOSX_DEPLOYMENT_TARGET: 10.7
5252
NO_LLVM_ASSERTIONS: 1
@@ -55,7 +55,7 @@ jobs:
5555

5656
dist-x86_64-apple-alt:
5757
SCRIPT: ./x.py dist
58-
INITIAL_RUST_CONFIGURE_ARGS: --enable-extended --enable-profiler --set rust.jemalloc
58+
INITIAL_RUST_CONFIGURE_ARGS: --enable-extended --enable-profiler --set rust.jemalloc --set llvm.ninja=false
5959
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
6060
MACOSX_DEPLOYMENT_TARGET: 10.7
6161
NO_LLVM_ASSERTIONS: 1

src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:20.04
33
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/armhf-gnu/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \
1414
libc6-dev \
1515
libc6-dev-armhf-cross \
1616
make \
17+
ninja-build \
1718
python3 \
1819
qemu-system-arm \
1920
xz-utils

src/ci/docker/host-x86_64/disabled/asmjs/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/disabled/dist-powerpcspe-linux/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/disabled/dist-sparc64-linux/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/disabled/dist-x86_64-dragonfly/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/disabled/dist-x86_64-haiku/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1616
libcurl4-openssl-dev \
1717
libssl-dev \
1818
make \
19+
ninja-build \
1920
nasm \
2021
pkg-config \
2122
python3 \

src/ci/docker/host-x86_64/disabled/riscv64gc-linux/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \
2020
libc6-dev \
2121
libc6-dev-riscv64-cross \
2222
make \
23+
ninja-build \
2324
patch \
2425
python3 \
2526
qemu-system-misc \

src/ci/docker/host-x86_64/dist-i586-gnu-i586-i686-musl/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++-multilib \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/dist-i686-freebsd/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:18.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
clang \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ ENV RUST_CONFIGURE_ARGS \
9393
--enable-profiler \
9494
--set target.i686-unknown-linux-gnu.linker=clang \
9595
--build=i686-unknown-linux-gnu \
96+
--set llvm.ninja=false \
9697
--set rust.jemalloc
9798
ENV SCRIPT python2.7 ../x.py dist --build $HOSTS --host $HOSTS --target $HOSTS
9899
ENV CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=clang

src/ci/docker/host-x86_64/dist-mips-linux/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/dist-mips64-linux/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/dist-mips64el-linux/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/dist-mipsel-linux/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/dist-various-1/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1515
libncurses-dev \
1616
gawk \
1717
make \
18+
ninja-build \
1819
file \
1920
curl \
2021
ca-certificates \

src/ci/docker/host-x86_64/dist-various-2/build-cloudabi-toolchain.sh

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ apt-get install -y --no-install-recommends \
1616
git \
1717
lld-5.0 \
1818
make \
19+
ninja-build \
1920
python \
2021
sudo \
2122
xz-utils

src/ci/docker/host-x86_64/dist-x86_64-freebsd/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:18.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
clang \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ ENV RUST_CONFIGURE_ARGS \
9696
--set target.x86_64-unknown-linux-gnu.ar=/rustroot/bin/llvm-ar \
9797
--set target.x86_64-unknown-linux-gnu.ranlib=/rustroot/bin/llvm-ranlib \
9898
--set llvm.thin-lto=true \
99+
--set llvm.ninja=false \
99100
--set rust.jemalloc
100101
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
101102
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=clang

src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
wget \
89
curl \

src/ci/docker/host-x86_64/i686-gnu-nopt/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++-multilib \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/i686-gnu/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++-multilib \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/mingw-check/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:18.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/test-various/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:18.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/wasm32/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/x86_64-gnu-aux/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/x86_64-gnu-debug/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:19.10
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/x86_64-gnu-distcheck/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/x86_64-gnu-llvm-8/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
g++-arm-linux-gnueabi \
66
make \
7+
ninja-build \
78
file \
89
curl \
910
ca-certificates \

src/ci/docker/host-x86_64/x86_64-gnu-nopt/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/host-x86_64/x86_64-gnu/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ubuntu:19.10
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \

src/ci/docker/scripts/android-base-apt-get.sh

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ apt-get install -y --no-install-recommends \
1010
git \
1111
libssl-dev \
1212
make \
13+
ninja-build \
1314
pkg-config \
1415
python3 \
1516
sudo \

src/ci/docker/scripts/cross-apt-packages.sh

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ apt-get update && apt-get install -y --no-install-recommends \
1717
libssl-dev \
1818
libtool-bin \
1919
make \
20+
ninja-build \
2021
patch \
2122
pkg-config \
2223
python3 \

0 commit comments

Comments
 (0)