Conversation
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Thinking about this again, this would cause a compilation failure if there is any C code compiled with |
You mean objects files that are not fat compiled with GCC? |
It should currently work without extra configuration when using Clang as C compiler and either Clang as linker driver or LLD as linker though. |
So, we would need to only emit |
|
r? bjorn3 |
This comment has been minimized.
This comment has been minimized.
…r=Kobzol Make `run-make` testsuite work with other codegen backend than LLVM Needed for rust-lang#159924. Currently, we always run `run-make` testsuite with the codegen backend rustc was compiled with. However, in CI it's compiled with LLVM, so when we want to test with GCC (with `--test-codegen-backend`), it compiles `rmake.rs` with the GCC backend, but when running the test, it doesn't use the GCC backend since it just calls `rustc`. So to get around that, I now pass the codegen backend through the environment and set it in the `rustc` function of `run_make_support`. To be noted that for now it's only for the `rustc` function, no other command uses it. Should I extend it right away for all commands (well, likely only `cargo`) or just `rustc` for now is enough? r? @jieyouxu
…r=Kobzol Make `run-make` testsuite work with other codegen backend than LLVM Needed for rust-lang#159924. Currently, we always run `run-make` testsuite with the codegen backend rustc was compiled with. However, in CI it's compiled with LLVM, so when we want to test with GCC (with `--test-codegen-backend`), it compiles `rmake.rs` with the GCC backend, but when running the test, it doesn't use the GCC backend since it just calls `rustc`. So to get around that, I now pass the codegen backend through the environment and set it in the `rustc` function of `run_make_support`. To be noted that for now it's only for the `rustc` function, no other command uses it. Should I extend it right away for all commands (well, likely only `cargo`) or just `rustc` for now is enough? r? @jieyouxu
…r=Kobzol Make `run-make` testsuite work with other codegen backend than LLVM Needed for rust-lang#159924. Currently, we always run `run-make` testsuite with the codegen backend rustc was compiled with. However, in CI it's compiled with LLVM, so when we want to test with GCC (with `--test-codegen-backend`), it compiles `rmake.rs` with the GCC backend, but when running the test, it doesn't use the GCC backend since it just calls `rustc`. So to get around that, I now pass the codegen backend through the environment and set it in the `rustc` function of `run_make_support`. To be noted that for now it's only for the `rustc` function, no other command uses it. Should I extend it right away for all commands (well, likely only `cargo`) or just `rustc` for now is enough? r? @jieyouxu
Rollup merge of #162482 - GuillaumeGomez:run-make-backends, r=Kobzol Make `run-make` testsuite work with other codegen backend than LLVM Needed for #159924. Currently, we always run `run-make` testsuite with the codegen backend rustc was compiled with. However, in CI it's compiled with LLVM, so when we want to test with GCC (with `--test-codegen-backend`), it compiles `rmake.rs` with the GCC backend, but when running the test, it doesn't use the GCC backend since it just calls `rustc`. So to get around that, I now pass the codegen backend through the environment and set it in the `rustc` function of `run_make_support`. To be noted that for now it's only for the `rustc` function, no other command uses it. Should I extend it right away for all commands (well, likely only `cargo`) or just `rustc` for now is enough? r? @jieyouxu
|
#162482 got merged, so after a rebase, this PR should be ready to go. |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
… GCC do LTO when using rustc_codegen_gcc
| @@ -1,4 +1,5 @@ | |||
| //@ ignore-cross-compile (need to run fake linker) | |||
| //@ ignore-backends: gcc | |||
There was a problem hiding this comment.
Not sure if there would be a way to make this test "generic" on whether the flag -fno-lto is present or not, but I guess it's not super important anyway.
|
The test now passes. |
Yes.
This is the default mode for GCC/Clang and it should work as long as you don't explicitly pass
No, LLD doesn't handle GIMPLE bitcode at all (it doesn't even support the plugins).
Only when the host Clang version that produced the objects matches LLD version (by default the one shipped with particular Rust version). Also, when using Clang + any linker other than LLD
For Clang it will make no difference since
Codegen options will likely need to be updated to reflect that: https://doc.rust-lang.org/rustc/codegen-options/index.html#linker-plugin-lto One thing here I'm failing to understand is why should GCC backend differ from LLVM one here. Since libstd produced by LLVM backend is a fat object, LLD probably does some kind of LTO on it? |
GCC needs additional files to do LTO ( Also, is cg_llvm really automatically doing LTO when building a program that depends on the std because the std is a fat object (even when not asked by the user)? |
|
As I understand it, in the LLVM world the embedded bitcode of fat objects is ignored by the linker unless |
Even for Rust? I thought you said otherwise above in this thread. |
|
Okay, those are pretty compelling arguments for disabling plugin based LTO with GCC backend. I made small experiment with C code and LLD will only use bitcode from fat objects if given With Rust the situation might be different because Clang puts bitcode in |
According to https://llvm.org/docs/BitCodeFormat.html#native-object-file-wrapper-format |
Just to make sure I understand, this is not actually the case? Would using clang without |
|
I would have expected it to do LTO for C code that is compiled with ; echo 'int main() { return 0; }' | clang -flto -x c -c - -o foo.o
; clang foo.o -o foo
foo.o: file not recognized: file format not recognized
clang: error: linker command failed with exit code 1 (use -v to see invocation)
; clang foo.o -o foo -flto
; clang foo.o -o foo -fuse-ld=lld
; ./foo |
But does Rust send |
No, only when using
lld does do LTO without |
|
Is there anything we should change in this PR or is it good to merge? |
View all comments
More info on this Zulip thread.
cc @bjorn3