diff --git a/src/tools/miri/tests/extern-so/libcode.version b/src/tools/miri/tests/extern-so/libcode.version deleted file mode 100644 index 0f04b9aaebb3..000000000000 --- a/src/tools/miri/tests/extern-so/libcode.version +++ /dev/null @@ -1,9 +0,0 @@ -CODEABI_1.0 { - global: *add_one_int*; - *printer*; - *test_stack_spill*; - *get_unsigned_int*; - *add_int16*; - *add_short_to_long*; - local: *; -}; diff --git a/src/tools/miri/tests/extern-so/libtest.map b/src/tools/miri/tests/extern-so/libtest.map new file mode 100644 index 000000000000..a57a4dc149fe --- /dev/null +++ b/src/tools/miri/tests/extern-so/libtest.map @@ -0,0 +1,12 @@ +CODEABI_1.0 { + # Define which symbols to export. + global: + add_one_int; + printer; + test_stack_spill; + get_unsigned_int; + add_int16; + add_short_to_long; + # The rest remains private. + local: *; +}; diff --git a/src/tools/miri/tests/ui.rs b/src/tools/miri/tests/ui.rs index a75fa4cf986d..7e8d1401183b 100644 --- a/src/tools/miri/tests/ui.rs +++ b/src/tools/miri/tests/ui.rs @@ -1,9 +1,10 @@ -use colored::*; -use regex::bytes::Regex; use std::ffi::OsString; use std::num::NonZeroUsize; use std::path::{Path, PathBuf}; use std::{env, process::Command}; + +use colored::*; +use regex::bytes::Regex; use ui_test::color_eyre::eyre::{Context, Result}; use ui_test::{ status_emitter, CommandBuilder, Config, Format, Match, Mode, OutputConflictHandling, @@ -44,12 +45,15 @@ fn build_so_for_c_ffi_tests() -> PathBuf { // This is to avoid automatically adding `malloc`, etc. // Source: https://anadoxin.org/blog/control-over-symbol-exports-in-gcc.html/ "-fPIC", - "-Wl,--version-script=tests/extern-so/libcode.version", + "-Wl,--version-script=tests/extern-so/libtest.map", ]) .output() .expect("failed to generate shared object file for testing external C function calls"); if !cc_output.status.success() { - panic!("error in generating shared object file for testing external C function calls"); + panic!( + "error in generating shared object file for testing external C function calls:\n{}", + String::from_utf8_lossy(&cc_output.stderr), + ); } so_file_path } @@ -120,10 +124,10 @@ fn run_tests( config.program.args.push("--target".into()); config.program.args.push(target.into()); - // If we're on linux, and we're testing the extern-so functionality, - // then build the shared object file for testing external C function calls - // and push the relevant compiler flag. - if cfg!(target_os = "linux") && path.starts_with("tests/extern-so/") { + // If we're testing the extern-so functionality, then build the shared object file for testing + // external C function calls and push the relevant compiler flag. + if path.starts_with("tests/extern-so/") { + assert!(cfg!(target_os = "linux")); let so_file_path = build_so_for_c_ffi_tests(); let mut flag = std::ffi::OsString::from("-Zmiri-extern-so-file="); flag.push(so_file_path.into_os_string());