-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
+whole-archive link modifier not behaving as expected on macOS #110624
Comments
@rustbot label +A-linkage |
I think I'm seeing the same thing on Linux.
Strangely enough, I can get the symbol to show up if I add a #[link(name = "p", kind = "static", modifiers = "+whole-archive")]
extern "C" {
#[no_mangle]
pub fn add(a: u32, b: u32) -> u32;
} |
I didn't check what happens in the examples in detail, but it's possible that linker throws away individual symbols due to Some attributes like |
The
|
I think I'm seeing this on linux - it appears to be because the linker version script looks like:
If I save my linker invocation and temporaries with |
Are you using |
I think what's described in this issue is that we want i.e.
In the OP that's being done via a build script whereas I have the annotations on an empty extern block, but we're trying to do the same thing.
If rustc won't support this, I think I have two options:
|
Ah but of course, with option 2 I'm hitting the warning in #110624 (comment) because I have to put Demo repo https://github.com/aidanhs/rust-re-export-lib/ Semi related #73958 which talks about no_mangle visibility. |
|
Unfortunately the repo above seems to demonstrate otherwise? At least on Linux (which matches up with what the other people in this issue have found). |
The |
The whole-archive mention in that changelog seems to specifically be referring to something that was happening with tests - I don't think that's related to this issue. |
I'm trying to link a C static lib to a rust cdylib using the
+whole-archive
link modifier in order to expose the library symbols from the generated dylib, but they do not show up in the final library. A minimal example is as follows:static.c
compiled using:
lib.rs
build.rs
Cargo..toml
I expected to see this happen:
I expected to be able to see the static lib symbols in the
dylib
, as I can when linking the same lib to a C dylib generated by gcc:dynamic.c
compiled using:
Symbols listed
nm -g libdynamic.dylib
:Instead, this happened:
Instead, I cannot find the static lib symbols in the generated dylib
nm -g target/debug/librust.dylib
:Meta
rustc --version --verbose
:Backtrace
Linker info:
The text was updated successfully, but these errors were encountered: