Skip to content

Conversation

joboet
Copy link
Member

@joboet joboet commented Sep 16, 2025

This moves the dlsym-based and weak-linkage versions of the weak! macro into separate files, both of which include a common test file. As a result, both versions will be tested on all the platforms where they are used.

Since the #[link_name] arm of the dlsym version was unused, I've removed it. I've also removed the unused raw_syscall! and non-Linux syscall! macros and gated the #[allow(dead_code, unused_macros)] to only apply on non-Linux platforms, so compilation will fail if weak turns out to be unused on all platforms.

The last change concerns the use of dlsym! on FreeBSD: it is only used once, to link against sysctlbyname. But that symbol is always available, so there is no need for weak linkage.

@rustbot rustbot added O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 16, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Sep 16, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

// transmutation is well-defined. It is the responsibility of the
// creator of this `DlsymWeak` to ensure that calling the resulting
// function pointer does not result in undefined behaviour (though
// the `dlsym!` macro delegates this responsibility to the caller
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// the `dlsym!` macro delegates this responsibility to the caller
// the `weak!` macro delegates this responsibility to the caller
@ibraheemdev
Copy link
Member

Looks good. r=me after the nit.

@ibraheemdev ibraheemdev added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-unix Operating system: Unix-like S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.

4 participants