Skip to content

Commit fd182c4

Browse files
committed
Auto merge of #40329 - petrochenkov:llreuse, r=alexcrichton
rustbuild: Add option for enabling partial LLVM rebuilds @alexcrichton , you probably didn't notice my [late comment](#40236 (comment)) on #40236, but here's an implementation of that suggestion, it supersedes c652a4f. r? @alexcrichton
2 parents a5483a7 + 4cda4d6 commit fd182c4

File tree

7 files changed

+26
-18
lines changed

7 files changed

+26
-18
lines changed

appveyor.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ on_failure:
144144
- cat %CD%/sccache.log
145145

146146
cache:
147-
- "build/i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-auto-clean-trigger"
148-
- "build/x86_64-pc-windows-msvc/llvm -> src/rustllvm/llvm-auto-clean-trigger"
149-
- "i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-auto-clean-trigger"
150-
- "x86_64-pc-windows-msvc/llvm -> src/rustllvm/llvm-auto-clean-trigger"
147+
- "build/i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger"
148+
- "build/x86_64-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger"
149+
- "i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger"
150+
- "x86_64-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger"
151151

152152
branches:
153153
only:

configure

+1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ opt local-rust 0 "use an installed rustc rather than downloading a snapshot"
437437
opt local-rebuild 0 "assume local-rust matches the current version, for rebuilds; implies local-rust, and is implied if local-rust already matches the current version"
438438
opt llvm-static-stdcpp 0 "statically link to libstdc++ for LLVM"
439439
opt llvm-link-shared 0 "prefer shared linking to LLVM (llvm-config --link-shared)"
440+
opt llvm-clean-rebuild 0 "delete LLVM build directory on rebuild"
440441
opt rpath 1 "build rpaths into rustc itself"
441442
opt stage0-landing-pads 1 "enable landing pads during bootstrap with stage0"
442443
# This is used by the automation to produce single-target nightlies

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub struct Config {
6060
pub llvm_link_shared: bool,
6161
pub llvm_targets: Option<String>,
6262
pub llvm_link_jobs: Option<u32>,
63+
pub llvm_clean_rebuild: bool,
6364

6465
// rust codegen options
6566
pub rust_optimize: bool,
@@ -181,6 +182,7 @@ struct Llvm {
181182
static_libstdcpp: Option<bool>,
182183
targets: Option<String>,
183184
link_jobs: Option<u32>,
185+
clean_rebuild: Option<bool>,
184186
}
185187

186188
#[derive(RustcDecodable, Default, Clone)]
@@ -334,6 +336,7 @@ impl Config {
334336
set(&mut config.llvm_release_debuginfo, llvm.release_debuginfo);
335337
set(&mut config.llvm_version_check, llvm.version_check);
336338
set(&mut config.llvm_static_stdcpp, llvm.static_libstdcpp);
339+
set(&mut config.llvm_clean_rebuild, llvm.clean_rebuild);
337340
config.llvm_targets = llvm.targets.clone();
338341
config.llvm_link_jobs = llvm.link_jobs;
339342
}
@@ -439,6 +442,7 @@ impl Config {
439442
("LLVM_VERSION_CHECK", self.llvm_version_check),
440443
("LLVM_STATIC_STDCPP", self.llvm_static_stdcpp),
441444
("LLVM_LINK_SHARED", self.llvm_link_shared),
445+
("LLVM_CLEAN_REBUILD", self.llvm_clean_rebuild),
442446
("OPTIMIZE", self.rust_optimize),
443447
("DEBUG_ASSERTIONS", self.rust_debug_assertions),
444448
("DEBUGINFO", self.rust_debuginfo),

src/bootstrap/config.toml.example

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@
6161
# controlled by rustbuild's -j parameter.
6262
#link-jobs = 0
6363

64+
# Delete LLVM build directory on LLVM rebuild.
65+
# This option defaults to `false` for local development, but CI may want to
66+
# always perform clean full builds (possibly accelerated by (s)ccache).
67+
#clean-rebuild = false
68+
6469
# =============================================================================
6570
# General build configuration options
6671
# =============================================================================

src/bootstrap/native.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,25 @@ pub fn llvm(build: &Build, target: &str) {
4141
}
4242
}
4343

44-
let clean_trigger = build.src.join("src/rustllvm/llvm-auto-clean-trigger");
45-
let mut clean_trigger_contents = String::new();
46-
t!(t!(File::open(&clean_trigger)).read_to_string(&mut clean_trigger_contents));
44+
let rebuild_trigger = build.src.join("src/rustllvm/llvm-rebuild-trigger");
45+
let mut rebuild_trigger_contents = String::new();
46+
t!(t!(File::open(&rebuild_trigger)).read_to_string(&mut rebuild_trigger_contents));
4747

4848
let out_dir = build.llvm_out(target);
4949
let done_stamp = out_dir.join("llvm-finished-building");
5050
if done_stamp.exists() {
5151
let mut done_contents = String::new();
5252
t!(t!(File::open(&done_stamp)).read_to_string(&mut done_contents));
5353

54-
// LLVM was already built previously.
55-
// We don't track changes in LLVM sources, so we need to choose between reusing
56-
// what was built previously, or cleaning the directory and doing a fresh build.
57-
// The choice depends on contents of the clean-trigger file.
58-
// If the contents are the same as during the previous build, then no action is required.
59-
// If the contents differ from the previous build, then cleaning is triggered.
60-
if done_contents == clean_trigger_contents {
54+
// If LLVM was already built previously and contents of the rebuild-trigger file
55+
// didn't change from the previous build, then no action is required.
56+
if done_contents == rebuild_trigger_contents {
6157
return
62-
} else {
63-
t!(fs::remove_dir_all(&out_dir));
6458
}
6559
}
60+
if build.config.llvm_clean_rebuild {
61+
drop(fs::remove_dir_all(&out_dir));
62+
}
6663

6764
println!("Building LLVM for {}", target);
6865
let _time = util::timeit();
@@ -154,7 +151,7 @@ pub fn llvm(build: &Build, target: &str) {
154151
// tools and libs on all platforms.
155152
cfg.build();
156153

157-
t!(t!(File::create(&done_stamp)).write_all(clean_trigger_contents.as_bytes()));
154+
t!(t!(File::create(&done_stamp)).write_all(rebuild_trigger_contents.as_bytes()));
158155
}
159156

160157
fn check_llvm_version(build: &Build, llvm_config: &Path) {

src/ci/run.sh

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-quiet-tests"
2828
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules"
2929
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps"
3030
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-openssl-static"
31+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-clean-rebuild"
3132

3233
if [ "$DIST_SRC" = "" ]; then
3334
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-dist-src"
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# If this file is modified, then llvm will be forcibly cleaned and then rebuilt.
1+
# If this file is modified, then llvm will be (optionally) cleaned and then rebuilt.
22
# The actual contents of this file do not matter, but to trigger a change on the
33
# build bots then the contents should be changed so git updates the mtime.
44
2017-03-04

0 commit comments

Comments
 (0)