Skip to content

Commit 8999ce4

Browse files
committed
extern-so: give the version script a better name; show errors from failing to build the C lib
1 parent 75b9935 commit 8999ce4

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
CODEABI_1.0 {
2+
# Define which symbols to export.
23
global: *add_one_int*;
34
*printer*;
45
*test_stack_spill*;
56
*get_unsigned_int*;
67
*add_int16*;
78
*add_short_to_long*;
9+
# The rest remains private.
810
local: *;
911
};

tests/ui.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use colored::*;
2-
use regex::bytes::Regex;
31
use std::ffi::OsString;
42
use std::num::NonZeroUsize;
53
use std::path::{Path, PathBuf};
64
use std::{env, process::Command};
5+
6+
use colored::*;
7+
use regex::bytes::Regex;
78
use ui_test::color_eyre::eyre::{Context, Result};
89
use ui_test::{
910
status_emitter, CommandBuilder, Config, Format, Match, Mode, OutputConflictHandling,
@@ -44,12 +45,15 @@ fn build_so_for_c_ffi_tests() -> PathBuf {
4445
// This is to avoid automatically adding `malloc`, etc.
4546
// Source: https://anadoxin.org/blog/control-over-symbol-exports-in-gcc.html/
4647
"-fPIC",
47-
"-Wl,--version-script=tests/extern-so/libcode.version",
48+
"-Wl,--version-script=tests/extern-so/libtest.map",
4849
])
4950
.output()
5051
.expect("failed to generate shared object file for testing external C function calls");
5152
if !cc_output.status.success() {
52-
panic!("error in generating shared object file for testing external C function calls");
53+
panic!(
54+
"error in generating shared object file for testing external C function calls:\n{}",
55+
String::from_utf8_lossy(&cc_output.stderr),
56+
);
5357
}
5458
so_file_path
5559
}
@@ -120,10 +124,10 @@ fn run_tests(
120124
config.program.args.push("--target".into());
121125
config.program.args.push(target.into());
122126

123-
// If we're on linux, and we're testing the extern-so functionality,
124-
// then build the shared object file for testing external C function calls
125-
// and push the relevant compiler flag.
126-
if cfg!(target_os = "linux") && path.starts_with("tests/extern-so/") {
127+
// If we're testing the extern-so functionality, then build the shared object file for testing
128+
// external C function calls and push the relevant compiler flag.
129+
if path.starts_with("tests/extern-so/") {
130+
assert!(cfg!(target_os = "linux"));
127131
let so_file_path = build_so_for_c_ffi_tests();
128132
let mut flag = std::ffi::OsString::from("-Zmiri-extern-so-file=");
129133
flag.push(so_file_path.into_os_string());

0 commit comments

Comments
 (0)