Skip to content

Commit 89c1b4a

Browse files
committed
rewrite extern-fn-mangle to rmake
1 parent 5940fa4 commit 89c1b4a

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -320,16 +320,18 @@ pub fn count_regex_matches_in_files_with_extension(re: &regex::Regex, ext: &str)
320320
/// Builds a static lib (`.lib` on Windows MSVC and `.a` for the rest) with the given name.
321321
#[track_caller]
322322
pub fn build_native_static_lib(lib_name: &str) -> PathBuf {
323-
let mut obj_file = format!("{lib_name}.o");
323+
let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
324324
let src = format!("{lib_name}.c");
325325
let lib_path = static_lib_name(lib_name);
326326
if is_msvc() {
327327
cc().arg("-c").out_exe(&obj_file).input(src).run();
328328
} else {
329329
cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run();
330330
};
331+
let mut obj_file = PathBuf::from(format!("{lib_name}.o"));
331332
if is_msvc() {
332-
obj_file = format!("{obj_file}.obj");
333+
obj_file.set_extension("");
334+
obj_file.set_extension("obj");
333335
}
334336
ar(&[obj_file], &lib_path);
335337
path(lib_path)

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ run-make/export-executable-symbols/Makefile
2828
run-make/extern-diff-internal-name/Makefile
2929
run-make/extern-flag-disambiguates/Makefile
3030
run-make/extern-fn-generic/Makefile
31-
run-make/extern-fn-mangle/Makefile
3231
run-make/extern-fn-reachable/Makefile
3332
run-make/extern-fn-with-union/Makefile
3433
run-make/extern-multiple-copies/Makefile

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

-6
This file was deleted.
+16
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)