Skip to content

Validate that naked functions are never inlined #87652

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Aug 3, 2021

Conversation

npmccallum
Copy link
Contributor

@npmccallum npmccallum commented Jul 31, 2021

Reject all uses of the inline attribute on naked functions.

rust-lang/rfcs#2774
rust-lang/rfcs#2972

cc @joshtriplett @tmiasko @Amanieu

@rust-highfive
Copy link
Contributor

r? @oli-obk

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 31, 2021
@rust-log-analyzer

This comment has been minimized.

pub unsafe extern "C" fn valid_att_syntax() {
asm!("", options(noreturn, att_syntax));
}

#[naked]
//~^ WARN naked functions require #[inline(never)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tracking issue says that this should be an error, but it's a warning in this PR. Is this just a transitional lint to avoid breaking nightly code? If so, seems reasonable to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josephlr There's a bunch of these lints that should be errors according to the RFC. I wanted to get them all in as warnings first and then file a follow-up which switches the relevant ones to errors. This allows us to reason about them as an entire set.

@oli-obk
Copy link
Contributor

oli-obk commented Aug 2, 2021

r? @Amanieu

@rust-log-analyzer

This comment has been minimized.

Reject all uses of the inline attribute on naked functions.

rust-lang/rfcs#2774
rust-lang/rfcs#2972
@Amanieu
Copy link
Member

Amanieu commented Aug 3, 2021

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 3, 2021

📌 Commit 157e0a0 has been approved by Amanieu

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 3, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 3, 2021
Rollup of 8 pull requests

Successful merges:

 - rust-lang#87645 (Properly find owner of closure in THIR unsafeck)
 - rust-lang#87646 (Fix a parser ICE on invalid `fn` body)
 - rust-lang#87652 (Validate that naked functions are never inlined)
 - rust-lang#87685 (Write docs for SyncOnceCell From and Default impl)
 - rust-lang#87693 (Add `aarch64-apple-ios-sim` as a possible target to the manifest)
 - rust-lang#87708 (Add convenience method for handling ipv4-mapped addresses by canonicalizing them)
 - rust-lang#87711 (Correct typo)
 - rust-lang#87716 (Allow generic SIMD array element type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a14b283 into rust-lang:master Aug 3, 2021
@rustbot rustbot added this to the 1.56.0 milestone Aug 3, 2021
@npmccallum npmccallum deleted the naked_inline branch August 3, 2021 14:35
npmccallum added a commit to npmccallum/rust-rfcs that referenced this pull request Aug 4, 2021
This matches the behavior of the merged PR implementing this criteria.

rust-lang/rust#87652
tmiasko added a commit to tmiasko/rust that referenced this pull request Jan 21, 2022
Transition unsupported naked functions future incompatibility lint into
an error:

* Naked functions must contain a single inline assembly block.
  Introduced as future incompatibility lint in 1.50 rust-lang#79653.
  Change into an error fixes a soundness issue described in rust-lang#32489.

* Naked functions must not use any forms of inline attribute.
  Introduced as future incompatibility lint in 1.56 rust-lang#87652.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 22, 2022
…nctions, r=Amanieu

Reject unsupported naked functions

Transition unsupported naked functions future incompatibility lint into an error:

* Naked functions must contain a single inline assembly block. Introduced as future incompatibility lint in 1.50 rust-lang#79653. Change into an error fixes a soundness issue described in rust-lang#32489.

* Naked functions must not use any forms of inline attribute. Introduced as future incompatibility lint in 1.56 rust-lang#87652.

Closes rust-lang#32490.
Closes rust-lang#32489.

r? `@Amanieu` `@npmccallum` `@joshtriplett`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 22, 2022
…nctions, r=Amanieu

Reject unsupported naked functions

Transition unsupported naked functions future incompatibility lint into an error:

* Naked functions must contain a single inline assembly block. Introduced as future incompatibility lint in 1.50 rust-lang#79653. Change into an error fixes a soundness issue described in rust-lang#32489.

* Naked functions must not use any forms of inline attribute. Introduced as future incompatibility lint in 1.56 rust-lang#87652.

Closes rust-lang#32490.
Closes rust-lang#32489.

r? ``@Amanieu`` ``@npmccallum`` ``@joshtriplett``
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 22, 2022
…nctions, r=Amanieu

Reject unsupported naked functions

Transition unsupported naked functions future incompatibility lint into an error:

* Naked functions must contain a single inline assembly block. Introduced as future incompatibility lint in 1.50 rust-lang#79653. Change into an error fixes a soundness issue described in rust-lang#32489.

* Naked functions must not use any forms of inline attribute. Introduced as future incompatibility lint in 1.56 rust-lang#87652.

Closes rust-lang#32490.
Closes rust-lang#32489.

r? ```@Amanieu``` ```@npmccallum``` ```@joshtriplett```
@bstrie bstrie added A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 2, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants