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

-Clinker-plugin-lto breaks with -Copt-level=s/z #75940

Closed
jonas-schievink opened this issue Aug 26, 2020 · 0 comments · Fixed by #75956
Closed

-Clinker-plugin-lto breaks with -Copt-level=s/z #75940

jonas-schievink opened this issue Aug 26, 2020 · 0 comments · Fixed by #75956
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-embedded Working group: Embedded systems

Comments

@jonas-schievink
Copy link
Contributor

$ cat main.rs
fn main() {
    println!("Hello World!");
}

Using the instructions at https://doc.rust-lang.org/stable/rustc/linker-plugin-lto.html#cc-code-as-a-dependency-in-rust.

Works fine with numerical opt-levels:

$ rustc main.rs -Clinker-plugin-lto -Clinker=clang -Clink-arg=-fuse-ld=lld -Copt-level=3

Breaks with -Copt-level=s/z:

$ rustc main.rs -Clinker-plugin-lto -Clinker=clang -Clink-arg=-fuse-ld=lld -Copt-level=s
error: linking with `clang` failed: exit code: 1
  |
  = note: "clang" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,-plugin-opt=Oz" "-Wl,-plugin-opt=mcpu=x86-64" "-L" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "main.main.7rcbfp3g-cgu.0.rcgu.o" "main.main.7rcbfp3g-cgu.1.rcgu.o" "-o" "main" "main.4s37gsrti678ik8u.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-c147cd9c030850ef.rlib" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-7e62a3a07bb85bc1.rlib" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-000f77165d4d2d36.rlib" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-7dc0cb59ed386ac6.rlib" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace-9248bfbd7273ac3d.rlib" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace_sys-b75363fb938de39d.rlib" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-7bbe96f555da4ad6.rlib" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-a145493c64eeb044.rlib" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-9577436fc6fce6bc.rlib" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-b3376c0a2b35415c.rlib" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-5708f6b2b59b6e0f.rlib" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-e9fd09201d99d6f4.rlib" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-914c6ef6f5cf354a.rlib" "-Wl,--end-group" "/home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-1445b6c7903692a2.rlib" "-Wl,-Bdynamic" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-ldl" "-lutil" "-fuse-ld=lld"
  = note: ld.lld: error: -plugin-opt=Oz: number expected, but got 'z'
          clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
@jonas-schievink jonas-schievink added A-codegen Area: Code generation T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. WG-embedded Working group: Embedded systems A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. labels Aug 26, 2020
@bors bors closed this as completed in 62cbe81 Oct 12, 2020
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-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-embedded Working group: Embedded systems
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant