Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
No march=znver1 option when compiling kernel with Clang
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
PurpleGerbim
n00b
n00b


Joined: 10 Jul 2021
Posts: 5

PostPosted: Thu Jul 29, 2021 8:23 am    Post subject: No march=znver1 option when compiling kernel with Clang Reply with quote

Hello good Gentoo folk,

I've been happily running Gentoo on an AMD Ryzen processor (1800x) and compiling my kernel with the experimental USE flag, to compile the kernel with march=znver1 (Under Processor type and features -->Processor family (AMD ZEN)).

I've recently switched from GCC to Clang as the system compiler, and noticed the option went missing, even when compiling with the same USE flags and settings. Sure enough, when I set the kernel to compile with GCC again, the option reappeared.

This leads me to two questions:

1. Since I have march=native set globally, will the kernel compile with znver1 under Clang? (I don't recall it does with GCC)
2. If not, is there a way to compile the kernel with march=nativeunder Clang?


I'm not sure if I need to attach any details - if there's anything missing please let me know and I'll be sure to add it.


Thanks!
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Thu Jul 29, 2021 9:55 am    Post subject: Reply with quote

Quote:

Since I have march=native set globally, will the kernel compile with znver1 under Clang? (I don't recall it does with GCC)

No the kernel overrides all CFLAGS settings.It uses its own.
Try to manually add
Code:

CONFIG_GENERIC_CPU=n
CONFIG_MNATIVE_AMD=y

in .config
and run make and see if it recognizes it.It will prompt you to reconfirm.
If not it means it is ignored.
_________________
:)
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Thu Jul 29, 2021 6:57 pm    Post subject: Reply with quote

not a clang thing, its a gentoo specific patchset that hasn't been updated. I went back to 5.13.0 and checked using make LD=ld.bfd ... and with make LLVM=1 LLVM_IAS=1 and the options are not there
_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Thu Jul 29, 2021 7:28 pm    Post subject: Reply with quote

Naib
Quote:

I went back to 5.13.0 and checked

Indeed but in 5.13.1 they are available.
_________________
:)
Back to top
View user's profile Send private message
PurpleGerbim
n00b
n00b


Joined: 10 Jul 2021
Posts: 5

PostPosted: Thu Jul 29, 2021 7:28 pm    Post subject: Reply with quote

Hi, Thank you both for responding!
Quote:
Try to manually add
Code:

CONFIG_GENERIC_CPU=n
CONFIG_MNATIVE_AMD=y

in .config


make seems to ignore it as you mentioned might happen, but this error pops up as well:
Code:
.config:418:warning: override: MNATIVE_AMD changes choice state


Quote:
not a clang thing, its a gentoo specific patchset that hasn't been updated. I went back to 5.13.0 and checked using make LD=ld.bfd ... and with make LLVM=1 LLVM_IAS=1 and the options are not there


I guess this is it then - I had similar results.

Thanks!
Back to top
View user's profile Send private message
PurpleGerbim
n00b
n00b


Joined: 10 Jul 2021
Posts: 5

PostPosted: Sat Aug 14, 2021 2:08 pm    Post subject: Reply with quote

Hi again,

I was able to get this working on the latest kernel (5.13.10-gentoo) by running

Code:
LLVM=1 LLVM_IAS=1 CC=clang HOSTCC=clang make -j$(nproc) && LLVM=1 LLVM_IAS=1 CC=clang HOSTCC=clang  make modules_install && LLVM=1 LLVM_IAS=1 CC=clang HOSTCC=clang make install


and confirmed my kernel was clang based by reading the .config. make also prompted my to choose Clang's LTO.

Even though Clang did not appear under make menuconfig, I managed to compile the kernel with it using the command above.

Thanks for pointing me in the right direction, and hope this helps!
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Sat Aug 14, 2021 2:50 pm    Post subject: Reply with quote

PurpleGerbim,

Read the kernel Makefile.
There are some user accessible knobs you can twiddle, if you know the names.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum