Skip to content

Commit 2eb8531

Browse files
committed
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
2 parents 75b9935 + 975926e commit 2eb8531

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

tests/extern-so/libcode.version

-9
This file was deleted.

tests/extern-so/libtest.map

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CODEABI_1.0 {
2+
# Define which symbols to export.
3+
global:
4+
add_one_int;
5+
printer;
6+
test_stack_spill;
7+
get_unsigned_int;
8+
add_int16;
9+
add_short_to_long;
10+
# The rest remains private.
11+
local: *;
12+
};

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)