Skip to content

Commit 5ec7d6e

Browse files
committed
Auto merge of rust-lang#132646 - jieyouxu:liberate-aarch64-gnu-debug, r=Kobzol
Liberate `aarch64-gnu-debug` from the shackles of `--test-args=clang` ### Changes - Drop `--test-args=clang` from `aarch64-gnu-debug` so run-make tests that are `//@ needs-force-clang-based-tests` no longer only run if their test name contains `clang` (which is a very cool footgun). - Reorganize run-make-suport library slightly to accommodate a raw gcc invocation. - Fix `tests/run-make/mte-ffi/rmake.rs` to use `gcc` instead of *a* c compiler. try-job: aarch64-gnu try-job: aarch64-gnu-debug
2 parents a8e75c5 + a6dac70 commit 5ec7d6e

File tree

9 files changed

+184
-111
lines changed

9 files changed

+184
-111
lines changed

src/ci/docker/host-aarch64/aarch64-gnu-debug/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ ENV RUST_CONFIGURE_ARGS \
5555

5656
ENV SCRIPT \
5757
python3 ../x.py --stage 2 build && \
58-
python3 ../x.py --stage 2 test tests/run-make --test-args clang
58+
python3 ../x.py --stage 2 test tests/run-make

src/tools/run-make-support/src/external_deps/c_build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::path::PathBuf;
22

33
use crate::artifact_names::{dynamic_lib_name, static_lib_name};
4-
use crate::external_deps::cc::{cc, cxx};
4+
use crate::external_deps::c_cxx_compiler::{cc, cxx};
55
use crate::external_deps::llvm::llvm_ar;
66
use crate::path_helpers::path;
77
use crate::targets::{is_darwin, is_msvc, is_windows};

src/tools/run-make-support/src/external_deps/cc.rs renamed to src/tools/run-make-support/src/external_deps/c_cxx_compiler/cc.rs

+1-97
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::path::Path;
22

33
use crate::command::Command;
4-
use crate::{env_var, is_msvc, is_windows, uname};
4+
use crate::{env_var, is_msvc};
55

