-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Disallow export_name
starting with "llvm."
#140837
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
base: master
Are you sure you want to change the base?
Conversation
This comment from 2017 says "every error should have an associated error code" However, a more recent rustc-dev-guide doc from 2020 suggests that this is not the case, and that errorcode-less errors are fine and sometimes even preferable to errorcode-full ones: rust-lang/rustc-dev-guide#967
Some changes occurred in compiler/rustc_codegen_ssa/src/codegen_attrs.rs Some changes occurred in compiler/rustc_codegen_ssa |
This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
Reminder, once the PR becomes ready for a review, use |
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
Simply because it looks a little bit prettier that way, IMO
@@ -52,6 +52,9 @@ codegen_ssa_expected_one_argument = expected one argument | |||
|
|||
codegen_ssa_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)` | |||
|
|||
codegen_ssa_export_name_llvm_intrinsic = exported symbol name must not start with "llvm." | |||
.note = symbols starting with "llvm." are reserved for LLVM intrinsics and cannot be defined in user code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have a concept of "user code" so let's not confuse users into believing there is one.
.note = symbols starting with "llvm." are reserved for LLVM intrinsics and cannot be defined in user code | |
.note = symbols starting with `llvm.` are reserved for LLVM intrinsics |
@@ -52,6 +52,9 @@ codegen_ssa_expected_one_argument = expected one argument | |||
|
|||
codegen_ssa_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)` | |||
|
|||
codegen_ssa_export_name_llvm_intrinsic = exported symbol name must not start with "llvm." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
codegen_ssa_export_name_llvm_intrinsic = exported symbol name must not start with "llvm." | |
codegen_ssa_export_name_llvm_intrinsic = exported symbol name must not start with `llvm.` |
(same below)
Note Please ignore this nomination, as it's probably more of a bug-fix. Left unresolved for reference only. BackgroundRejecting
Possible breakageI don't really expect any breakages (someone is likely doing some... weird things if this causes their code to no longer compile), but this is technically constraining the set of programs that we accept.
|
EDIT: I removed the lang nomination, probably more of a "bug fix" / "impl detail". |
GitHub code search yields no results; https://github.com/search?q=%22export_name+%3D+%5C%22llvm.%22&type=code this is such a weird and broken thing to do that I think we can just ship this without crater or FCW or anything |
r? compiler |
Is there a reason this is handled in |
Wouldn't it be weird if your code is working on one backend but not on another one? |
@Urgau generally yes, but
|
Yeah, I should've left the nomination comment open, also asked
|
Fixes #140822
Motivation in the issue, and in code comments.
This implementation adds the check to right to
#[export_name]
parsing code. I considered moving it closer to the place where the new name gets emitted to llvm, but that looked harder to get right, and easier to accidentally break going forward.I don't believe any other attributes need this handling. The only one that comes close is
link_name
but that one uses the name, and does not define it, and in fact#[link_name = "llvm.stuff"]
is entirely justified and actively used in real code.Two small drive-by changes in separate commits (removed an obsolete and misleading
//FIXME
comment, and tighten the diagnostics span for the null-byte-in-export_name
check). Happy to split them into dedicated PR(s) if this is deemed valuable.