validate #[link_name = "..."] & #[link(name = "...")] parameters#155817
Open
folkertdev wants to merge 1 commit intorust-lang:mainfrom
Open
validate #[link_name = "..."] & #[link(name = "...")] parameters#155817folkertdev wants to merge 1 commit intorust-lang:mainfrom
#[link_name = "..."] & #[link(name = "...")] parameters#155817folkertdev wants to merge 1 commit intorust-lang:mainfrom
Conversation
Collaborator
|
Some changes occurred in compiler/rustc_attr_parsing |
#[link_name = "..."] parameter#[link_name = "..."] & #[link(name = "...")] parameters
mejrs
approved these changes
Apr 26, 2026
This comment has been minimized.
This comment has been minimized.
b94ed3f to
2ffa233
Compare
folkertdev
commented
Apr 26, 2026
Comment on lines
12
to
13
| #[link_name = "@GLIBC_2.2.5"] | ||
| pub safe fn exit_1(status: i32) -> !; //~ ERROR link name must be well-formed if link kind is `raw-dylib` |
Contributor
Author
There was a problem hiding this comment.
2ffa233 to
4338dfc
Compare
This comment has been minimized.
This comment has been minimized.
4338dfc to
5a5ae4c
Compare
This comment has been minimized.
This comment has been minimized.
specifically, do not allow NULL bytes and the empty string
5a5ae4c to
c08b9ab
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #155776
fixes #155484
specifically, do not allow NULL bytes and the empty string in
#[link_name = "..."]and#[link(name = "...")].Like some of the others I think this formally needs to be looked at by T-lang because these errors would not show up if not linking.
The LLVM erorr on
#[linke_name = "\0"]is emitted here, it is not e.g. target-specific.https://github.com/llvm/llvm-project/blob/d593279c0b2891f0b0c8af3f70a1a0383b4ad1b5/llvm/lib/IR/Value.cpp#L336-L342
On
#[link(name = "")]we already error today. A NULL byte in#[link(name = "\0")]is caught by the linker (https://godbolt.org/z/vnz9sYbPs), using#[link_name = ""]makes LLVM generate a name (https://godbolt.org/z/1hWEo4cxf) which is not useful and likely to cause linker errors.r? jdonszelmann