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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 0 deletions

config.toml.example

Lines changed: 2 additions & 4 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 10 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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 \

0 commit comments

Comments
 (0)