-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Invalid monomorphization when -C link-dead-code
is used
#77529
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
Comments
(Not sure if |
Any progress on this error ? There are many projects which are having problems, as they use |
Since this crate cannot be built with Compiling approx v0.3.2
error[E0658]: platform intrinsics are experimental and possibly buggy
--> src/simd_llvm.rs:13:8
|
13 | extern "platform-intrinsic" {
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information
warning: unused import: `crate::simd_llvm`
--> src/vec.rs:21:5
|
21 | use crate::simd_llvm;
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0658`. @rustbot modify labels: requires-nightly |
@xd009642 do you know if this used to work on an old version of rust? Or has it always been an issue? |
MCVE: https://rust.godbolt.org/z/ax56Mj // compile-flags: --crate-type=rlib -C link-dead-code
#![feature(platform_intrinsics)]
#![feature(repr_simd)]
extern "platform-intrinsic" {
pub fn simd_reduce_all<T>(x: T) -> bool;
}
#[repr(simd)]
// #[repr(C)]
pub struct Vec3<T> {
pub x: T,
pub y: T,
pub z: T,
}
impl Vec3<bool> {
#[inline]
pub fn reduce_and(self) -> bool {
unsafe { simd_reduce_all(self) }
}
} |
I used the MCVE and checked it with those toolchains on linux. And all show exact the same error.
(long version is always: nightly-20xx-yy-zz-x86_64-unknown-linux-gnu) |
@jyn514 I've no idea when it started, it's not my code I just write a tool that adds the linker flag 😅 |
I believe the code should never be compiled. Because if you manually replace #![feature(repr_simd)]
#[repr(simd)]
pub struct Vec3 { // error[E0077]: SIMD vector element type should be machine type
pub x: bool,
pub y: bool,
pub z: bool,
} In short, an useful error message is lost, instead a less useful error message replaces it. |
Assigning |
Unfortunately, because this uses |
Could some code be added to the monomorphizer that replaces the less useful error with a more useful error like the one reported by |
Perhaps, but this only occurs because
I have a hunch that says that unconstrained linking-in of code that was intended to be omitted may simply be a bad idea, though. There is a need served by it, but it is not clear that that need is best addressed in this way. In this case, however, we can simply eliminate the need directly, however, by following through with #63633, which is what I have been working on. |
(meta: It might be good to rename the |
It's a little more like the |
My understanding is that |
I've tried to compile this crate https://github.com/yoanlcq/vek as part of running code coverage and with
RUSTFLAGS="-C link-dead-code"
and--features platform_intrinsics
it fails to build. But without-C link-dead-code
it builds and runs fine which is what I'd expect with the flag present.Sample error (they're all the same error just different bits of code:
The text was updated successfully, but these errors were encountered: