Skip to content

Conversation

folkertdev
Copy link
Contributor

The cargo asm tool (cargo install cargo-show-asm) pattern matches on such labels to figure out where functions end: normal functions generated by LLVM always do have such a label. We don't guarantee that naked functions emit such a label, but having cargo asm work is convenient.

https://github.com/pacak/cargo-show-asm/blob/be45f67454ad8b634246a7fc69b3c6a963ee93f1/src/asm/statements.rs#L897-L901

To make the label name unique it's suffixed with the name of the current symbol.

r? @Amanieu

The `cargo asm` tool pattern matches on such labels to figure out where functions end: normal functions generated by LLVM always do have such a label. We don't guarantee that naked functions emit such a label, but having `cargo asm` work is convenient
@folkertdev folkertdev added A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS F-naked_functions `#![feature(naked_functions)]` labels Sep 19, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 19, 2025

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 19, 2025
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 19, 2025
@Amanieu
Copy link
Member

Amanieu commented Sep 20, 2025

This is fine but I want to be clear that this is not something that we guarantee, and we reserve the right to change it in the future. It might be better for cargo asm to match on the .size directive instead since that is also always placed at the end of a function.

@folkertdev
Copy link
Contributor Author

folkertdev commented Sep 20, 2025

This is fine but I want to be clear that this is not something that we guarantee, and we reserve the right to change it in the future.

Absolutely, I totally agree.

It might be better for cargo asm to match on the .size directive instead since that is also always placed at the end of a function.

Only elf emits .size, while this label match also works for macho, coff and wasm.

@Amanieu
Copy link
Member

Amanieu commented Sep 20, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 20, 2025

📌 Commit b279428 has been approved by Amanieu

It is now in the queue for this repository.

@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 Sep 20, 2025
bors added a commit that referenced this pull request Sep 20, 2025
naked_asm: emit a label starting with `func_end`

The `cargo asm` tool (`cargo install cargo-show-asm`) pattern matches on such labels to figure out where functions end: normal functions generated by LLVM always do have such a label. We don't guarantee that naked functions emit such a label, but having `cargo asm` work is convenient.

https://github.com/pacak/cargo-show-asm/blob/be45f67454ad8b634246a7fc69b3c6a963ee93f1/src/asm/statements.rs#L897-L901

To make the label name unique it's suffixed with the name of the current symbol.

r? `@Amanieu`
@bors
Copy link
Collaborator

bors commented Sep 20, 2025

⌛ Testing commit b279428 with merge a62154d...

@rust-log-analyzer
Copy link
Collaborator

The job dist-powerpc64le-linux-musl failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
warning: spurious network error (2 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (2 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (2 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (2 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
warning: spurious network error (1 try remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
error: failed to get `ident_case` as a dependency of package `darling_core v0.20.11`
    ... which satisfies dependency `darling_core = "=0.20.11"` (locked to 0.20.11) of package `darling v0.20.11`
    ... which satisfies dependency `darling = "^0.20"` (locked to 0.20.11) of package `derive_setters v0.1.8`
    ... which satisfies dependency `derive_setters = "^0.1.6"` (locked to 0.1.8) of package `rustc_errors v0.0.0 (/checkout/compiler/rustc_errors)`
    ... which satisfies path dependency `rustc_errors` (locked to 0.0.0) of package `rustc_codegen_ssa v0.0.0 (/checkout/compiler/rustc_codegen_ssa)`
    ... which satisfies path dependency `rustc_codegen_ssa` (locked to 0.0.0) of package `rustc-main v0.0.0 (/checkout/compiler/rustc)`

Caused by:
  download of id/en/ident_case failed

Caused by:
  failed to download from `https://index.crates.io/id/en/ident_case`

Caused by:
  [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
Bootstrap failed while executing `dist --host powerpc64le-unknown-linux-musl --target powerpc64le-unknown-linux-musl`
Build completed unsuccessfully in 0:22:57

@bors
Copy link
Collaborator

bors commented Sep 20, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 20, 2025
@Amanieu
Copy link
Member

Amanieu commented Sep 20, 2025

@bors retry

@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 Sep 20, 2025
tgross35 added a commit to tgross35/rust that referenced this pull request Sep 20, 2025
…manieu

naked_asm: emit a label starting with `func_end`

The `cargo asm` tool (`cargo install cargo-show-asm`) pattern matches on such labels to figure out where functions end: normal functions generated by LLVM always do have such a label. We don't guarantee that naked functions emit such a label, but having `cargo asm` work is convenient.

https://github.com/pacak/cargo-show-asm/blob/be45f67454ad8b634246a7fc69b3c6a963ee93f1/src/asm/statements.rs#L897-L901

To make the label name unique it's suffixed with the name of the current symbol.

r? `@Amanieu`
tgross35 added a commit to tgross35/rust that referenced this pull request Sep 20, 2025
…manieu

naked_asm: emit a label starting with `func_end`

The `cargo asm` tool (`cargo install cargo-show-asm`) pattern matches on such labels to figure out where functions end: normal functions generated by LLVM always do have such a label. We don't guarantee that naked functions emit such a label, but having `cargo asm` work is convenient.

https://github.com/pacak/cargo-show-asm/blob/be45f67454ad8b634246a7fc69b3c6a963ee93f1/src/asm/statements.rs#L897-L901

To make the label name unique it's suffixed with the name of the current symbol.

r? ``@Amanieu``
bors added a commit that referenced this pull request Sep 20, 2025
Rollup of 6 pull requests

Successful merges:

 - #140983 (Improve doc of some methods that take ranges)
 - #144091 (Stabilize `new_zeroed_alloc`)
 - #145664 (Stabilize `std::panic::Location::file_as_c_str`)
 - #146744 (Deref related cleanups in ref_prop)
 - #146793 (naked_asm: emit a label starting with `func_end`)
 - #146822 (Fix old typo in lang_start_internal comment)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Sep 21, 2025
Rollup of 6 pull requests

Successful merges:

 - #140983 (Improve doc of some methods that take ranges)
 - #144091 (Stabilize `new_zeroed_alloc`)
 - #145664 (Stabilize `std::panic::Location::file_as_c_str`)
 - #146744 (Deref related cleanups in ref_prop)
 - #146793 (naked_asm: emit a label starting with `func_end`)
 - #146822 (Fix old typo in lang_start_internal comment)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Sep 21, 2025
Rollup of 8 pull requests

Successful merges:

 - #140983 (Improve doc of some methods that take ranges)
 - #144091 (Stabilize `new_zeroed_alloc`)
 - #145664 (Stabilize `std::panic::Location::file_as_c_str`)
 - #146551 (fix issue with `cmse-nonsecure-entry` ABI being both async and c-variadic)
 - #146744 (Deref related cleanups in ref_prop)
 - #146793 (naked_asm: emit a label starting with `func_end`)
 - #146820 (Add unstable attribute to BTreeMap-related allocator generics)
 - #146822 (Fix old typo in lang_start_internal comment)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 92ea947 into rust-lang:master Sep 21, 2025
10 of 11 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Sep 21, 2025
rust-timer added a commit that referenced this pull request Sep 21, 2025
Rollup merge of #146793 - folkertdev:naked-asm-func-end, r=Amanieu

naked_asm: emit a label starting with `func_end`

The `cargo asm` tool (`cargo install cargo-show-asm`) pattern matches on such labels to figure out where functions end: normal functions generated by LLVM always do have such a label. We don't guarantee that naked functions emit such a label, but having `cargo asm` work is convenient.

https://github.com/pacak/cargo-show-asm/blob/be45f67454ad8b634246a7fc69b3c6a963ee93f1/src/asm/statements.rs#L897-L901

To make the label name unique it's suffixed with the name of the current symbol.

r? ```@Amanieu```
Muscraft pushed a commit to Muscraft/rust that referenced this pull request Sep 24, 2025
…manieu

naked_asm: emit a label starting with `func_end`

The `cargo asm` tool (`cargo install cargo-show-asm`) pattern matches on such labels to figure out where functions end: normal functions generated by LLVM always do have such a label. We don't guarantee that naked functions emit such a label, but having `cargo asm` work is convenient.

https://github.com/pacak/cargo-show-asm/blob/be45f67454ad8b634246a7fc69b3c6a963ee93f1/src/asm/statements.rs#L897-L901

To make the label name unique it's suffixed with the name of the current symbol.

r? ```@Amanieu```
Muscraft pushed a commit to Muscraft/rust that referenced this pull request Sep 24, 2025
Rollup of 8 pull requests

Successful merges:

 - rust-lang#140983 (Improve doc of some methods that take ranges)
 - rust-lang#144091 (Stabilize `new_zeroed_alloc`)
 - rust-lang#145664 (Stabilize `std::panic::Location::file_as_c_str`)
 - rust-lang#146551 (fix issue with `cmse-nonsecure-entry` ABI being both async and c-variadic)
 - rust-lang#146744 (Deref related cleanups in ref_prop)
 - rust-lang#146793 (naked_asm: emit a label starting with `func_end`)
 - rust-lang#146820 (Add unstable attribute to BTreeMap-related allocator generics)
 - rust-lang#146822 (Fix old typo in lang_start_internal comment)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS F-naked_functions `#![feature(naked_functions)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants