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 db1a6e7

Browse files
committedJul 16, 2024
Auto merge of #127787 - Rejyr:migrate-atomic-lock-free-rmake, r=<try>
Migrate `atomic-lock-free` to `rmake` Also adds `is_linux` and `llvm_components_contain` to `run-make-support`. Part of #121876. r? `@jieyouxu` try-job: dist-x86_64-linux
2 parents 5c84886 + 7519704 commit db1a6e7

File tree

4 files changed

+65
-49
lines changed

4 files changed

+65
-49
lines changed
 

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

+13
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ pub fn ar(inputs: &[impl AsRef<Path>], output_path: impl AsRef<Path>) {
7474
}
7575
}
7676

77+
/// Check if target is linux-like.
78+
#[must_use]
79+
pub fn is_linux() -> bool {
80+
target().contains("linux")
81+
}
82+
7783
/// Check if target is windows-like.
7884
#[must_use]
7985
pub fn is_windows() -> bool {
@@ -92,6 +98,13 @@ pub fn is_darwin() -> bool {
9298
target().contains("darwin")
9399
}
94100

101+
/// Check if `component` is within `LLVM_COMPONENTS`
102+
#[must_use]
103+
pub fn llvm_components_contain(component: &str) -> bool {
104+
// `LLVM_COMPONENTS` is a space-separated list of words
105+
env_var("LLVM_COMPONENTS").split_whitespace().find(|s| s == &component).is_some()
106+
}
107+
95108
#[track_caller]
96109
#[must_use]
97110
pub fn python_command() -> Command {

‎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+
use run_make_support::{is_linux, llvm_components_contain, llvm_readobj, rustc};
5+
6+
fn compile(target: &str) {
7+
rustc().input("atomic_lock_free.rs").target(target).run();
8+
}
9+
10+
fn check() {
11+
llvm_readobj()
12+
.symbols()
13+
.input("libatomic_lock_free.rlib")
14+
.run()
15+
.assert_stdout_not_contains("__atomic_fetch_add");
16+
}
17+
18+
fn compile_and_check(target: &str) {
19+
compile(target);
20+
check();
21+
}
22+
23+
fn main() {
24+
if is_linux() {
25+
if llvm_components_contain("x86") {
26+
compile_and_check("i686-unknown-linux-gnu");
27+
compile_and_check("x86_64-unknown-linux-gnu");
28+
}
29+
if llvm_components_contain("arm") {
30+
compile_and_check("arm-unknown-linux-gnueabi");
31+
compile_and_check("arm-unknown-linux-gnueabihf");
32+
compile_and_check("armv7-unknown-linux-gnueabihf");
33+
compile_and_check("thumbv7neon-unknown-linux-gnueabihf");
34+
}
35+
if llvm_components_contain("aarch64") {
36+
compile_and_check("aarch64-unknown-linux-gnu");
37+
}
38+
if llvm_components_contain("mips") {
39+
compile_and_check("mips-unknown-linux-gnu");
40+
compile_and_check("mipsel-unknown-linux-gnu");
41+
}
42+
if llvm_components_contain("powerpc") {
43+
compile_and_check("powerpc-unknown-linux-gnu");
44+
compile_and_check("powerpc-unknown-linux-gnuspe");
45+
compile_and_check("powerpc64-unknown-linux-gnu");
46+
compile_and_check("powerpc64le-unknown-linux-gnu");
47+
}
48+
if llvm_components_contain("systemz") {
49+
compile_and_check("s390x-unknown-linux-gnu");
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)
Failed to load comments.