66
/// Construct a new platform-specific C compiler invocation.
77
///
@@ -127,99 +127,3 @@ impl Cc {
127127
self
128128
}
129129
}
130-
131-
/// `EXTRACFLAGS`
132-
pub fn extra_c_flags() -> Vec<&'static str> {
133-
// Adapted from tools.mk (trimmed):
134-
//
135-
// ```makefile
136-
// ifdef IS_WINDOWS
137-
// ifdef IS_MSVC
138-
// EXTRACFLAGS := ws2_32.lib userenv.lib advapi32.lib bcrypt.lib ntdll.lib synchronization.lib
139-
// else
140-
// EXTRACFLAGS := -lws2_32 -luserenv -lbcrypt -lntdll -lsynchronization
141-
// endif
142-
// else
143-
// ifeq ($(UNAME),Darwin)
144-
// EXTRACFLAGS := -lresolv
145-
// else
146-
// ifeq ($(UNAME),FreeBSD)
147-
// EXTRACFLAGS := -lm -lpthread -lgcc_s
148-
// else
149-
// ifeq ($(UNAME),SunOS)
150-
// EXTRACFLAGS := -lm -lpthread -lposix4 -lsocket -lresolv
151-
// else
152-
// ifeq ($(UNAME),OpenBSD)
153-
// EXTRACFLAGS := -lm -lpthread -lc++abi
154-
// else
155-
// EXTRACFLAGS := -lm -lrt -ldl -lpthread
156-
// endif
157-
// endif
158-
// endif
159-
// endif
160-
// endif
161-
// ```
162-
163-
if is_windows() {
164-
if is_msvc() {
165-
vec![
166-
"ws2_32.lib",
167-
"userenv.lib",
168-
"advapi32.lib",
169-
"bcrypt.lib",
170-
"ntdll.lib",
171-
"synchronization.lib",
172-
]
173-
} else {
174-
vec!["-lws2_32", "-luserenv", "-lbcrypt", "-lntdll", "-lsynchronization"]
175-
}
176-
} else {
177-
match uname() {
178-
n if n.contains("Darwin") => vec!["-lresolv"],
179-
n if n.contains("FreeBSD") => vec!["-lm", "-lpthread", "-lgcc_s"],
180-
n if n.contains("SunOS") => {
181-
vec!["-lm", "-lpthread", "-lposix4", "-lsocket", "-lresolv"]
182-
}
183-
n if n.contains("OpenBSD") => vec!["-lm", "-lpthread", "-lc++abi"],
184-
_ => vec!["-lm", "-lrt", "-ldl", "-lpthread"],
185-
}
186-
}
187-
}
188-
189-
/// `EXTRACXXFLAGS`
190-
pub fn extra_cxx_flags() -> Vec<&'static str> {
191-
// Adapted from tools.mk (trimmed):
192-
//
193-
// ```makefile
194-
// ifdef IS_WINDOWS
195-
// ifdef IS_MSVC
196-
// else
197-
// EXTRACXXFLAGS := -lstdc++
198-
// endif
199-
// else
200-
// ifeq ($(UNAME),Darwin)
201-
// EXTRACXXFLAGS := -lc++
202-
// else
203-
// ifeq ($(UNAME),FreeBSD)
204-
// else
205-
// ifeq ($(UNAME),SunOS)
206-
// else
207-
// ifeq ($(UNAME),OpenBSD)
208-
// else
209-
// EXTRACXXFLAGS := -lstdc++
210-
// endif
211-
// endif
212-
// endif
213-
// endif
214-
// endif
215-
// ```
216-
if is_windows() {
217-
if is_msvc() { vec![] } else { vec!["-lstdc++"] }
218-
} else {
219-
match &uname()[..] {
220-
"Darwin" => vec!["-lc++"],
221-
"FreeBSD" | "SunOS" | "OpenBSD" => vec![],
222-
_ => vec!["-lstdc++"],
223-
}
224-
}
225-
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
use crate::{is_msvc, is_windows, uname};
2+
3+
/// `EXTRACFLAGS`
4+
pub fn extra_c_flags() -> Vec<&'static str> {
5+
// Adapted from tools.mk (trimmed):
6+
//
7+
// ```makefile
8+
// ifdef IS_WINDOWS
9+
// ifdef IS_MSVC
10+
// EXTRACFLAGS := ws2_32.lib userenv.lib advapi32.lib bcrypt.lib ntdll.lib synchronization.lib
11+
// else
12+
// EXTRACFLAGS := -lws2_32 -luserenv -lbcrypt -lntdll -lsynchronization
13+
// endif
14+
// else
15+
// ifeq ($(UNAME),Darwin)
16+
// EXTRACFLAGS := -lresolv
17+
// else
18+
// ifeq ($(UNAME),FreeBSD)
19+
// EXTRACFLAGS := -lm -lpthread -lgcc_s
20+
// else
21+
// ifeq ($(UNAME),SunOS)
22+
// EXTRACFLAGS := -lm -lpthread -lposix4 -lsocket -lresolv
23+
// else
24+
// ifeq ($(UNAME),OpenBSD)
25+
// EXTRACFLAGS := -lm -lpthread -lc++abi
26+
// else
27+
// EXTRACFLAGS := -lm -lrt -ldl -lpthread
28+
// endif
29+
// endif
30+
// endif
31+
// endif
32+
// endif
33+
// ```
34+
35+
if is_windows() {
36+
if is_msvc() {
37+
vec![
38+
"ws2_32.lib",
39+
"userenv.lib",
40+
"advapi32.lib",
41+
"bcrypt.lib",
42+
"ntdll.lib",
43+
"synchronization.lib",
44+
]
45+
} else {
46+
vec!["-lws2_32", "-luserenv", "-lbcrypt", "-lntdll", "-lsynchronization"]
47+
}
48+
} else {
49+
match uname() {
50+
n if n.contains("Darwin") => vec!["-lresolv"],
51+
n if n.contains("FreeBSD") => vec!["-lm", "-lpthread", "-lgcc_s"],
52+
n if n.contains("SunOS") => {
53+
vec!["-lm", "-lpthread", "-lposix4", "-lsocket", "-lresolv"]
54+
}
55+
n if n.contains("OpenBSD") => vec!["-lm", "-lpthread", "-lc++abi"],
56+
_ => vec!["-lm", "-lrt", "-ldl", "-lpthread"],
57+
}
58+
}
59+
}
60+
61+
/// `EXTRACXXFLAGS`
62+
pub fn extra_cxx_flags() -> Vec<&'static str> {
63+
// Adapted from tools.mk (trimmed):
64+
//
65+
// ```makefile
66+
// ifdef IS_WINDOWS
67+
// ifdef IS_MSVC
68+
// else
69+
// EXTRACXXFLAGS := -lstdc++
70+
// endif
71+
// else
72+
// ifeq ($(UNAME),Darwin)
73+
// EXTRACXXFLAGS := -lc++
74+
// else
75+
// ifeq ($(UNAME),FreeBSD)
76+
// else
77+
// ifeq ($(UNAME),SunOS)
78+
// else
79+
// ifeq ($(UNAME),OpenBSD)
80+
// else
81+
// EXTRACXXFLAGS := -lstdc++
82+
// endif
83+
// endif
84+
// endif
85+
// endif
86+
// endif
87+
// ```
88+
if is_windows() {
89+
if is_msvc() { vec![] } else { vec!["-lstdc++"] }
90+
} else {
91+
match &uname()[..] {
92+
"Darwin" => vec!["-lc++"],
93+
"FreeBSD" | "SunOS" | "OpenBSD" => vec![],
94+
_ => vec!["-lstdc++"],
95+
}
96+
}
97+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
use std::path::Path;
2+
3+
use crate::command::Command;
4+
5+
/// Construct a gcc invocation.
6+
///
7+
/// WARNING: This assumes *a* `gcc` exists in the environment and is suitable for use.
8+
#[track_caller]
9+
pub fn gcc() -> Gcc {
10+
Gcc::new()
11+
}
12+
13+
/// A specific `gcc`.
14+
#[derive(Debug)]
15+
#[must_use]
16+
pub struct Gcc {
17+
cmd: Command,
18+
}
19+
20+
crate::macros::impl_common_helpers!(Gcc);
21+
22+
impl Gcc {
23+
/// Construct a `gcc` invocation. This assumes that *a* suitable `gcc` is available in the
24+
/// environment.
25+
///
26+
/// Note that this does **not** prepopulate the `gcc` invocation with `CC_DEFAULT_FLAGS`.
27+
#[track_caller]
28+
pub fn new() -> Self {
29+
let cmd = Command::new("gcc");
30+
Self { cmd }
31+
}
32+
33+
/// Specify path of the input file.
34+
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
35+
self.cmd.arg(path.as_ref());
36+
self
37+
}
38+
39+
/// Adds directories to the list that the linker searches for libraries.
40+
/// Equivalent to `-L`.
41+
pub fn library_search_path<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
42+
self.cmd.arg("-L");
43+
self.cmd.arg(path.as_ref());
44+
self
45+
}
46+
47+
/// Specify `-o`.
48+
pub fn out_exe(&mut self, name: &str) -> &mut Self {
49+
self.cmd.arg("-o");
50+
self.cmd.arg(name);
51+
self
52+
}
53+
54+
/// Specify path of the output binary.
55+
pub fn output<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
56+
self.cmd.arg("-o");
57+
self.cmd.arg(path.as_ref());
58+
self
59+
}
60+
61+
/// Optimize the output at `-O3`.
62+
pub fn optimize(&mut self) -> &mut Self {
63+
self.cmd.arg("-O3");
64+
self
65+
}
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
mod cc;
2+
mod extras;
3+
mod gcc;
4+
5+
pub use cc::*;
6+
pub use extras::*;
7+
pub use gcc::*;

src/tools/run-make-support/src/external_deps/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//! such as `cc` or `python`.
33
44
pub mod c_build;
5+
pub mod c_cxx_compiler;
56
pub mod cargo;
6-
pub mod cc;
77
pub mod clang;
88
pub mod htmldocck;
99
pub mod llvm;

src/tools/run-make-support/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ pub use wasmparser;
4646
// tidy-alphabetical-end
4747

4848
// Re-exports of external dependencies.
49-
pub use external_deps::{c_build, cc, clang, htmldocck, llvm, python, rustc, rustdoc};
49+
pub use external_deps::{c_build, c_cxx_compiler, clang, htmldocck, llvm, python, rustc, rustdoc};
5050

5151
// These rely on external dependencies.
52-
pub use cc::{cc, cxx, extra_c_flags, extra_cxx_flags, Cc};
52+
pub use c_cxx_compiler::{Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, gcc};
5353
pub use c_build::{
5454
build_native_dynamic_lib, build_native_static_lib, build_native_static_lib_cxx,
5555
build_native_static_lib_optimized,

tests/run-make/mte-ffi/rmake.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
// Tests that MTE tags and values stored in the top byte of a pointer (TBI) are
2-
// preserved across FFI boundaries (C <-> Rust).
3-
// This test does not require MTE: whilst the test will use MTE if available, if it is not,
4-
// arbitrary tag bits are set using TBI.
1+
//! Tests that MTE tags and values stored in the top byte of a pointer (TBI) are preserved across
2+
//! FFI boundaries (C <-> Rust). This test does not require MTE: whilst the test will use MTE if
3+
//! available, if it is not, arbitrary tag bits are set using TBI.
54
6-
// This test is only valid for AArch64.
7-
// The linker must be explicitly specified when cross-compiling, so it is limited to
8-
// `aarch64-unknown-linux-gnu`.
95
//@ only-aarch64-unknown-linux-gnu
6+
// Reason: this test is only valid for AArch64 with `gcc`. The linker must be explicitly specified
7+
// when cross-compiling, so it is limited to `aarch64-unknown-linux-gnu`.
108

11-
use run_make_support::{cc, dynamic_lib_name, extra_c_flags, run, rustc, target};
9+
use run_make_support::{dynamic_lib_name, extra_c_flags, gcc, run, rustc, target};
1210

1311
fn main() {
1412
run_test("int");
@@ -29,7 +27,8 @@ fn run_test(variant: &str) {
2927
.target(target())
3028
.linker("aarch64-linux-gnu-gcc")
3129
.run();
32-
cc().input(format!("bar_{variant}.c"))
30+
gcc()
31+
.input(format!("bar_{variant}.c"))
3332
.input(dynamic_lib_name("foo"))
3433
.out_exe("test")
3534
.args(&flags)

0 commit comments

Comments
 (0)