Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Determining -march=native output.
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
dE_logics
Advocate
Advocate


Joined: 02 Jan 2009
Posts: 2266
Location: $TERM

PostPosted: Thu Sep 12, 2024 10:28 am    Post subject: Determining -march=native output. Reply with quote

I've tried
Code:
gcc -### -march=native -E /usr/include/stdlib.h 2>&1 | grep "/usr/libexec/gcc/.*cc1"

OR
Code:
gcc -march=native -E -v - </dev/null 2>&1 | grep cc1

(which both result in the same outputs)
I get the following --

Code:
 /usr/libexec/gcc/x86_64-pc-linux-gnu/14/cc1 -E -quiet /usr/include/stdlib.h "-march=znver1" -mmmx -mpopcnt -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -mavx2 -msse4a -mno-fma4 -mno-xop -mfma -mno-avx512f -mbmi -mbmi2 -maes -mpclmul -mno-avx512vl -mno-avx512bw -mno-avx512dq -mno-avx512cd -mno-avx512vbmi -mno-avx512ifma -mno-avx512vpopcntdq -mno-avx512vbmi2 -mno-gfni -mno-vpclmulqdq -mno-avx512vnni -mno-avx512bitalg -mno-avx512bf16 -mno-avx512vp2intersect -mno-3dnow -madx -mabm -mno-cldemote -mclflushopt -mno-clwb -mclzero -mcx16 -mno-enqcmd -mf16c -mfsgsbase -mfxsr -mno-hle -msahf -mno-lwp -mlzcnt -mmovbe -mno-movdir64b -mno-movdiri -mmwaitx -mno-pconfig -mno-pku -mprfchw -mno-ptwrite -mno-rdpid -mrdrnd -mrdseed -mno-rtm -mno-serialize -mno-sgx -msha -mno-shstk -mno-tbm -mno-tsxldtrk -mno-vaes -mno-waitpkg -mno-wbnoinvd -mxsave -mxsavec -mxsaveopt -mxsaves -mno-amx-tile -mno-amx-int8 -mno-amx-bf16 -mno-uintr -mno-hreset -mno-kl -mno-widekl -mno-avxvnni -mno-avx512fp16 -mno-avxifma -mno-avxvnniint8 -mno-avxneconvert -mno-cmpccxadd -mno-amx-fp16 -mno-prefetchi -mno-raoint -mno-amx-complex -mno-avxvnniint16 -mno-sm3 -mno-sha512 -mno-sm4 -mno-apxf -mno-usermsr --param "l1-cache-size=32" --param "l1-cache-line-size=64" --param "l2-cache-size=512" "-mtune=znver1" -dumpbase stdlib.h -dumpbase-ext .h


Based on this I've been trying to cross-compile the kernel with the following KCFLAGS --
Code:
KCFLAGS="-march=znver1 -mmmx -mpopcnt -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -mavx2 -msse4a -mno-fma4 -mno-xop -mfma -mno-avx512f -mbmi -mbmi2 -maes -mpclmul -mno-avx512vl -mno-avx512bw -mno-avx512dq -mno-avx512cd -mno-avx512vbmi -mno-avx512ifma -mno-avx512vpopcntdq -mno-avx512vbmi2 -mno-gfni -mno-vpclmulqdq -mno-avx512vnni -mno-avx512bitalg -mno-avx512bf16 -mno-avx512vp2intersect -mno-3dnow -madx -mabm -mno-cldemote -mclflushopt -mno-clwb -mclzero -mcx16 -mno-enqcmd -mf16c -mfsgsbase -mfxsr -mno-hle -msahf -mno-lwp -mlzcnt -mmovbe -mno-movdir64b -mno-movdiri -mmwaitx -mno-pconfig -mno-pku -mprfchw -mno-ptwrite -mno-rdpid -mrdrnd -mrdseed -mno-rtm -mno-serialize -mno-sgx -msha -mno-shstk -mno-tbm -mno-tsxldtrk -mno-vaes -mno-waitpkg -mno-wbnoinvd -mxsave -mxsavec -mxsaveopt -mxsaves -mno-amx-tile -mno-amx-int8 -mno-amx-bf16 -mno-uintr -mno-hreset -mno-kl -mno-widekl -mno-avxvnni -mno-avx512fp16 -mno-avxifma -mno-avxvnniint8 -mno-avxneconvert -mno-cmpccxadd -mno-amx-fp16 -mno-prefetchi -mno-raoint -mno-amx-complex -mno-avxvnniint16 -mno-sm3 -mno-sha512 -mno-sm4 -mno-apxf -mno-usermsr --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=512 -flto=1 -fuse-linker-plugin -ffat-lto-objects -O3"


However this does not work. After the kernel gets executed, the system reboots.
If I --
Code:
"-march=native -O3 -pipe -Wno-error -flto=1 -fuse-linker-plugin -ffat-lto-objects"


It works. I fail to understand how. Can someone put some light on this?
_________________
My blog
Back to top
View user's profile Send private message
krumpf
Apprentice
Apprentice


Joined: 15 Jul 2018
Posts: 187

PostPosted: Thu Sep 12, 2024 8:44 pm    Post subject: Reply with quote

To check native flags, I use the following :
Code:
gcc -march=native -Q --help=target


Compiling the kernel with gcc using LTO is possible, but requires a patch (read here).
Afaik, many flags you've added seem useless, as march=native should already cover most of them. Check in kernel menuconfig submenu 'Processor type and features' (gentoo-sources package needs USE=experimental to display additional CPUs in the list, notably the intel/amd native)
_________________
Dragon Princess Music Games Heroes and villains
Back to top
View user's profile Send private message
dE_logics
Advocate
Advocate


Joined: 02 Jan 2009
Posts: 2266
Location: $TERM

PostPosted: Fri Sep 13, 2024 3:43 am    Post subject: Reply with quote

I'm cross compiling. -march=native is not an option.

I was aware of gcc -march=native -Q --help=target but it seems it's output is different from the commands which I'm using. However it's more 'official' therefore I'm going to try this out. Also I'll try disabling LTO (although it's working without any patches).

Thanks for notifying about these.
_________________
My blog
Back to top
View user's profile Send private message
dE_logics
Advocate
Advocate


Joined: 02 Jan 2009
Posts: 2266
Location: $TERM

PostPosted: Fri Sep 13, 2024 5:53 am    Post subject: Reply with quote

This results in a bigger and more epic fail.

./arch/x86/include/asm/preempt.h:27: Error: no such instruction: `movl %gs:DWORD PTR __preempt_count[rip],ecx'
_________________
My blog
Back to top
View user's profile Send private message
dE_logics
Advocate
Advocate


Joined: 02 Jan 2009
Posts: 2266
Location: $TERM

PostPosted: Fri Sep 13, 2024 8:27 am    Post subject: Reply with quote

Turns out app-misc/resolve-march-native is the solution.
_________________
My blog
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22617

PostPosted: Fri Sep 13, 2024 2:13 pm    Post subject: Reply with quote

From what architecture are you cross-compiling, and to what architecture? I would not expect -march=native to be meaningful in that situation, since it directs the compiler to build for the system on which it is running.
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