Skip to content

bpf: return results larger than one register indirectly - #147638

Merged
bors merged 1 commit into
rust-lang:masterfrom
alessandrod:indirect-res
Oct 15, 2025
Merged

bpf: return results larger than one register indirectly#147638
bors merged 1 commit into
rust-lang:masterfrom
alessandrod:indirect-res

Conversation

@alessandrod

Copy link
Copy Markdown
Contributor

Fixes triggering the "only small returns supported" error in the BPF target.

@rustbotrustbot 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 Oct 13, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot

This comment has been minimized.

@rustbot

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master 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.

@alessandrod

Copy link
Copy Markdown
ContributorAuthor

⚠️Warning⚠️

* This PR is based on an [upstream commit](https://github.com/rust-lang/rust/commit/41a79f1862aa6b81bac674598e275e80e9f09eb9) that is older than 28 days.

whoops, fixed

@rust-log-analyzer

This comment has been minimized.

@alessandrod

alessandrod commented Oct 13, 2025

Copy link
Copy Markdown
ContributorAuthor
#![no_std]
#![no_main]
#[unsafe(no_mangle)]
pub unsafe fn outer(a: u64) -> u64 {
match try_inner(a) {
Ok(v) => v,
Err(()) => 0,
}
}
#[inline(never)]
fn try_inner(a: u64) -> Result<u64, ()> {
if a == 0 { Err(()) } else { Ok(a + 1) }
}

nightly without fix

sol@dev-alessandrod:/tmp/b$ cargo +nightly rustc --target=bpfel-unknown-none -Z build-std=core --release
Compiling b v0.1.0 (/tmp/b)
error: linking with `bpf-linker` failed: exit status: 1
|
= note: "bpf-linker" "--export-symbols" "/tmp/rustcpWeU1V/symbols" "/tmp/rustcpWeU1V/symbols.o" "<1 object files omitted>" "/tmp/b/target/bpfel-unknown-none/release/deps/{libcore-e2186c15db672292,libcompiler_builtins-33b0f57b988ec271}.rlib" "-L" "/tmp/rustcpWeU1V/raw-dylibs" "--cpu" "generic" "-o" "/tmp/b/target/bpfel-unknown-none/release/deps/b-89f0e403b55dfe7b" "-O3" "--debug"
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: ERROR llvm: <unknown>:0:0: in function outer i64 (i64): only small returns supported
ERROR llvm: <unknown>:0:0: in function _ZN1b9try_inner17ha7a0d46aa0ff6c7eE { i64, i64 } (i64): aggregate returns are not supported
Error: LLVM issued diagnostic with error severity
error: could not compile `b` (bin "b") due to 1 previous error

with this PR

sol@dev-alessandrod:/tmp/b$ cargo +stage1 rustc --target=bpfel-unknown-none -Z build-std=core --release
Compiling core v0.0.0 (/home/sol/src/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/core)
Compiling compiler_builtins v0.1.160 (/home/sol/src/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins)
Compiling b v0.1.0 (/tmp/b)
Finished `release` profile [optimized] target(s) in 18.25s

@wesleywiser

Copy link
Copy Markdown
Member

Thanks @alessandrod!

@bors r+ rollup

@bors

bors commented Oct 13, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 246f764 has been approved by wesleywiser

It is now in the queue for this repository.

@borsbors 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 Oct 13, 2025
Comment threadcompiler/rustc_target/src/callconv/bpf.rs Outdated
Fixes triggering the "only small returns supported" error in the BPF
target.
@wesleywiser

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Oct 14, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 056c2da has been approved by wesleywiser

It is now in the queue for this repository.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 14, 2025
…wiser
bpf: return results larger than one register indirectly
Fixes triggering the "only small returns supported" error in the BPF target.
This was referenced Oct 14, 2025
bors added a commit that referenced this pull request Oct 14, 2025
Rollup of 12 pull requests
Successful merges:
- #146187 (Unstably constify `ptr::drop_in_place` and related methods)
- #146503 (std: improve handling of timed condition variable waits on macOS)
- #147526 (Move computation of allocator shim contents to cg_ssa)
- #147630 (Bitset cleanups)
- #147638 (bpf: return results larger than one register indirectly)
- #147666 (Replace manual implementation with `carrying_mul_add`)
- #147669 (fix missing link to `std::char` in `std` docs)
- #147673 (pretty print u128 with display)
- #147677 (Fewer exceptions in `span()` on parsed attributes)
- #147680 (Fix ICE caused by associated_item_def_ids on wrong type in resolve diag)
- #147682 (convert `rustc_main` to the new attribute parsing infrastructure)
- #147683 (only check duplicates on old/unparsed attributes)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 10e535a into rust-lang:masterOct 15, 2025
10 checks passed
@rustbotrustbot added this to the 1.92.0 milestone Oct 15, 2025
@alessandrod
alessandrod deleted the indirect-res branch October 15, 2025 00:07
rust-timer added a commit that referenced this pull request Oct 15, 2025
Rollup merge of #147638 - alessandrod:indirect-res, r=wesleywiser
bpf: return results larger than one register indirectly
Fixes triggering the "only small returns supported" error in the BPF target.
github-actionsBot pushed a commit to rust-lang/miri that referenced this pull request Oct 15, 2025
Rollup of 12 pull requests
Successful merges:
- rust-lang/rust#146187 (Unstably constify `ptr::drop_in_place` and related methods)
- rust-lang/rust#146503 (std: improve handling of timed condition variable waits on macOS)
- rust-lang/rust#147526 (Move computation of allocator shim contents to cg_ssa)
- rust-lang/rust#147630 (Bitset cleanups)
- rust-lang/rust#147638 (bpf: return results larger than one register indirectly)
- rust-lang/rust#147666 (Replace manual implementation with `carrying_mul_add`)
- rust-lang/rust#147669 (fix missing link to `std::char` in `std` docs)
- rust-lang/rust#147673 (pretty print u128 with display)
- rust-lang/rust#147677 (Fewer exceptions in `span()` on parsed attributes)
- rust-lang/rust#147680 (Fix ICE caused by associated_item_def_ids on wrong type in resolve diag)
- rust-lang/rust#147682 (convert `rustc_main` to the new attribute parsing infrastructure)
- rust-lang/rust#147683 (only check duplicates on old/unparsed attributes)
r? `@ghost`
`@rustbot` modify labels: rollup
github-actionsBot pushed a commit to rust-lang/rust-analyzer that referenced this pull request Nov 3, 2025
Rollup of 12 pull requests
Successful merges:
- rust-lang/rust#146187 (Unstably constify `ptr::drop_in_place` and related methods)
- rust-lang/rust#146503 (std: improve handling of timed condition variable waits on macOS)
- rust-lang/rust#147526 (Move computation of allocator shim contents to cg_ssa)
- rust-lang/rust#147630 (Bitset cleanups)
- rust-lang/rust#147638 (bpf: return results larger than one register indirectly)
- rust-lang/rust#147666 (Replace manual implementation with `carrying_mul_add`)
- rust-lang/rust#147669 (fix missing link to `std::char` in `std` docs)
- rust-lang/rust#147673 (pretty print u128 with display)
- rust-lang/rust#147677 (Fewer exceptions in `span()` on parsed attributes)
- rust-lang/rust#147680 (Fix ICE caused by associated_item_def_ids on wrong type in resolve diag)
- rust-lang/rust#147682 (convert `rustc_main` to the new attribute parsing infrastructure)
- rust-lang/rust#147683 (only check duplicates on old/unparsed attributes)
r? `@ghost`
`@rustbot` modify labels: rollup
Kobzol pushed a commit to Kobzol/rustc_codegen_gcc that referenced this pull request Dec 21, 2025
Rollup of 12 pull requests
Successful merges:
- rust-lang/rust#146187 (Unstably constify `ptr::drop_in_place` and related methods)
- rust-lang/rust#146503 (std: improve handling of timed condition variable waits on macOS)
- rust-lang/rust#147526 (Move computation of allocator shim contents to cg_ssa)
- rust-lang/rust#147630 (Bitset cleanups)
- rust-lang/rust#147638 (bpf: return results larger than one register indirectly)
- rust-lang/rust#147666 (Replace manual implementation with `carrying_mul_add`)
- rust-lang/rust#147669 (fix missing link to `std::char` in `std` docs)
- rust-lang/rust#147673 (pretty print u128 with display)
- rust-lang/rust#147677 (Fewer exceptions in `span()` on parsed attributes)
- rust-lang/rust#147680 (Fix ICE caused by associated_item_def_ids on wrong type in resolve diag)
- rust-lang/rust#147682 (convert `rustc_main` to the new attribute parsing infrastructure)
- rust-lang/rust#147683 (only check duplicates on old/unparsed attributes)
r? `@ghost`
`@rustbot` modify labels: rollup
Kobzol pushed a commit to Kobzol/rustc_codegen_cranelift that referenced this pull request Dec 29, 2025
Rollup of 12 pull requests
Successful merges:
- rust-lang/rust#146187 (Unstably constify `ptr::drop_in_place` and related methods)
- rust-lang/rust#146503 (std: improve handling of timed condition variable waits on macOS)
- rust-lang/rust#147526 (Move computation of allocator shim contents to cg_ssa)
- rust-lang/rust#147630 (Bitset cleanups)
- rust-lang/rust#147638 (bpf: return results larger than one register indirectly)
- rust-lang/rust#147666 (Replace manual implementation with `carrying_mul_add`)
- rust-lang/rust#147669 (fix missing link to `std::char` in `std` docs)
- rust-lang/rust#147673 (pretty print u128 with display)
- rust-lang/rust#147677 (Fewer exceptions in `span()` on parsed attributes)
- rust-lang/rust#147680 (Fix ICE caused by associated_item_def_ids on wrong type in resolve diag)
- rust-lang/rust#147682 (convert `rustc_main` to the new attribute parsing infrastructure)
- rust-lang/rust#147683 (only check duplicates on old/unparsed attributes)
r? `@ghost`
`@rustbot` modify labels: rollup
christian-schilling pushed a commit to christian-schilling/rustc_codegen_cranelift that referenced this pull request Jan 27, 2026
Rollup of 12 pull requests
Successful merges:
- rust-lang/rust#146187 (Unstably constify `ptr::drop_in_place` and related methods)
- rust-lang/rust#146503 (std: improve handling of timed condition variable waits on macOS)
- rust-lang/rust#147526 (Move computation of allocator shim contents to cg_ssa)
- rust-lang/rust#147630 (Bitset cleanups)
- rust-lang/rust#147638 (bpf: return results larger than one register indirectly)
- rust-lang/rust#147666 (Replace manual implementation with `carrying_mul_add`)
- rust-lang/rust#147669 (fix missing link to `std::char` in `std` docs)
- rust-lang/rust#147673 (pretty print u128 with display)
- rust-lang/rust#147677 (Fewer exceptions in `span()` on parsed attributes)
- rust-lang/rust#147680 (Fix ICE caused by associated_item_def_ids on wrong type in resolve diag)
- rust-lang/rust#147682 (convert `rustc_main` to the new attribute parsing infrastructure)
- rust-lang/rust#147683 (only check duplicates on old/unparsed attributes)
r? `@ghost`
`@rustbot` modify labels: rollup
christian-schilling pushed a commit to christian-schilling/rustc_codegen_cranelift that referenced this pull request Jan 27, 2026
Rollup of 12 pull requests
Successful merges:
- rust-lang/rust#146187 (Unstably constify `ptr::drop_in_place` and related methods)
- rust-lang/rust#146503 (std: improve handling of timed condition variable waits on macOS)
- rust-lang/rust#147526 (Move computation of allocator shim contents to cg_ssa)
- rust-lang/rust#147630 (Bitset cleanups)
- rust-lang/rust#147638 (bpf: return results larger than one register indirectly)
- rust-lang/rust#147666 (Replace manual implementation with `carrying_mul_add`)
- rust-lang/rust#147669 (fix missing link to `std::char` in `std` docs)
- rust-lang/rust#147673 (pretty print u128 with display)
- rust-lang/rust#147677 (Fewer exceptions in `span()` on parsed attributes)
- rust-lang/rust#147680 (Fix ICE caused by associated_item_def_ids on wrong type in resolve diag)
- rust-lang/rust#147682 (convert `rustc_main` to the new attribute parsing infrastructure)
- rust-lang/rust#147683 (only check duplicates on old/unparsed attributes)
r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

7 participants

@alessandrod@rustbot@rust-log-analyzer@wesleywiser@bors@bjorn3@jackh726