Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 39faece

Browse files
committedJun 22, 2024
Migrate static-pie scripts to rmake
1 parent 92a55e9 commit 39faece

File tree

3 files changed

+32
-42
lines changed

3 files changed

+32
-42
lines changed
 

‎tests/run-make/static-pie/check_clang_version.sh

-20
This file was deleted.

‎tests/run-make/static-pie/check_gcc_version.sh

-20
This file was deleted.

‎tests/run-make/static-pie/rmake.rs

+32-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,40 @@ use run_make_support::llvm_readobj;
1111
use run_make_support::rustc;
1212
use run_make_support::{cmd, run_with_args, target};
1313

14+
// Minimum major versions supporting -static-pie
15+
const GCC_VERSION: u32 = 8;
16+
const CLANG_VERSION: u32 = 9;
17+
18+
// Return `true` if the `compiler` version supports `-static-pie`.
1419
fn ok_compiler_version(compiler: &str) -> bool {
15-
let check_file = format!("check_{compiler}_version.sh");
20+
let version_threshold = match compiler {
21+
"clang" => CLANG_VERSION,
22+
"gcc" => GCC_VERSION,
23+
other => panic!("unexpected compiler '{other}', expected 'clang' or 'gcc'"),
24+
};
1625

17-
Command::new(check_file).status().is_ok_and(|status| status.success())
26+
if Command::new(compiler).spawn().is_err() {
27+
eprintln!("No {compiler} version detected");
28+
return false;
29+
}
30+
// 'major.minor.patch', 'major.minor', or 'major'
31+
let version: u32 = cmd(compiler)
32+
.arg("-dumpversion")
33+
.run()
34+
.stdout_utf8()
35+
.split(".")
36+
.next()
37+
.unwrap()
38+
.parse()
39+
.unwrap();
40+
41+
if version >= version_threshold {
42+
eprintln!("{compiler} supports -static-pie");
43+
true
44+
} else {
45+
eprintln!("{compiler} too old to support -static-pie, skipping test");
46+
false
47+
}
1848
}
1949

2050
fn test(compiler: &str) {

0 commit comments

Comments
 (0)
Failed to load comments.