Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

elmarco
Copy link
Contributor

@elmarco elmarco commented Sep 3, 2025

rustc --crate-type staticlib --print native-static-libs doesn't print
the default libraries being linked with rustc by default, at least not
with rustc 1.89.0 (29483883e 2025-08-04).

Stripping those by default, such as ws2_32 on win32, prevents from
linking programs using sockets (ex qemu).

@bonzini @xclaesse

Signed-off-by: Marc-André Lureau <[email protected]>
`rustc --crate-type staticlib --print native-static-libs` doesn't print
the default libraries being linked with rustc by default, at least not
with rustc 1.89.0 (29483883e 2025-08-04).

Stripping those by default, such as ws2_32 on win32, prevents from
linking programs using sockets (ex qemu).

Signed-off-by: Marc-André Lureau <[email protected]>
@elmarco elmarco requested a review from jpakkane as a code owner September 3, 2025 11:51
@elmarco
Copy link
Contributor Author

elmarco commented Sep 12, 2025

it's actually more subtle than that, it seems to be due to the order of arguments, but I don't yet have a good reproducer.

@bonzini, you can easily reproduce with qemu --cross-prefix=x86_64-w64-mingw32- --enable-rust on fedora.

@bonzini
Copy link
Collaborator

bonzini commented Sep 12, 2025

it's actually more subtle than that, it seems to be due to the order of arguments, but I don't yet have a good reproducer.

That would make this patch correct. If a static library comes after the native libraries in the command line, it would not pick up the symbols even if it uses one of those libraries.

@bonzini bonzini added this to the 1.9.1 milestone Sep 12, 2025
@eli-schwartz
Copy link
Member

Isn't that exactly why meson uses --start-group? Only necessary on Unix linkers, since it implements what windows linkers do anyway.

@bonzini
Copy link
Collaborator

bonzini commented Sep 12, 2025

Isn't that exactly why meson uses --start-group?

It doesn't use it (yet) for Rust. But it wouldn't solve the problem because rustc adds these libraries outside of the arguments coming from Meson, and therefore the libraries would be close to Rust's libstd and outside the group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants