-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
link_section is not applied to global constants #46968
Comments
As far as Rust-the-language is concerned, |
Okay, well then it would make sense to disallow |
Inapplicable attributes don’t really get "disallowed", that applies for most of them, really. The principle is that item checks for attributes relevant to itself, rather than all attributes checked against the item they apply to. There are multiple good reasons why it is implemented as such and I don’t see the behaviour changing. That being said, I find it amusing that the attribute-not-used warning does not get output, as constants should not bother checking for |
There's a set of attributes that attribute-not-used lint doesn't look at since they're used in trans but lints run before that. |
Triage: Closing as won't fix based on last two comments. |
The
link_section
attribute doesn't get applied to globalconst
values.Consider the following program (which uses
static
instead ofconst
, and correctly applies thelink_section
toHELLO
):As can be seen in the LLVM IR (Playground link),
HELLO
is correctly given the custom section assignment:But if we change
HELLO
to be aconst
instead ofstatic
:Then the string no longer has the custom section applied (Playground link):
I think that Rust should propagate the link section to all instances of the string. That is,
@byte_str.0
(and any other duplicate instances of theconst
) should be defined as@byte_str.0 = private unnamed_addr constant [6 x i8] c"hello\00", section ".data,__yes_this_is_a_custom_link_section", align 8
.Meta info: I've tested this in both 1.22.1 and 1.24.0-nightly (2017-12-22 5165ee9). Both produce the same results.
The text was updated successfully, but these errors were encountered: