Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
antoyo opened this issue Sep 19, 2024 · 2 comments
Open
Labels
A-codegen Area: Code generation A-gcc Things relevant to the [future] GCC backend T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@antoyo
Copy link
Contributor

antoyo commented Sep 19, 2024

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.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 19, 2024
@GuillaumeGomez GuillaumeGomez added A-codegen Area: Code generation T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-gcc Things relevant to the [future] GCC backend and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 19, 2024
@bjorn3
Copy link
Member

bjorn3 commented Sep 19, 2024

Do you need --plugin-opt=-..., -plugin-opt=--... or --plugin-opt=--...?

@antoyo
Copy link
Contributor Author

antoyo commented Sep 19, 2024

Here's what works:

-Wl,-plugin-opt=-O3,-plugin-opt=-mcpu=x86-64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-gcc Things relevant to the [future] GCC backend T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants