Skip to content

test #[naked] with #[link_section = "..."] on windows#154598

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
folkertdev:windows-naked-link-section
Apr 9, 2026
Merged

test #[naked] with #[link_section = "..."] on windows#154598
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
folkertdev:windows-naked-link-section

Conversation

@folkertdev
Copy link
Copy Markdown
Contributor

As a part of #147811 I ran into that we actually don't match (current) LLVM output.

r? @mati865

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 30, 2026
Comment on lines -270 to +284
let section = link_section.unwrap_or_else(|| format!(".text.{asm_name}"));
writeln!(begin, ".pushsection {},\"xr\"", section).unwrap();
writeln!(begin, ".balign {align_bytes}").unwrap();
write_linkage(&mut begin).unwrap();
writeln!(begin, ".def {asm_name}").unwrap();
writeln!(begin, ".scl 2").unwrap();
writeln!(begin, ".type 32").unwrap();
writeln!(begin, ".endef").unwrap();

let section = link_section.unwrap_or_else(|| format!(".text.{asm_name}"));
writeln!(begin, ".pushsection {},\"xr\"", section).unwrap();
write_linkage(&mut begin).unwrap();
writeln!(begin, ".balign {align_bytes}").unwrap();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This just got moved up so that .def comes before the .pushsection.

Comment on lines -281 to -282
writeln!(end, ".Lfunc_end_{asm_name}:").unwrap();
writeln!(end, ".popsection").unwrap();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LLVM does not emit these, so then we should not need to either

Comment on lines +144 to +151
// Pick a default alignment when the alignment is not explicitly specified.
let align_bytes = match attrs.alignment {
Some(align) => align.bytes(),
None => match asm_binary_format {
BinaryFormat::Coff => 16,
_ => 4,
},
};
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think this really matters but we may as well match LLVM

@folkertdev
Copy link
Copy Markdown
Contributor Author

@bors try jobs=x86_64-mingw-1

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 30, 2026
test `#[naked]` with `#[link_section = "..."]` on windows


try-job: x86_64-mingw-1
@rust-log-analyzer

This comment has been minimized.

@folkertdev folkertdev force-pushed the windows-naked-link-section branch from f445a7c to b1287a8 Compare March 30, 2026 17:08
@rust-bors rust-bors bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 30, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Mar 30, 2026

💔 Test for e60d030 failed: CI. Failed job:

@rust-log-analyzer

This comment has been minimized.

@folkertdev folkertdev force-pushed the windows-naked-link-section branch from b1287a8 to 984fb02 Compare March 30, 2026 18:38
@folkertdev
Copy link
Copy Markdown
Contributor Author

@bors try jobs=x86_64-mingw-1

rust-bors bot pushed a commit that referenced this pull request Mar 30, 2026
test `#[naked]` with `#[link_section = "..."]` on windows


try-job: x86_64-mingw-1
@rust-bors

This comment has been minimized.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Mar 30, 2026

☀️ Try build successful (CI)
Build commit: d4f9c71 (d4f9c7193a4577562f0c4bc2e76a5f1fbff95732, parent: cf7da0b7277cad05b79f91b60c290aa08a17a6f0)

// CHECK-LABEL: naked_empty:
//
// linux,macos,win: ret
// linux,macos,win_x86,win_x86: ret
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You probably meant i686 and x86 here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(Not tested)

Suggested change
// linux,macos,win_x86,win_x86: ret
// linux,macos,win_x86,win_i686: ret

@folkertdev folkertdev force-pushed the windows-naked-link-section branch from 984fb02 to 72b6825 Compare April 6, 2026 12:59
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 6, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@folkertdev
Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 7, 2026
@mati865
Copy link
Copy Markdown
Member

mati865 commented Apr 8, 2026

Thanks.

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 8, 2026

📌 Commit 72b6825 has been approved by mati865

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Apr 8, 2026
rust-bors bot pushed a commit that referenced this pull request Apr 8, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #154912 (Remove `BuiltinLintDiag`)
 - #154598 (test `#[naked]` with `#[link_section = "..."]` on windows)
 - #154719 (Hexagon inline asm: add reg_pair, vreg, vreg_pair, and qreg register classes)
 - #154057 (Parenthesize block-like expressions in index base of pretty printer)
 - #154893 (make `expected_literal` positive)
 - #155002 (Clarify that `core::range` ranges do not have special syntax)
@rust-bors rust-bors bot merged commit b040d54 into rust-lang:main Apr 9, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Apr 9, 2026
rust-timer added a commit that referenced this pull request Apr 9, 2026
Rollup merge of #154598 - folkertdev:windows-naked-link-section, r=mati865

test `#[naked]` with `#[link_section = "..."]` on windows

As a part of #147811 I ran into that we actually don't match (current) LLVM output.

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

Labels

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.

4 participants