Skip to content

Commit 4a93663

Browse files
committed
Migrate static-pie scripts to rmake
1 parent 591bbf6 commit 4a93663

File tree

3 files changed

+25
-44
lines changed

3 files changed

+25
-44
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

+25-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,37 @@
55
//@ only-linux
66
//@ ignore-32bit
77

8-
use std::process::Command;
9-
108
use run_make_support::llvm_readobj;
119
use run_make_support::rustc;
1210
use run_make_support::{cmd, target};
1311

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

17-
Command::new(check_file).status().is_ok_and(|status| status.success())
24+
let process = cmd(compiler).arg("-dumpversion").run_unchecked();
25+
if !process.status().success() {
26+
eprintln!("No {compiler} version detected");
27+
return false;
28+
}
29+
// 'major.minor.patch', 'major.minor', or 'major'
30+
let version: u32 = process.stdout_utf8().split(".").next().unwrap().parse().unwrap();
31+
32+
if version >= version_threshold {
33+
eprintln!("{compiler} supports -static-pie");
34+
true
35+
} else {
36+
eprintln!("{compiler} too old to support -static-pie, skipping test");
37+
false
38+
}
1839
}
1940

2041
fn test(compiler: &str) {

0 commit comments

Comments
 (0)