Skip to content

just use #[used]#541

Open
AwesomeQubic wants to merge 1 commit intorust-osdev:mainfrom
AwesomeQubic:main
Open

just use #[used]#541
AwesomeQubic wants to merge 1 commit intorust-osdev:mainfrom
AwesomeQubic:main

Conversation

@AwesomeQubic
Copy link

ran the test suite and it seems fine

@AwesomeQubic AwesomeQubic changed the title just use #[used] bruh just use #[used] Feb 19, 2026
@Freax13
Copy link
Member

Freax13 commented Feb 19, 2026

According to the Rust Reference, #[used] does not prevent the static from being garbage collected by the linker.

I'm not entirely convinced that we can safely remove the code that references the variable just because the compiler happens to not remove the variable for the kernels in our tests.

@AwesomeQubic
Copy link
Author

Tested it in gobolt and using similar setup current approach got removed but not used
link

@ethindp
Copy link
Contributor

ethindp commented Feb 19, 2026

The address cannot be removed though. It must be present. The used attribute does not prevent the linker from removing the variable if it's own heuristics determine that it is unused.

@AwesomeQubic
Copy link
Author

good point my bad link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments