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 2013bf9

Browse files
authoredJul 18, 2024
Rollup merge of #127787 - Rejyr:migrate-atomic-lock-free-rmake, r=jieyouxu
Migrate `atomic-lock-free` to `rmake` Also adds `llvm_components_contain` to `run-make-support`. Part of #121876. r? ``@jieyouxu`` try-job: dist-x86_64-linux
2 parents 97d5edf + a8b6e3f commit 2013bf9

File tree

5 files changed

+60
-50
lines changed

5 files changed

+60
-50
lines changed
 

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub use env::{env_var, env_var_os};
6161
pub use run::{cmd, run, run_fail, run_with_args};
6262

6363
/// Helpers for checking target information.
64-
pub use targets::{is_darwin, is_msvc, is_windows, target, uname};
64+
pub use targets::{is_darwin, is_msvc, is_windows, llvm_components_contain, target, uname};
6565

6666
/// Helpers for building names of output artifacts that are potentially target-specific.
6767
pub use artifact_names::{

‎src/tools/run-make-support/src/targets.rs

+7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ pub fn is_darwin() -> bool {
2828
target().contains("darwin")
2929
}
3030

31+
/// Check if `component` is within `LLVM_COMPONENTS`
32+
#[must_use]
33+
pub fn llvm_components_contain(component: &str) -> bool {
34+
// `LLVM_COMPONENTS` is a space-separated list of words
35+
env_var("LLVM_COMPONENTS").split_whitespace().find(|s| s == &component).is_some()
36+
}
37+
3138
/// Run `uname`. This assumes that `uname` is available on the platform!
3239
#[track_caller]
3340
#[must_use]

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
run-make/archive-duplicate-names/Makefile
2-
run-make/atomic-lock-free/Makefile
32
run-make/branch-protection-check-IBT/Makefile
43
run-make/c-dynamic-dylib/Makefile
54
run-make/c-dynamic-rlib/Makefile

‎tests/run-make/atomic-lock-free/Makefile

-48
This file was deleted.
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// This tests ensure that atomic types are never lowered into runtime library calls that are not
2+
// guaranteed to be lock-free.
3+
4+
//@ only-linux
5+
6+
use run_make_support::{llvm_components_contain, llvm_readobj, rustc};
7+
8+
fn compile(target: &str) {
9+
rustc().input("atomic_lock_free.rs").target(target).run();
10+
}
11+
12+
fn check() {
13+
llvm_readobj()
14+
.symbols()
15+
.input("libatomic_lock_free.rlib")
16+
.run()
17+
.assert_stdout_not_contains("__atomic_fetch_add");
18+
}
19+
20+
fn compile_and_check(target: &str) {
21+
compile(target);
22+
check();
23+
}
24+
25+
fn main() {
26+
if llvm_components_contain("x86") {
27+
compile_and_check("i686-unknown-linux-gnu");
28+
compile_and_check("x86_64-unknown-linux-gnu");
29+
}
30+
if llvm_components_contain("arm") {
31+
compile_and_check("arm-unknown-linux-gnueabi");
32+
compile_and_check("arm-unknown-linux-gnueabihf");
33+
compile_and_check("armv7-unknown-linux-gnueabihf");
34+
compile_and_check("thumbv7neon-unknown-linux-gnueabihf");
35+
}
36+
if llvm_components_contain("aarch64") {
37+
compile_and_check("aarch64-unknown-linux-gnu");
38+
}
39+
if llvm_components_contain("mips") {
40+
compile_and_check("mips-unknown-linux-gnu");
41+
compile_and_check("mipsel-unknown-linux-gnu");
42+
}
43+
if llvm_components_contain("powerpc") {
44+
compile_and_check("powerpc-unknown-linux-gnu");
45+
compile_and_check("powerpc-unknown-linux-gnuspe");
46+
compile_and_check("powerpc64-unknown-linux-gnu");
47+
compile_and_check("powerpc64le-unknown-linux-gnu");
48+
}
49+
if llvm_components_contain("systemz") {
50+
compile_and_check("s390x-unknown-linux-gnu");
51+
}
52+
}

0 commit comments

Comments
 (0)
Failed to load comments.