diff options
| author | bors <bors@rust-lang.org> | 2024-03-31 08:12:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-31 08:12:02 +0000 |
| commit | ff20a442cee8e812d293a7c7ae5296ff708d2742 (patch) | |
| tree | af983cb8ed58686673cdef0f98f811f3cf0a11c2 | |
| parent | d5de305fef8065d3af726537db2513a884ed2bcc (diff) | |
| parent | 38780aa5a420c301b94345cfc372d8463ce46711 (diff) | |
| download | rust-ff20a442cee8e812d293a7c7ae5296ff708d2742.tar.gz rust-ff20a442cee8e812d293a7c7ae5296ff708d2742.zip | |
Auto merge of #3437 - RalfJung:extern-so, r=RalfJung
extern-so: give the version script a better name; show errors from failing to build the C lib
| -rw-r--r-- | src/tools/miri/tests/extern-so/libcode.version | 9 | ||||
| -rw-r--r-- | src/tools/miri/tests/extern-so/libtest.map | 12 | ||||
| -rw-r--r-- | src/tools/miri/tests/ui.rs | 20 |
3 files changed, 24 insertions, 17 deletions
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 0f04b9aaebb..00000000000 --- 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 00000000000..a57a4dc149f --- /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 a75fa4cf986..7e8d1401183 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()); |
