-
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 |
This comment was marked as resolved.
This comment was marked as resolved.
This comment has been minimized.
This comment has been minimized.
Simply because it looks a little bit prettier that way, IMO
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
|
I really don't think a singular codegen backend's limitation should be part of the language. I don't think we'd do something like this for other backends and I think llvm shouldn't be special in this regard. |
It's possible to support this for the LLVM backend by emitting a mangling escape. But actually doing that would be incoherent with |
It's probably also worth pointing out that other backends actually do tend to support So while this is certainly an LLVM-ism originally, the fact that |
The actual reason was that I thought the implementation to be a bit easier and look a bit nicer this way.
My opinion doesn't have much weight here, but as a user I agree that this should not be part of the Language reference. It is only an implementation detail of rustc compiler. I also considered making this a deny-by-default lint instead of hard error, but couldn't think of a good reason why would someone want to bypass this check so it's a hard error currently. |
On the second thought, that's an unfair framing by me. This check should go to I'll try to move it to @rustbot author |
r? codegen |
Are there similar "restricted" names for cg_gcc or cg_clif? I believe names starting with |
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.