-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Target features getting erased when using #[export_name] with names of LLVM intrinsics #140822
Copy link
Copy link
Open
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
TIL Rust "supports"
#[export_name]with names of LLVM intrinsics! The following code compiles no problem(FYI
llvm.x86.rdtscis a very real LLVM intrinsic, used to read the timestamp counter value in x86)which imo should be hard error anyway. But then if we combine this monstrosity with
#[target_feature](or-C target-featurefor that matter), all the target feature data for that function is erased. This is possible even in stable Rust, both in debug and release profile.Godbolt link https://godbolt.org/z/h7jdrsY54
Meta
Doing a naive bisect on Godbolt, I found out that this bug was introduced in
1.29.0!!https://godbolt.org/z/8M9a4vs9Y
The solution is probably just disallow any
#[export_name]'s that try to masquerade as LLVM intrinsics (i.e. name starts withllvm.), which will mean reverting to pre-1.29.0 behavior.@rustbot label T-compiler