Skip to content

Commit

Permalink
rewrite extern-fn-mangle to rmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Jul 12, 2024
1 parent 5940fa4 commit 89c1b4a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,18 @@ pub fn count_regex_matches_in_files_with_extension(re: &regex::Regex, ext: &str)
/// Builds a static lib (`.lib` on Windows MSVC and `.a` for the rest) with the given name.
#[track_caller]
pub fn build_native_static_lib(lib_name: &str) -> PathBuf {
let mut obj_file = format!("{lib_name}.o");
let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
let src = format!("{lib_name}.c");
let lib_path = static_lib_name(lib_name);
if is_msvc() {
cc().arg("-c").out_exe(&obj_file).input(src).run();
} else {
cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run();
};
let mut obj_file = PathBuf::from(format!("{lib_name}.o"));
if is_msvc() {
obj_file = format!("{obj_file}.obj");
obj_file.set_extension("");
obj_file.set_extension("obj");
}
ar(&[obj_file], &lib_path);
path(lib_path)
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ run-make/export-executable-symbols/Makefile
run-make/extern-diff-internal-name/Makefile
run-make/extern-flag-disambiguates/Makefile
run-make/extern-fn-generic/Makefile
run-make/extern-fn-mangle/Makefile
run-make/extern-fn-reachable/Makefile
run-make/extern-fn-with-union/Makefile
run-make/extern-multiple-copies/Makefile
Expand Down
6 changes: 0 additions & 6 deletions tests/run-make/extern-fn-mangle/Makefile

This file was deleted.

16 changes: 16 additions & 0 deletions tests/run-make/extern-fn-mangle/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// In this test, the functions foo() and bar() must avoid being mangled, as
// the external C function depends on them to return the correct sum of 3 + 5 = 8.
// This test therefore checks that the compiled and executed program respects the
// #[no_mangle] flags successfully.
// See https://github.com/rust-lang/rust/pull/15831

//@ ignore-cross-compile
// Reason: the compiled binary is executed

use run_make_support::{build_native_static_lib, run, rustc};

fn main() {
build_native_static_lib("test");
rustc().input("test.rs").run();
run("test");
}

0 comments on commit 89c1b4a

Please sign in to comment.