close
Skip to content

offload_kernel macro expansion#156642

Merged
rust-bors[bot] merged 8 commits into
rust-lang:mainfrom
Sa4dUs:offload-macro
May 31, 2026
Merged

offload_kernel macro expansion#156642
rust-bors[bot] merged 8 commits into
rust-lang:mainfrom
Sa4dUs:offload-macro

Conversation

@Sa4dUs
Copy link
Copy Markdown
Contributor

@Sa4dUs Sa4dUs commented May 16, 2026

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 16, 2026
@rust-log-analyzer

This comment has been minimized.

@ZuseZ4
Copy link
Copy Markdown
Member

ZuseZ4 commented May 21, 2026

Nice! I'll look closer after RustWeek, but the tests look fine. We should update the rustc-dev guide to look prettier

Comment thread tests/pretty/offload/offload_kernel.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@ZuseZ4
Copy link
Copy Markdown
Member

ZuseZ4 commented May 25, 2026

Still need to check the rustc code, but the test lgtm, we don't need anything inside of main here.
As part of this pr, can you add an update to our rustc-dev-guide with a full, working example (including main) to show how to use offload in the current state?
It doesn't need to use your safe &mut handling from the other pr to keep it simple.

@rustbot rustbot added the A-rustc-dev-guide Area: rustc-dev-guide label May 25, 2026
Comment thread src/doc/rustc-dev-guide/src/offload/usage.md
@rust-log-analyzer

This comment has been minimized.

Comment thread src/doc/rustc-dev-guide/src/offload/usage.md
Comment thread src/doc/rustc-dev-guide/src/offload/usage.md
@rust-log-analyzer

This comment has been minimized.

) -> Option<(ast::Visibility, ast::FnSig, Ident, ast::Generics, Option<Box<ast::Block>>)> {
match item {
Annotatable::Item(iitem) => match &iitem.kind {
ast::ItemKind::Fn(box ast::Fn { sig, ident, generics, body, .. }) => {
Copy link
Copy Markdown
Member

@ZuseZ4 ZuseZ4 May 26, 2026

Choose a reason for hiding this comment

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

Comment thread src/doc/rustc-dev-guide/src/offload/usage.md Outdated
Comment thread compiler/rustc_span/src/symbol.rs Outdated
Comment thread compiler/rustc_builtin_macros/src/offload.rs Outdated
Annotatable::Item(item)
};

if is_device(ecx) { vec![device_item] } else { vec![host_item] }
Copy link
Copy Markdown
Member

@ZuseZ4 ZuseZ4 May 26, 2026

Choose a reason for hiding this comment

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

This is cursed :D But I kind of like it. Let me just confirm if the surrounding infra is expecting a (builtin) macro to change based on a (tracked) flag.

@JonathanBrouwer, as an attribute person, this is fine, or?

View changes since the review

Copy link
Copy Markdown
Contributor

@JonathanBrouwer JonathanBrouwer May 28, 2026

Choose a reason for hiding this comment

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

I think this is perfectly fine, since no incremental happens on builtin macros, I don't see what could go wrong.

But as an attribute person I've actually not done that much with the builtin_macros attributes yet so don't count me as an expert on this

@rust-log-analyzer

This comment has been minimized.

@xkevio
Copy link
Copy Markdown
Contributor

xkevio commented May 27, 2026

somewhat related since we are updating usage.md anyway:

You might afterwards need to copy your target/release/deps/<lib_name>.bc to lib.bc for now, before the next step.

Is this still needed? The path mentioned differs on my system and "might" implies it might not be needed which would make automation via shell scripting easier.

Comment thread library/core/src/macros/mod.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@Sa4dUs Sa4dUs marked this pull request as ready for review May 29, 2026 12:19
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 29, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 29, 2026

The rustc-dev-guide subtree was changed. If this PR only touches the dev guide consider submitting a PR directly to rust-lang/rustc-dev-guide otherwise thank you for updating the dev guide with your changes.

cc @BoxyUwU, @tshepang

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label May 29, 2026
@Sa4dUs Sa4dUs changed the title wip offload frontend offload_kernel macro expansion May 29, 2026
@ZuseZ4
Copy link
Copy Markdown
Member

ZuseZ4 commented May 30, 2026

@xkevio

Is this still needed? The path mentioned differs on my system and "might" implies it might not be needed which would make automation via shell scripting easier.

I don't think so, but we could correct that directly in the dev guide.

Thanks! This will make the upstreaming of tests nicer. With the latest iteration, we should be able to support generics. Also, having it expand differently for host and device is nice. In the future, we should also think about having a solution to make the function callable on both host and device.

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 30, 2026

📌 Commit 5e81772 has been approved by ZuseZ4

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 May 30, 2026
rust-bors Bot pushed a commit that referenced this pull request May 30, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #157006 (net tests: let the OS pick the port numbers)
 - #157126 (Avoid redundant note when a #[derive] is already suggested)
 - #151690 (std: Refactor `env::var` function)
 - #155826 (std::process: uefi: avoid panicking in Stdio From impls.)
 - #156109 (Migrate libraries from ptr::slice_from_raw_parts to .cast_slice)
 - #156642 (`offload_kernel` macro expansion)
 - #156823 (Add regression test)
 - #157162 (elaborate_drop: Avoid as_mut.unwrap dance, empty vectors are cheap.)

Failed merges:

 - #157173 (rustc-dev-guide subtree update)
@rust-bors rust-bors Bot merged commit d63db62 into rust-lang:main May 31, 2026
12 checks passed
@rustbot rustbot added this to the 1.98.0 milestone May 31, 2026
rust-timer added a commit that referenced this pull request May 31, 2026
Rollup merge of #156642 - Sa4dUs:offload-macro, r=ZuseZ4

`offload_kernel` macro expansion

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

Labels

A-rustc-dev-guide Area: rustc-dev-guide 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. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants