Skip to content

Commit 10b9533

Browse files
committed
rewrite extern-fn-mangle to rmake
1 parent eaaa180 commit 10b9533

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,18 @@ pub fn count_regex_matches_in_files_with_extension(re: &regex::Regex, ext: &str)
331331
/// Builds a static lib (`.lib` on Windows MSVC and `.a` for the rest) with the given name.
332332
#[track_caller]
333333
pub fn build_native_static_lib(lib_name: &str) -> PathBuf {
334-
let mut obj_file = format!("{lib_name}.o");
334+
let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
335335
let src = format!("{lib_name}.c");
336336
let lib_path = static_lib_name(lib_name);
337337
if is_msvc() {
338338
cc().arg("-c").out_exe(&obj_file).input(src).run();
339339
} else {
340340
cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run();
341341
};
342+
let mut obj_file = PathBuf::from(format!("{lib_name}.o"));
342343
if is_msvc() {
343-
obj_file = format!("{obj_file}.obj");
344+
obj_file.set_extension("");
345+
obj_file.set_extension("obj");
344346
}
345347
ar(&[obj_file], &lib_path);
346348
path(lib_path)

src/tools/tidy/src/allowed_run_make_makefiles.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ run-make/export-executable-symbols/Makefile
2525
run-make/extern-diff-internal-name/Makefile
2626
run-make/extern-flag-disambiguates/Makefile
2727
run-make/extern-fn-generic/Makefile
28-
run-make/extern-fn-mangle/Makefile
2928
run-make/extern-fn-reachable/Makefile
3029
run-make/extern-fn-with-union/Makefile
3130
run-make/extern-multiple-copies/Makefile

tests/run-make/extern-fn-mangle/Makefile

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// In this test, the functions foo() and bar() must avoid being mangled, as
2+
// the external C function depends on them to return the correct sum of 3 + 5 = 8.
3+
// This test therefore checks that the compiled and executed program respects the
4+
// #[no_mangle] flags successfully.
5+
// See https://github.com/rust-lang/rust/pull/15831
6+
7+
//@ ignore-cross-compile
8+
// Reason: the compiled binary is executed
9+
10+
use run_make_support::{build_native_static_lib, run, rustc};
11+
12+
fn main() {
13+
build_native_static_lib("test");
14+
rustc().input("test.rs").run();
15+
run("test");
16+
}

0 commit comments

Comments
 (0)