Error on invalid macho section specifier#155065
Error on invalid macho section specifier#155065folkertdev wants to merge 4 commits intorust-lang:mainfrom
Conversation
|
Some changes occurred in compiler/rustc_hir/src/attrs cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_passes/src/check_attr.rs cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_attr_parsing |
|
just in case we're doing something weird that never got built or linked @bors try jobs=aarch64-apple |
This comment has been minimized.
This comment has been minimized.
error on invalid macho section specifier try-job: aarch64-apple
This comment has been minimized.
This comment has been minimized.
35e0a3f to
c90d31f
Compare
We're trying to move as many checks as possible to attribute parsing, with the "parse, don't validate" mentality, so if an attribute gets through parsing you can assume it is correct. Therefore I'd like this to be in the attribute parser |
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
|
💔 Test for 3e6930f failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
c90d31f to
30b9c6e
Compare
This comment has been minimized.
This comment has been minimized.
30b9c6e to
db42ae2
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
…, r=JonathanBrouwer error on invalid macho section specifier The macho section specifier used by `#[link_section = "..."]` is more strict than e.g. the one for elf. LLVM will error when you get it wrong, which is easy to do if you're used to elf. So, provide some guidance for the simplest mistakes, based on the LLVM validation. Currently compilation fails with an LLVM error, see https://godbolt.org/z/WoE8EdK1K. The LLVM validation logic is at https://github.com/llvm/llvm-project/blob/a0f0d6342e0cd75b7f41e0e6aae0944393b68a62/llvm/lib/MC/MCSectionMachO.cpp#L199-L203 LLVM validates the other components of the section specifier too, but it feels a bit fragile to duplicate those checks. If you get that far, hopefully the LLVM errors will be sufficient to get unstuck. --- sidequest from rust-lang#147811 r? JonathanBrouwer specifically, is this the right place for this sort of validation? `rustc_attr_parsing` also does some validation.
3f4778b to
7aeba4e
Compare
|
These commits modify Please ensure that if you've changed the output:
|
|
@bors try jobs=aarch64-apple |
This comment has been minimized.
This comment has been minimized.
error on invalid macho section specifier try-job: aarch64-apple
|
btw there is some discussion at #t-lang > error on invalid macho section about whether we should FCW this first. This change might break projects that use an invalid section specifier for a symbol that never gets linked. Currently LLVM's codegen would never see that symbol, but with this change |
|
@rfcbot fcp lang |
|
Let's do it. @rfcbot fcp merge lang |
|
Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
|
@rfcbot reviewed |
1 similar comment
|
@rfcbot reviewed |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
Rfcbot didn't catch your review Niko. |
|
☔ The latest upstream changes (presumably #155472) made this pull request unmergeable. Please resolve the merge conflicts. |
View all comments
The macho section specifier used by
#[link_section = "..."]is more strict than e.g. the one for elf. LLVM will error when you get it wrong, which is easy to do if you're used to elf. So, provide some guidance for the simplest mistakes, based on the LLVM validation.Currently compilation fails with an LLVM error, see https://godbolt.org/z/WoE8EdK1K.
The LLVM validation logic is at
https://github.com/llvm/llvm-project/blob/a0f0d6342e0cd75b7f41e0e6aae0944393b68a62/llvm/lib/MC/MCSectionMachO.cpp#L199-L203
LLVM validates the other components of the section specifier too, but it feels a bit fragile to duplicate those checks. If you get that far, hopefully the LLVM errors will be sufficient to get unstuck.
sidequest from #147811
r? JonathanBrouwer
specifically, is this the right place for this sort of validation?
rustc_attr_parsingalso does some validation.