Skip to content

Add support for generics in offloadand remove no_mangle attribute#159566

Draft
Sa4dUs wants to merge 1 commit into
rust-lang:mainfrom
Sa4dUs:offload-generics
Draft

Add support for generics in offloadand remove no_mangle attribute#159566
Sa4dUs wants to merge 1 commit into
rust-lang:mainfrom
Sa4dUs:offload-generics

Conversation

@Sa4dUs

@Sa4dUs Sa4dUs commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

implements a 3rd pass where we collect kernel instantiations required by offload to work
also enforces consistent mangling for offload functions between host and device

closes: #150985

r? @ZuseZ4

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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. labels Jul 19, 2026
@Sa4dUs
Sa4dUs force-pushed the offload-generics branch from 7fefbf7 to a019aea Compare July 19, 2026 14:10
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
fmt: checked 7031 files
tidy check
tidy [rustdoc_json (src)]: `rustdoc-json-types` modified, checking format version
tidy: Skipping binary file check, read-only filesystem
tidy [style (compiler)]: /checkout/compiler/rustc_monomorphize/src/collector.rs:864: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
tidy [style (compiler)]: FAIL
removing old virtual environment
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'venv'
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'virtualenv'
Requirement already satisfied: pip in ./build/venv/lib/python3.10/site-packages (26.1.2)
linting python files
---
typechecking javascript files
tidy: The following check failed: style (compiler)
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Currently active steps:
test::Tidy {  } at src/bootstrap/src/core/build_steps/test.rs:1568
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy --root-path=/checkout --cargo-path=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo --output-dir=/checkout/obj/build --concurrency=4 --npm-path=/node/bin/yarn --ci=true --extra-checks=py,cpp,js,spellcheck` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1630:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1646:29

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:02:37
  local time: Sun Jul 19 14:16:42 UTC 2026
  network time: Sun, 19 Jul 2026 14:16:42 GMT
##[error]Process completed with exit code 1.
##[group]Run echo "disk usage:"

@@ -534,11 +606,19 @@ fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel
// are not considered for export
let codegen_fn_attrs = tcx.codegen_fn_attrs(sym_def_id);
let is_extern = codegen_fn_attrs.contains_extern_indicator();

@bjorn3 bjorn3 Jul 19, 2026

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.

Perhaps contains_extern_indicator should return true for offload functions?

View changes since the review

});

// Write out the offload manifest of required generic kernel instantiations.
if let Some(path) = tcx.sess.opts.unstable_opts.offload.iter().find_map(|o| {

@bjorn3 bjorn3 Jul 19, 2026

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.

This seems like something that should be done outside of this query. I think this query can be cached, in which case nothing would be written.

View changes since the review

}

// A `HostMetadata` pass only exists to collect the set of generic kernel instantiations
// required by the host and write the offload manifest.

@bjorn3 bjorn3 Jul 19, 2026

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.

Why does this even go through codegen_crate?

View changes since the review

@ZuseZ4

ZuseZ4 commented Jul 20, 2026

Copy link
Copy Markdown
Member

Great improvement ( I'll review later).
@Flakebi fyi, I think now we only have the abi checks left to implement for more complex types and offload should cover all the bigger things we talked about?

@rust-bors

rust-bors Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #159610) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

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

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

std::offload requires mangled names

5 participants