Repository navigation
Revert "Make: use gcc as LD" - #3900
Conversation
Yes, it's a little bit confusing, but if you want to enable LTO, you must use gcc to drive the link process as far as I know. If we can't find a method to let ld work with LTO, it's better to keep the change as it.
|
Agreed that Link Time Optimization would be a good thing to make a reality, if possible. We may run into some additional fallout from the 45672c2 change, like what happened with clang (fixed in #3904). But so far it looks good. |
https://github.com/torvalds/linux/blob/009c9aa5be652675a06d5211e1640e02bbb1c33d/Makefile#L920 |
|
i played a bit with LTO. also, it seems gcc folks are thinking ld should work. my impression is that it isn't a good idea to use LD=cc for the LTO purpose either. |
Linux Kernel support LTO with Clang-only so far, and using the LLD, which is the LLVM linker.
I believe that wiki page might not be up-to-date, since it is already a bit old. Is there a specific detail from this guide you'd like to bring to the discussion?
I understand that a future support for LTO should not be the sole reason for that decision, and I agree that removing |
yes.
have you looked at the example i provided?
|
|
I have no opinion if this should be reverted or not, but doing changes like this repeatedly is hard for commercial users because all out-of-tree board Make.defs files needs to be modified every single time when something like this is either applied or reverted. At least the -Wl, should have been expanded from make variable, say $(LDFLAGPREFIX), so that changing between gcc and ld does not need to touch so many files again. |
I agree that we should not cause a lot of additional work to downstream users.
I think that is a good idea. The good news is: although #3836 is on master, it has not been released. A make variable could be added now. Commercial users who work with official releases will only have to make 1 change, not 2, if we do it now, before the next release. (Users who track master are sure to experience a bumpy road no matter what, so if they've updated their boards already, they will have to do it again; but this could be easier than the first time because the diff of the 1st change will show them exactly where to make the 2nd change.) |
|
my suggestion is
|
|
@xiaoxiang781216 @gustavonihei |
|
I am fine with either approach, but could you incorporate your LTO demo into mainline? Otherwise, the same change may be created again for LTO. |
maybe i will try. |
|
@gustavonihei was your opinion? |
My opinion is somewhat like yours, I am fine either way. |
|
@xiaoxiang781216 @gustavonihei i haven't found a chance to investigate the lto things. |
|
btw, i updated my demo to use a library. it seems working for both of gcc and clang so far. |
|
@xiaoxiang781216 @gustavonihei @AlexanderVasiljev are we going to have more PRs like #4173? Otherwise we should merge this one, it's been sitting here for a while. |
… Clang" This reverts commit ba1f730.
…ld to gcc": This reverts commit 6545b95.
This reverts commit 45672c2. Because: * It's very confusing to have cc as LD. * I don't see what "-nostartfiles -nodefaultlibs" in LDFLAGS are supposed to do when we use LD directly. It would be simpler to remove them from our LDFLAGS.
Remove -Wl, in LDFLAGS.
These options are not ld options. The recent versions of ld complain on them. https://sourceware.org/pipermail/binutils/2021-June/116826.html
…ilds" This reverts commit 6c2c70c.
|
@gustavonihei and @Ouss4 how about we merge this PR? because using gcc as ld doesn't work well with clang toolchain. I can provide lto demo with ld after this PR merge. |
|
@yamt @xiaoxiang781216 please take a look, this Revert brought back an old issue, now all ARM and MIPS boards are breaking because of it: "arm-none-eabi-ld: Error: unable to disambiguate: -nostartfiles (did you mean --nostartfiles ?)" As @hartmannathan reported here #3209 it will happen if "Binutils is updated to 2.36.x". So probably our CI is using an old version and the problem doesn't show up. |
|
I thought about the idea of going ahead and removing "-nostartfiles -nodefaultlibs" from all LDFLAGS, but we cannot do it without double check each toolchain. For example: This is a toolchain that use to be very outdated and removing those flags could bring unexpected results. |
Summary
This reverts commit 45672c2.
Because:
supposed to do when we use LD directly. It would be simpler to
remove them from our LDFLAGS.
Impact
Testing