Skip to content

Commit 3281060

Browse files
committed
Add simple regression test for --print=native-static-libs
1 parent 701bf2d commit 3281060

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

Diff for: tests/run-make/print-native-static-libs/Makefile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
include ../tools.mk
2+
3+
# ignore-cross-compile
4+
# ignore-wasm
5+
6+
all:
7+
$(RUSTC) --crate-type rlib -lbar_cli bar.rs
8+
$(RUSTC) foo.rs -lfoo_cli --crate-type staticlib --print native-static-libs 2>&1 \
9+
| grep 'note: native-static-libs: ' \
10+
| sed 's/note: native-static-libs: \(.*\)/\1/' > $(TMPDIR)/libs.txt
11+
12+
cat $(TMPDIR)/libs.txt | grep -F "glib-2.0" # in bar.rs
13+
cat $(TMPDIR)/libs.txt | grep -F "systemd" # in foo.rs
14+
cat $(TMPDIR)/libs.txt | grep -F "bar_cli"
15+
cat $(TMPDIR)/libs.txt | grep -F "foo_cli"

Diff for: tests/run-make/print-native-static-libs/bar.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#[no_mangle]
2+
pub extern "C" fn my_bar_add(left: i32, right: i32) -> i32 {
3+
// Obviously makes no sense but...
4+
unsafe {
5+
g_free(std::ptr::null_mut());
6+
}
7+
left + right
8+
}
9+
10+
#[link(name = "glib-2.0")]
11+
extern "C" {
12+
fn g_free(p: *mut ());
13+
}

Diff for: tests/run-make/print-native-static-libs/foo.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
extern crate bar;
2+
3+
#[no_mangle]
4+
pub extern "C" fn my_foo_add(left: i32, right: i32) -> i32 {
5+
// Obviously makes no sense but...
6+
unsafe {
7+
init(std::ptr::null_mut());
8+
}
9+
bar::my_bar_add(left, right)
10+
}
11+
12+
#[link(name = "systemd")]
13+
extern "C" {
14+
fn init(p: *mut ());
15+
}

0 commit comments

Comments
 (0)