Skip to content

Commit c4eab2b

Browse files
authored
Avoid spurious build script runs (#4150)
* Don't attempt to track the generated clif.isle in cargo This causes the build script to rerun every time for me. * Put build script debug messages on stderr instead of stdout This keeps stdout reserved for cargo build script directives
1 parent 2111f7d commit c4eab2b

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

cranelift/codegen/build.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ struct IsleCompilations {
166166
struct IsleCompilation {
167167
output: std::path::PathBuf,
168168
inputs: Vec<std::path::PathBuf>,
169+
untracked_inputs: Vec<std::path::PathBuf>,
169170
}
170171

171172
/// Construct the list of compilations (transformations from ISLE
@@ -205,31 +206,31 @@ fn get_isle_compilations(
205206
IsleCompilation {
206207
output: out_dir.join("isle_x64.rs"),
207208
inputs: vec![
208-
clif_isle.clone(),
209209
prelude_isle.clone(),
210210
src_isa_x64.join("inst.isle"),
211211
src_isa_x64.join("lower.isle"),
212212
],
213+
untracked_inputs: vec![clif_isle.clone()],
213214
},
214215
// The aarch64 instruction selector.
215216
IsleCompilation {
216217
output: out_dir.join("isle_aarch64.rs"),
217218
inputs: vec![
218-
clif_isle.clone(),
219219
prelude_isle.clone(),
220220
src_isa_aarch64.join("inst.isle"),
221221
src_isa_aarch64.join("lower.isle"),
222222
],
223+
untracked_inputs: vec![clif_isle.clone()],
223224
},
224225
// The s390x instruction selector.
225226
IsleCompilation {
226227
output: out_dir.join("isle_s390x.rs"),
227228
inputs: vec![
228-
clif_isle.clone(),
229229
prelude_isle.clone(),
230230
src_isa_s390x.join("inst.isle"),
231231
src_isa_s390x.join("lower.isle"),
232232
],
233+
untracked_inputs: vec![clif_isle.clone()],
233234
},
234235
],
235236
})
@@ -276,10 +277,15 @@ fn run_compilation(
276277
) -> Result<(), Box<dyn std::error::Error + 'static>> {
277278
use cranelift_isle as isle;
278279

279-
println!("Rebuilding {}", compilation.output.display());
280+
eprintln!("Rebuilding {}", compilation.output.display());
280281

281282
let code = (|| {
282-
let lexer = isle::lexer::Lexer::from_files(&compilation.inputs[..])?;
283+
let lexer = isle::lexer::Lexer::from_files(
284+
compilation
285+
.inputs
286+
.iter()
287+
.chain(compilation.untracked_inputs.iter()),
288+
)?;
283289
let defs = isle::parser::parse(lexer)?;
284290

285291
let mut options = isle::codegen::CodegenOptions::default();
@@ -355,7 +361,7 @@ fn run_compilation(
355361
code
356362
});
357363

358-
println!(
364+
eprintln!(
359365
"Writing ISLE-generated Rust code to {}",
360366
compilation.output.display()
361367
);

cranelift/codegen/meta/src/srcgen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl Formatter {
100100
let path_str = format!("{}/{}", directory, filename.as_ref());
101101

102102
let path = path::Path::new(&path_str);
103-
println!("Writing generated file: {}", path.display());
103+
eprintln!("Writing generated file: {}", path.display());
104104
let mut f = fs::File::create(path)?;
105105

106106
for l in self.lines.iter().map(|l| l.as_bytes()) {

0 commit comments

Comments
 (0)