Skip to content
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

Add the weak-intrinsics feature #526

Merged
merged 1 commit into from
May 20, 2023
Merged

Add the weak-intrinsics feature #526

merged 1 commit into from
May 20, 2023

Conversation

danakj
Copy link
Contributor

@danakj danakj commented May 19, 2023

When enabled, the weak-intrinsics feature will cause all intrinsics functions to be marked with weak linkage (i.e. `#[linkage = "weak"]) so that they can be replaced at link time by a stronger symbol.

This can be set to use C++ intrinsics from the compiler-rt library, as it will avoid Rust's implementation replacing the compiler-rt implementation as long as the compiler-rt symbols are linked as strong symbols. Typically this requires the compiler-rt library to be explicitly specified in the link command.

Addresses #525.

src/macros.rs Outdated Show resolved Hide resolved
@danakj danakj marked this pull request as draft May 19, 2023 21:07
@danakj danakj marked this pull request as ready for review May 19, 2023 21:34
When enabled, the weak-intrinsics feature will cause all intrinsics
functions to be marked with weak linkage (i.e. `#[linkage = "weak"])
so that they can be replaced at link time by a stronger symbol.

This can be set to use C++ intrinsics from the compiler-rt library,
as it will avoid Rust's implementation replacing the compiler-rt
implementation as long as the compiler-rt symbols are linked as
strong symbols. Typically this requires the compiler-rt library to
be explicitly specified in the link command.

Addresses rust-lang#525.

Without weak-intrinsics, from nm:
```
00000000 W __aeabi_memclr8  // Is explicitly weak
00000000 T __udivsi3  // Is not.
```

With weak-intrinsics, from nm:
```
00000000 W __aeabi_memclr8  // Is explicitly weak
00000000 W __udivsi3  // Is weak due to weak-intrinsics
```
@Amanieu
Copy link
Member

Amanieu commented May 20, 2023

Thanks! If this works well, we may even enable it by default in the future.

@danakj danakj deleted the weak branch May 20, 2023 11:30
Amanieu added a commit to Amanieu/rust that referenced this pull request Jun 23, 2023
This was added in rust-lang/compiler-builtins#526 to force all
compiler-builtins intrinsics to use weak linkage.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 25, 2023
…mulacrum

Expose `compiler-builtins-weak-intrinsics` feature for `-Zbuild-std`

This was added in rust-lang/compiler-builtins#526 to force all compiler-builtins intrinsics to use weak linkage.
thomcc pushed a commit to tcdi/postgrestd that referenced this pull request Aug 24, 2023
This was added in rust-lang/compiler-builtins#526 to force all
compiler-builtins intrinsics to use weak linkage.
thomcc pushed a commit to tcdi/postgrestd that referenced this pull request Aug 24, 2023
Expose `compiler-builtins-weak-intrinsics` feature for `-Zbuild-std`

This was added in rust-lang/compiler-builtins#526 to force all compiler-builtins intrinsics to use weak linkage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants