Skip to content

Cross language LTO broken for crates with build.rs #115640

@dragostis

Description

@dragostis

On aarch64-apple-darwin, Rust 1.72 this fails:

cargo new --lib foo && cd foo && echo "fn main() {}" > build.rs && RUSTFLAGS="-Clinker-plugin-lto" cargo build

with ld: unknown option: -plugin-opt=O0.

Building without build.rs works as intended.

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Sep 7, 2023
bjorn3

bjorn3 commented on Sep 7, 2023

@bjorn3
Member

I would guess this is caused by the combination of -Copt-level=0 and -Clinker-plugin-lto. As workaround try adding --target aarch64-apple-darwin to the cargo invocation. That will cause it to ignore RUSTFLAGS for proc macros and build scripts.

added
A-LTOArea: Link-time optimization (LTO)
on Sep 7, 2023
added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LTOArea: Link-time optimization (LTO)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @dragostis@saethlin@bjorn3@rustbot

        Issue actions

          Cross language LTO broken for crates with build.rs · Issue #115640 · rust-lang/rust