Skip to content

Commit 0d1343e

Browse files
petrochenkovalexcrichton
authored andcommitted
rustbuild: Add option for enabling partial LLVM rebuilds
1 parent f573db4 commit 0d1343e

File tree

5 files changed

+26
-18
lines changed

5 files changed

+26
-18
lines changed

appveyor.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ test_script:
137137
- sh src/ci/run.sh
138138

139139
cache:
140-
- "build/i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-auto-clean-trigger"
141-
- "build/x86_64-pc-windows-msvc/llvm -> src/rustllvm/llvm-auto-clean-trigger"
142-
- "i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-auto-clean-trigger"
143-
- "x86_64-pc-windows-msvc/llvm -> src/rustllvm/llvm-auto-clean-trigger"
140+
- "build/i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger"
141+
- "build/x86_64-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger"
142+
- "i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger"
143+
- "x86_64-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger"
144144

145145
branches:
146146
only:

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pub struct Config {
5959
pub llvm_static_stdcpp: bool,
6060
pub llvm_link_shared: bool,
6161
pub llvm_targets: Option<String>,
62+
pub llvm_clean_rebuild: bool,
6263

6364
// rust codegen options
6465
pub rust_optimize: bool,
@@ -179,6 +180,7 @@ struct Llvm {
179180
version_check: Option<bool>,
180181
static_libstdcpp: Option<bool>,
181182
targets: Option<String>,
183+
clean_rebuild: Option<bool>,
182184
}
183185

184186
#[derive(RustcDecodable, Default, Clone)]
@@ -239,6 +241,7 @@ impl Config {
239241
pub fn parse(build: &str, file: Option<PathBuf>) -> Config {
240242
let mut config = Config::default();
241243
config.llvm_optimize = true;
244+
config.llvm_clean_rebuild = true;
242245
config.use_jemalloc = true;
243246
config.backtrace = true;
244247
config.rust_optimize = true;
@@ -332,6 +335,7 @@ impl Config {
332335
set(&mut config.llvm_release_debuginfo, llvm.release_debuginfo);
333336
set(&mut config.llvm_version_check, llvm.version_check);
334337
set(&mut config.llvm_static_stdcpp, llvm.static_libstdcpp);
338+
set(&mut config.llvm_clean_rebuild, llvm.clean_rebuild);
335339
config.llvm_targets = llvm.targets.clone();
336340
}
337341

src/bootstrap/config.toml.example

+7
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@
5353
# Rust team and file an issue if you need assistance in porting!
5454
#targets = "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc;NVPTX"
5555

56+
# Delete LLVM build directory on LLVM rebuild.
57+
# This option's default (`true`) is optimized for CI needs, and CI wants to
58+
# perform clean full builds only (possibly accelerated by (s)ccache).
59+
# You may want to override this option for local builds to enable partial LLVM
60+
# rebuilds.
61+
#clean-rebuild = true
62+
5663
# =============================================================================
5764
# General build configuration options
5865
# =============================================================================

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+
t!(fs::remove_dir_all(&out_dir));
62+
}
6663

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

151-
t!(t!(File::create(&done_stamp)).write_all(clean_trigger_contents.as_bytes()));
148+
t!(t!(File::create(&done_stamp)).write_all(rebuild_trigger_contents.as_bytes()));
152149
}
153150

154151
fn check_llvm_version(build: &Build, llvm_config: &Path) {
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-02

0 commit comments

Comments
 (0)