Auto merge of #126941 - GuillaumeGomez:migrate-run-make-llvm-ident, r… · rust-lang/rust@7d97c59 (original) (raw)

File tree

4 files changed

lines changed

4 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -180,6 +180,13 @@ impl LlvmFilecheck {
180 180 self.cmd.arg(path.as_ref());
181 181 self
182 182 }
183 +
184 +/// `--input-file` option.
185 + pub fn input_file<P: AsRef<Path>>(&mut self, input_file: P) -> &mut Self {
186 +self.cmd.arg("--input-file");
187 +self.cmd.arg(input_file.as_ref());
188 +self
189 +}
183 190 }
184 191
185 192 impl LlvmObjdump {
Original file line number Diff line number Diff line change
@@ -85,7 +85,6 @@ run-make/link-cfg/Makefile
85 85 run-make/link-framework/Makefile
86 86 run-make/link-path-order/Makefile
87 87 run-make/linkage-attr-on-static/Makefile
88 -run-make/llvm-ident/Makefile
89 88 run-make/long-linker-command-lines-cmd-exe/Makefile
90 89 run-make/long-linker-command-lines/Makefile
91 90 run-make/longjmp-across-rust/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
1 +//@ only-linux
2 +//@ ignore-cross-compile
3 +
4 +use run_make_support::llvm::llvm_bin_dir;
5 +use run_make_support::{cmd, env_var, llvm_filecheck, read_dir, rustc, source_root};
6 +
7 +use std::ffi::OsStr;
8 +
9 +fn main() {
10 +// `-Ccodegen-units=16 -Copt-level=2` is used here to trigger thin LTO
11 +// across codegen units to test deduplication of the named metadata
12 +// (see `LLVMRustPrepareThinLTOImport` for details).
13 +rustc()
14 +.emit("link,obj")
15 +.arg("-")
16 +.arg("-Csave-temps")
17 +.codegen_units(16)
18 +.opt_level("2")
19 +.target(&env_var("TARGET"))
20 +.stdin("fn main(){}")
21 +.run();
22 +
23 +// `llvm-dis` is used here since `--emit=llvm-ir` does not emit LLVM IR
24 +// for temporary outputs.
25 +let mut files = Vec::new();
26 +read_dir(".", |path
27 +if path.is_file() && path.extension().is_some_and(|ext
28 + files.push(path.to_path_buf());
29 +}
30 +});
31 +cmd(llvm_bin_dir().join("llvm-dis")).args(&files).run();
32 +
33 +// Check LLVM IR files (including temporary outputs) have `!llvm.ident`
34 +// named metadata, reusing the related codegen test.
35 +let llvm_ident_path = source_root().join("tests/codegen/llvm-ident.rs");
36 +read_dir(".", |path
37 +if path.is_file() && path.extension().is_some_and(|ext
38 +llvm_filecheck().input_file(path).arg(&llvm_ident_path).run();
39 +}
40 +});
41 +}