Announcement

Collapse
No announcement yet.

Clang LTO Support Looks Like It Could Land For Linux 5.12

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • AdelKS
    replied
    Thanks! ms178

    Leave a comment:


  • ms178
    replied
    Originally posted by AdelKS View Post

    ms178 I tried with modrobed-db but to no avail, linking takes ages then fails with thousands of objtool errors, then tries again then fails in an infinite loop. I will try to disable retpolines to see. Also, please give me a reference for your aggressive compiler flags and how to enable them for the kernel, I am interested.
    I use the following for KCFLAGS / KCPPFLAGS: "-O3 -march=native -mtune=native -mllvm -polly -mllvm -polly-parallel -fopenmp -mllvm -polly-vectorizer=stripmine -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=24 -mllvm -polly-scheduling=dynamic -mllvm -polly-scheduling-chunksize=1 -fno-math-errno -fno-trapping-math -feliminate-unused-debug-types -fno-semantic-interposition -falign-functions=32"

    KLDFLAGS="-Wl,-O2 -Wl,--as-needed"

    There are several ways how to set these, either by modifying the top level makefile (search for HOSTCFLAGS) or by adding these to your make command line. You have to adjust the polly-num-threads option to the max threads your CPU has.

    Concerning the errors you have seen, I mentioned two Kernel options which are likely the culprit, you need to disable these settings in your Kernel configuration, Retpolines is hidden behind the "avoid speculation in the kernel" option which you would need to disable and make also sure to not trim the generated symbols which would lead to modpost errors.

    Leave a comment:


  • xpris
    replied
    Originally posted by aspen View Post
    The main issue with building the kernel with Clang is that DKMS fucks up, at least on Arch. Rather sad, because it's way too annoying to manually configure DKMS build scripts to actually use something that isn't gcc.
    OpenMandriva ships Clang kernel as option in past release and Clang kernel should be default one in upcoming. So not that hard.

    Leave a comment:


  • aspen
    replied
    The main issue with building the kernel with Clang is that DKMS fucks up, at least on Arch. Rather sad, because it's way too annoying to manually configure DKMS build scripts to actually use something that isn't gcc.

    Leave a comment:


  • AdelKS
    replied
    Originally posted by ms178 View Post

    I saw one to three objtool errors but they weren't fatal for my build. Have you tried to disable Retpolines? I use a minimal config for my system and disable most stuff I don't need. I use -O3 -march=native and aggressive compiler flags (polly) and could get it working on my machine (Haswell-EP + Vega 56) with LLVM/Clang 11.
    ms178 I tried with modrobed-db but to no avail, linking takes ages then fails with thousands of objtool errors, then tries again then fails in an infinite loop. I will try to disable retpolines to see. Also, please give me a reference for your aggressive compiler flags and how to enable them for the kernel, I am interested.

    Leave a comment:


  • CochainComplex
    replied
    Originally posted by ms178 View Post

    I saw one to three objtool errors but they weren't fatal for my build. Have you tried to disable Retpolines? I use a minimal config for my system and disable most stuff I don't need. I use -O3 -march=native and aggressive compiler flags (polly) and could get it working on my machine (Haswell-EP + Vega 56) with LLVM/Clang 11.
    for march=native I also have to get rid of retpoline otherwise build will fail with a huge amout of objtool errors,

    Leave a comment:


  • CochainComplex
    replied
    Originally posted by ms178 View Post

    I've tried it with Clang 11, but if I remember correctly I couldn't get it to compile with Sami's Kernel, but that was a couple of weeks ago. You could try to patch Xanmod changes over Sami's sources and see if it works.

    By the way the new Intel C/C++ compiler (icx/icpx) is also clang based, but I haven't tried to build the Kernel with it yet.
    Thx for the valuable input ! I need some time to experiement. AOCC instead of pure clang might also be already a obstacle.

    Leave a comment:


  • ms178
    replied
    Originally posted by CochainComplex View Post
    I'm already dreaming of an AOCC LTO'ed Xanmod Kernel 5.12 build for my ryzen....
    I've tried it with Clang 11, but if I remember correctly I couldn't get it to compile with Sami's Kernel, but that was a couple of weeks ago. You could try to patch Xanmod changes over Sami's sources and see if it works.

    By the way the new Intel C/C++ compiler (icx/icpx) is also clang based, but I haven't tried to build the Kernel with it yet.

    Leave a comment:


  • ms178
    replied
    Originally posted by AdelKS View Post
    ms178 how do you avoid the objtool errors in practice ? I've been trying to x86_64 LTO for a while, at each new patch version, and the kernel compilation doesn't succeeded and I get a shit ton of objtool errors. I compile linux with the tkg patchset. Do I need to keep -02 or something ?
    I saw one to three objtool errors but they weren't fatal for my build. Have you tried to disable Retpolines? I use a minimal config for my system and disable most stuff I don't need. I use -O3 -march=native and aggressive compiler flags (polly) and could get it working on my machine (Haswell-EP + Vega 56) with LLVM/Clang 11.

    Leave a comment:


  • CochainComplex
    replied
    I'm already dreaming of an AOCC LTO'ed Xanmod Kernel 5.12 build for my ryzen....

    Leave a comment:

Working...
X