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

use non-LTO IPO cflags, adjust ldflags for Identical Code Folding and… #1

Closed
wants to merge 1 commit into from

Conversation

tpgxyz
Copy link
Contributor

@tpgxyz tpgxyz commented Apr 13, 2021

use non-LTO IPO cflags, adjust ldflags for Identical Code Folding and function Garbage Collector

Here is the long story short:

  1. lld has a hardcoded options in a patch:
    --icf=safe
    --gc-sections
  2. There are some software that intentionally does not use of {C,LD}FLAGS and this means above hardcoded flags can not be overrided by:
  • exporting LDFLAGS or redifining %build_ldfags
  • patching source files to and opposite options that disables above flags
  1. lld --icf=safe implementation is diffrent from ld.bfd!
  1. Function Garbage Collector break things when upstream wants to keep specific input sections:
  1. Using --gc-sections without -ffunction-sections -fdata-sections makes only half of the success

I did compile llvm without above hardcodes:
OpenMandrivaAssociation/llvm#12
then i build kernel-release for x86_64 and aarch64. Both kernels clang flovours uses lld as default linker.
x86_64: https://abf.openmandriva.org/build_lists/40029
aarch64: https://abf.openmandriva.org/build_lists/40016

[root@tpg-latitude5490 tpg]# uptime
 18:15:31 up 44 min,  4 users,  load average: 0,44, 0,39, 0,36
[root@tpg-latitude5490 tpg]# uname -a
Linux tpg-latitude5490 5.11.13-desktop-clang-1omv4050 #1 SMP PREEMPT Tue Apr 13 13:10:26 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
[root@tpg-latitude5490 tpg]# grep LLD /boot/config-5.11.13-desktop-clang-1omv4050 
CONFIG_LD_IS_LLD=y
CONFIG_LLD_VERSION=120000

@berolinux
Copy link
Member

Something along those lines makes sense.
A few things:
There is no hardcode. We merely flip the defaults to save some space in a gazillion packages.
To override the --icf=safe default, you can use --icf=none.
To override the --gc-sections default, you can use --no-gc-sections.
It probably makes sense to keep current defaults and just override them where necessary, but having a well defined way to do that instead of having to fiddle with the flags manually is a good idea

@tpgxyz
Copy link
Contributor Author

tpgxyz commented Apr 13, 2021

There is no hardcode. We merely flip the defaults to save some space in a gazillion packages.

Few of these defaults were moved to this PR so rpm macros may catch them.

To override the --icf=safe default, you can use --icf=none.
To override the --gc-sections default, you can use --no-gc-sections.

Some Makefies does not pass any LDFLAGS, see KBUILD in couple of places, so without patching Makefiles you are not able to pass --icf=none or --no-gc-sections. Please see ClangBuiltLinux bugs.
Anyways this PR pushes things forward, to explicitly set FLAGS instead of hardcoding these in some lld patch.

@tpgxyz tpgxyz force-pushed the master branch 3 times, most recently from 0dcd547 to 4583d63 Compare July 1, 2022 23:20
@rugyada rugyada closed this Sep 25, 2022
@rugyada rugyada deleted the lld branch September 25, 2022 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants