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 2f31447

Browse files
committedJul 17, 2024·
rewrite linkage-attr-on-static to rmake
1 parent 862e782 commit 2f31447

File tree

5 files changed

+20
-39
lines changed

5 files changed

+20
-39
lines changed
 

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

+5-25
Original file line numberDiff line numberDiff line change
@@ -281,26 +281,6 @@ pub fn not_contains<P: AsRef<Path>>(path: P, expected: &str) -> bool {
281281
!path.as_ref().file_name().is_some_and(|name| name.to_str().unwrap().contains(expected))
282282
}
283283

284-
/// Builds a static lib (`.lib` on Windows MSVC and `.a` for the rest) with the given name.
285-
#[track_caller]
286-
pub fn build_native_static_lib(lib_name: &str) -> PathBuf {
287-
let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
288-
let src = format!("{lib_name}.c");
289-
let lib_path = static_lib_name(lib_name);
290-
if is_msvc() {
291-
cc().arg("-c").out_exe(&obj_file).input(src).run();
292-
} else {
293-
cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run();
294-
};
295-
let obj_file = if is_msvc() {
296-
PathBuf::from(format!("{lib_name}.obj"))
297-
} else {
298-
PathBuf::from(format!("{lib_name}.o"))
299-
};
300-
llvm_ar().obj_to_ar().output_input(&lib_path, &obj_file).run();
301-
path(lib_path)
302-
}
303-
304284
/// Returns true if the filename at `path` is not in `expected`.
305285
pub fn filename_not_in_denylist<P: AsRef<Path>, V: AsRef<[String]>>(path: P, expected: V) -> bool {
306286
let expected = expected.as_ref();
@@ -339,11 +319,11 @@ pub fn build_native_static_lib(lib_name: &str) -> PathBuf {
339319
} else {
340320
cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run();
341321
};
342-
let mut obj_file = PathBuf::from(format!("{lib_name}.o"));
343-
if is_msvc() {
344-
obj_file.set_extension("");
345-
obj_file.set_extension("obj");
346-
}
322+
let obj_file = if is_msvc() {
323+
PathBuf::from(format!("{lib_name}.obj"))
324+
} else {
325+
PathBuf::from(format!("{lib_name}.o"))
326+
};
347327
llvm_ar().obj_to_ar().output_input(&lib_path, &obj_file).run();
348328
path(lib_path)
349329
}

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

-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ run-make/libtest-thread-limit/Makefile
6060
run-make/link-cfg/Makefile
6161
run-make/link-framework/Makefile
6262
run-make/link-path-order/Makefile
63-
run-make/linkage-attr-on-static/Makefile
6463
run-make/long-linker-command-lines-cmd-exe/Makefile
6564
run-make/long-linker-command-lines/Makefile
6665
run-make/longjmp-across-rust/Makefile
@@ -93,7 +92,6 @@ run-make/redundant-libs/Makefile
9392
run-make/remap-path-prefix-dwarf/Makefile
9493
run-make/reproducible-build-2/Makefile
9594
run-make/reproducible-build/Makefile
96-
run-make/return-non-c-like-enum-from-c/Makefile
9795
run-make/rlib-format-packed-bundled-libs-2/Makefile
9896
run-make/rlib-format-packed-bundled-libs-3/Makefile
9997
run-make/rlib-format-packed-bundled-libs/Makefile

‎tests/run-make/linkage-attr-on-static/Makefile

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// #[linkage] is a useful attribute which can be applied to statics to allow
2+
// external linkage, something which was not possible before #18890. This test
3+
// checks that using this new feature results in successful compilation and execution.
4+
// See https://github.com/rust-lang/rust/pull/18890
5+
6+
//@ ignore-cross-compile
7+
// Reason: the compiled binary is executed
8+
9+
use run_make_support::{build_native_static_lib, run, rustc};
10+
11+
fn main() {
12+
build_native_static_lib("foo");
13+
rustc().input("bar.rs").run();
14+
run("bar");
15+
}

‎tests/run-make/pass-non-c-like-enum-to-c/Makefile

-6
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.