rust-lang / rust-lang/rust

std::offload regression - requires lto=fat even though fat-lto is already enabled

Open
#157,563 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-LTO C-bug F-gpu_offload
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

When compiling for gpu offload, we always enable fat-lto:

[profile.release]
lto = "fat"
panic = "abort"

[profile.dev]
lto = "fat"
panic = "abort"

Lately I got hit with the following error when compiling a multi-crate project:
error: using the offload feature requires -C lto=fat

Commenting out the following lines solved it

-                if tcx.sess.lto() != rustc_session::config::Lto::Fat {
-                    let _ = tcx.dcx().emit_almost_fatal(OffloadWithoutFatLTO);
-                }

https://github.com/rust-lang/rust/blob/61d7280f3c4c63fa24c56bdaa9a446151b5a30dc/compiler/rustc_codegen_llvm/src/intrinsic.rs#L239

I expected to see this happen: It used to work

Version it worked on

It most recently worked on: Main, a week or two ago?

Version with regression

current main

cc @bjorn3 since you seem to be leading the lto cleanup efforts. Does my check strike you as something that checks for the wrong thing, or could it have regressed due to your changes? It's nothing urgent, I just disabled it locally till I have more time for debugging next week.

Relatedly, thanks for your cleanups! I wanted to give autodiff with thin-lto another try soonish, now that most of your changes landed.

Backtrace

<backtrace>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at compiler/rustc_codegen_llvm/src/intrinsic.rs around the offload and OffloadWithoutFatLTO check. Reproduce the multi-crate GPU offload build with the shown profile settings, then inspect how the session reports LTO mode. Done means a configuration with fat LTO no longer produces the erroneous requirement error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.