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

Apply weak attributes to all intrinsics #598

Merged
merged 3 commits into from
May 3, 2024

Conversation

Amjad50
Copy link
Contributor

@Amjad50 Amjad50 commented Apr 29, 2024

Removed the weak-intrinsics feature, so that all functions will have the weak linkage attribute.

But this caused issues for memset (maybe other mem functions are related), so added a special feature for those mem-weak-intrinsics.

mem functions won't have the weak attribute unless this feature is enabled.

This also fixed the bug in rust-lang/rust#124042.

Before this commit, generated code will be

pub extern "C" fn <name>(...) -> ... {
        // code...
}
pub mod <name> {
    #[linkage = "weak"]
    #[no_mangle]
    pub extern "C" fn <name>(...) -> ... {
        super::<name>(...)
    }
}

The issue is that there is 2 weak linkage, the first one is not required. Along refactoring weak attributes, this was fixed.

@Amjad50 Amjad50 changed the title Apply weak attributes to all* intrinsics Apply weak attributes to most intrinsics Apr 29, 2024
@Amjad50 Amjad50 changed the title Apply weak attributes to most intrinsics Apply weak attributes to most intrinsics by default Apr 29, 2024
src/macros.rs Outdated Show resolved Hide resolved
@Amjad50 Amjad50 changed the title Apply weak attributes to most intrinsics by default Apply weak attributes to all intrinsics Apr 30, 2024
@Amjad50 Amjad50 marked this pull request as draft May 1, 2024 04:18
@Amjad50 Amjad50 marked this pull request as ready for review May 1, 2024 11:27
@Amjad50 Amjad50 requested a review from Amanieu May 1, 2024 11:27
Copy link
Member

@Amanieu Amanieu left a comment

Choose a reason for hiding this comment

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

This may also be a good opportunity to cleanup the mod wrappers around the no_mangle version of each intrinsic. Specifically:

  • There is no need for these modules to be pub. Same with the function inside them. #[no_mangle] will ensure the symbol is exported.
  • The whole module should be #[cfg(not(feature = "mangled-names")]. The functions themselves can then be #[no_mangle] unconditionally.

src/macros.rs Outdated Show resolved Hide resolved
@Amjad50 Amjad50 requested a review from Amanieu May 2, 2024 14:00
Removed the `weak-intrinsics` feature, so that all functions
will have the `weak` linkage attribute.

Also this fixed the bug in
rust-lang/rust#124042.

Before this commit, generated code will be
```rust
pub extern "C" fn <name>(...) -> ... {
        // code...
}
pub mod <name> {
    #[linkage = "weak"]
    #[no_mangle]
    pub extern "C" fn <name>(...) -> ... {
        super::<name>(...)
    }
}
```

The issue is that there is 2 `weak` linkage, the first one is not required.
Along refactoring `weak` attributes, this was fixed.
`weak` is only used with `no_mangle`
Don't generate the whole function if we are not going to use `no_mangle`, there is no point
@Amanieu Amanieu enabled auto-merge May 3, 2024 11:27
@Amanieu Amanieu merged commit ab63499 into rust-lang:master May 3, 2024
23 checks passed
@Amjad50
Copy link
Contributor Author

Amjad50 commented May 3, 2024

Thanks @Amanieu , can a new version be released?

@Amanieu
Copy link
Member

Amanieu commented May 4, 2024

Done

nicholasbishop added a commit to nicholasbishop/rust that referenced this pull request May 11, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These cause a compilation error
(reproduce with `ENABLE_GCC_CODEGEN=1 src/ci/docker/run.sh
x86_64-gnu-llvm-17`), so enable `no-f16-f128` for now.
nicholasbishop added a commit to nicholasbishop/rust that referenced this pull request May 12, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc.
nicholasbishop added a commit to nicholasbishop/rust that referenced this pull request May 16, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc.
nicholasbishop added a commit to nicholasbishop/rust that referenced this pull request May 27, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc.
nicholasbishop added a commit to nicholasbishop/rust that referenced this pull request May 30, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc.
nicholasbishop added a commit to nicholasbishop/rust that referenced this pull request May 30, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc.
bors added a commit to rust-lang-ci/rust that referenced this pull request May 30, 2024
Update compiler_builtins to 0.1.112

The `weak-intrinsics` feature was removed from compiler_builtins in rust-lang/compiler-builtins#598, so dropped the `compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some builtins for f16/f128 were added. These don't work for all compiler backends, so add a `compiler-builtins-no-f16-f128` feature and disable it for cranelift and gcc.
nicholasbishop added a commit to nicholasbishop/rust that referenced this pull request May 30, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 4, 2024
…iler-errors

Update compiler_builtins to 0.1.112

The `weak-intrinsics` feature was removed from compiler_builtins in rust-lang/compiler-builtins#598, so dropped the `compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some builtins for f16/f128 were added. These don't work for all compiler backends, so add a `compiler-builtins-no-f16-f128` feature and disable it for cranelift and gcc.
nicholasbishop added a commit to nicholasbishop/rust that referenced this pull request Jun 4, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc. Also disable it for LLVM targets that don't
support it.
nicholasbishop added a commit to nicholasbishop/rust that referenced this pull request Jun 4, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc. Also disable it for LLVM targets that don't
support it.
nicholasbishop added a commit to nicholasbishop/rust that referenced this pull request Jun 8, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc. Also disable it for LLVM targets that don't
support it.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 17, 2024
Update compiler_builtins to 0.1.112

The `weak-intrinsics` feature was removed from compiler_builtins in rust-lang/compiler-builtins#598, so dropped the `compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some builtins for f16/f128 were added. These don't work for all compiler backends, so add a `compiler-builtins-no-f16-f128` feature and disable it for cranelift and gcc.
tgross35 pushed a commit to tgross35/rust that referenced this pull request Jun 21, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc. Also disable it for LLVM targets that don't
support it.
nicholasbishop added a commit to nicholasbishop/rust that referenced this pull request Jun 25, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc. Also disable it for LLVM targets that don't
support it.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 26, 2024
Update compiler_builtins to 0.1.112

The `weak-intrinsics` feature was removed from compiler_builtins in rust-lang/compiler-builtins#598, so dropped the `compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some builtins for f16/f128 were added. These don't work for all compiler backends, so add a `compiler-builtins-no-f16-f128` feature and disable it for cranelift and gcc.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 26, 2024
…anieu

Update compiler_builtins to 0.1.113

The `weak-intrinsics` feature was removed from compiler_builtins in rust-lang/compiler-builtins#598, so dropped the `compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some builtins for f16/f128 were added. These don't work for all compiler backends, so add a `compiler-builtins-no-f16-f128` feature and disable it for cranelift and gcc.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 26, 2024
…anieu

Update compiler_builtins to 0.1.113

The `weak-intrinsics` feature was removed from compiler_builtins in rust-lang/compiler-builtins#598, so dropped the `compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some builtins for f16/f128 were added. These don't work for all compiler backends, so add a `compiler-builtins-no-f16-f128` feature and disable it for cranelift and gcc.
tgross35 pushed a commit to tgross35/rust that referenced this pull request Jul 10, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc. Also disable it for LLVM targets that don't
support it.
tgross35 pushed a commit to tgross35/rust that referenced this pull request Jul 18, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc. Also disable it for LLVM targets that don't
support it.
tgross35 added a commit to tgross35/compiler-builtins that referenced this pull request Jul 18, 2024
After <rust-lang#598>,
arm-android was failing to complete in CI because it was hanging on some
tests. This issue appears to have been caused by symbols related to
atomics, e.g. `__sync_val_compare_and_swap_4`, to have become weak.

It turns out that these symbols were always strong before, even though
Android was always setting the `weak-intrinsics` feature. So, making
them weak presumably caused the system implementation to get linked,
which appears buggy.

Resolve this by making `__sync_*` symbols weak on Android.

(this includes a recursion limit increase, our macros are getting big).

Link: rust-lang#641
nicholasbishop added a commit to nicholasbishop/rust that referenced this pull request Jul 29, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc. Also disable it for LLVM targets that don't
support it.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 29, 2024
…ss35

Update compiler_builtins to 0.1.114

The `weak-intrinsics` feature was removed from compiler_builtins in rust-lang/compiler-builtins#598, so dropped the `compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some builtins for f16/f128 were added. These don't work for all compiler backends, so add a `compiler-builtins-no-f16-f128` feature and disable it for cranelift and gcc.
Mrmaxmeier pushed a commit to Mrmaxmeier/rust that referenced this pull request Jul 29, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc. Also disable it for LLVM targets that don't
support it.
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jul 30, 2024
Update compiler_builtins to 0.1.114

The `weak-intrinsics` feature was removed from compiler_builtins in rust-lang/compiler-builtins#598, so dropped the `compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some builtins for f16/f128 were added. These don't work for all compiler backends, so add a `compiler-builtins-no-f16-f128` feature and disable it for cranelift and gcc.
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request Aug 2, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc. Also disable it for LLVM targets that don't
support it.
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request Aug 2, 2024
Update compiler_builtins to 0.1.114

The `weak-intrinsics` feature was removed from compiler_builtins in rust-lang/compiler-builtins#598, so dropped the `compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some builtins for f16/f128 were added. These don't work for all compiler backends, so add a `compiler-builtins-no-f16-f128` feature and disable it for cranelift and gcc.
GuillaumeGomez pushed a commit to GuillaumeGomez/rustc_codegen_gcc that referenced this pull request Aug 6, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc. Also disable it for LLVM targets that don't
support it.
GuillaumeGomez pushed a commit to GuillaumeGomez/rustc_codegen_gcc that referenced this pull request Aug 6, 2024
Update compiler_builtins to 0.1.114

The `weak-intrinsics` feature was removed from compiler_builtins in rust-lang/compiler-builtins#598, so dropped the `compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some builtins for f16/f128 were added. These don't work for all compiler backends, so add a `compiler-builtins-no-f16-f128` feature and disable it for cranelift and gcc.
GuillaumeGomez pushed a commit to GuillaumeGomez/rustc_codegen_gcc that referenced this pull request Aug 12, 2024
The `weak-intrinsics` feature was removed from compiler_builtins in
rust-lang/compiler-builtins#598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc. Also disable it for LLVM targets that don't
support it.
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Aug 13, 2024
Update compiler_builtins to 0.1.114

The `weak-intrinsics` feature was removed from compiler_builtins in rust-lang/compiler-builtins#598, so dropped the `compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In rust-lang/compiler-builtins#593, some builtins for f16/f128 were added. These don't work for all compiler backends, so add a `compiler-builtins-no-f16-f128` feature and disable it for cranelift and gcc.
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