-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #111675 - Urgau:fix-local-libs-for-native-static-libs, …
…r=bjorn3 Fix local libs not included when printing native static libs This PR fixes #111643 by adding the local used libs to the printed `--print=native-static-libs` output. It seems that `--print=native-static-libs` doesn't have any test, so I added one. It's very simple and doesn't even tries to compile the result to a binary as I don't know how to handle external library linking in CI. (Note that https://github.com/rust-lang/rust/blob/master/tests/run-make/staticlib-dylib-linkage/Makefile does compile to a binary) r? `@bjorn3`
- Loading branch information
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
include ../tools.mk | ||
|
||
# ignore-cross-compile | ||
# ignore-wasm | ||
|
||
all: | ||
$(RUSTC) --crate-type rlib -lbar_cli bar.rs | ||
$(RUSTC) foo.rs -lfoo_cli --crate-type staticlib --print native-static-libs 2>&1 \ | ||
| grep 'note: native-static-libs: ' \ | ||
| sed 's/note: native-static-libs: \(.*\)/\1/' > $(TMPDIR)/libs.txt | ||
|
||
cat $(TMPDIR)/libs.txt | grep -F "glib-2.0" # in bar.rs | ||
cat $(TMPDIR)/libs.txt | grep -F "systemd" # in foo.rs | ||
cat $(TMPDIR)/libs.txt | grep -F "bar_cli" | ||
cat $(TMPDIR)/libs.txt | grep -F "foo_cli" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#[no_mangle] | ||
pub extern "C" fn my_bar_add(left: i32, right: i32) -> i32 { | ||
// Obviously makes no sense but... | ||
unsafe { | ||
g_free(std::ptr::null_mut()); | ||
} | ||
left + right | ||
} | ||
|
||
#[link(name = "glib-2.0")] | ||
extern "C" { | ||
fn g_free(p: *mut ()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
extern crate bar; | ||
|
||
#[no_mangle] | ||
pub extern "C" fn my_foo_add(left: i32, right: i32) -> i32 { | ||
// Obviously makes no sense but... | ||
unsafe { | ||
init(std::ptr::null_mut()); | ||
} | ||
bar::my_bar_add(left, right) | ||
} | ||
|
||
#[link(name = "systemd")] | ||
extern "C" { | ||
fn init(p: *mut ()); | ||
} |