Skip to content

-plugin-opt linker flags require a leading dash when using GCC as a linker #130583

Open

Description

Hi.
I was testing cross-language LTO with rustc_codegen_gcc (using GCC as the linker) and I needed to add a leading dash to the flags in this code in order to make cross-language LTO working, so that it looks like this:

        self.link_args(&[
            &format!("-plugin-opt=-{opt_level}"),
            &format!("-plugin-opt=-mcpu={}", self.target_cpu),
        ]);

Otherwise, GCC will error out with:

          lto1: fatal error: open O3 failed: No such file or directory
          compilation terminated.
          lto-wrapper: fatal error: gcc returned 1 exit status

It would be nice to have the code working for both GCC and clang.
How would you support both?

Interestingly, clang seems to support a leading dash in the case of -plugin-opt=-mcpu=x86-64, but not -plugin-opt=-O3.
Thanks.

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

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationA-gccThings relevant to the [future] GCC backendT-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

    Issue actions