@@ -41,28 +41,32 @@ pub fn llvm(build: &Build, target: &str) {
41
41
}
42
42
}
43
43
44
- // If the cleaning trigger is newer than our built artifacts (or if the
45
- // artifacts are missing) then we keep going, otherwise we bail out.
46
- let dst = build. llvm_out ( target) ;
47
- let stamp = build. src . join ( "src/rustllvm/llvm-auto-clean-trigger" ) ;
48
- let mut stamp_contents = String :: new ( ) ;
49
- t ! ( t!( File :: open( & stamp) ) . read_to_string( & mut stamp_contents) ) ;
50
- let done_stamp = dst. join ( "llvm-finished-building" ) ;
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) ) ;
47
+
48
+ let out_dir = build. llvm_out ( target) ;
49
+ let done_stamp = out_dir. join ( "llvm-finished-building" ) ;
51
50
if done_stamp. exists ( ) {
52
51
let mut done_contents = String :: new ( ) ;
53
52
t ! ( t!( File :: open( & done_stamp) ) . read_to_string( & mut done_contents) ) ;
54
- if done_contents == stamp_contents {
53
+
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 {
55
61
return
62
+ } else {
63
+ t ! ( fs:: remove_dir_all( & out_dir) ) ;
56
64
}
57
65
}
58
- drop ( fs:: remove_dir_all ( & dst) ) ;
59
66
60
67
println ! ( "Building LLVM for {}" , target) ;
61
-
62
68
let _time = util:: timeit ( ) ;
63
- let _ = fs:: remove_dir_all ( & dst. join ( "build" ) ) ;
64
- t ! ( fs:: create_dir_all( & dst. join( "build" ) ) ) ;
65
- let assertions = if build. config . llvm_assertions { "ON" } else { "OFF" } ;
69
+ t ! ( fs:: create_dir_all( & out_dir) ) ;
66
70
67
71
// http://llvm.org/docs/CMake.html
68
72
let mut cfg = cmake:: Config :: new ( build. src . join ( "src/llvm" ) ) ;
@@ -82,9 +86,11 @@ pub fn llvm(build: &Build, target: &str) {
82
86
None => "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc;NVPTX" ,
83
87
} ;
84
88
89
+ let assertions = if build. config . llvm_assertions { "ON" } else { "OFF" } ;
90
+
85
91
cfg. target ( target)
86
92
. host ( & build. config . build )
87
- . out_dir ( & dst )
93
+ . out_dir ( & out_dir )
88
94
. profile ( profile)
89
95
. define ( "LLVM_ENABLE_ASSERTIONS" , assertions)
90
96
. define ( "LLVM_TARGETS_TO_BUILD" , llvm_targets)
@@ -142,7 +148,7 @@ pub fn llvm(build: &Build, target: &str) {
142
148
// tools and libs on all platforms.
143
149
cfg. build ( ) ;
144
150
145
- t ! ( t!( File :: create( & done_stamp) ) . write_all( stamp_contents . as_bytes( ) ) ) ;
151
+ t ! ( t!( File :: create( & done_stamp) ) . write_all( clean_trigger_contents . as_bytes( ) ) ) ;
146
152
}
147
153
148
154
fn check_llvm_version ( build : & Build , llvm_config : & Path ) {
0 commit comments