On 04/01/25 at 17:54, Lee wrote:
On Sat, Jan 4, 2025 at 7:52 AM Franco Martelli wrote:On 02/01/25 at 12:53, Istvan Toth wrote:amd 5700G cpuIf you are new to kernel compiling maybe you don't know that you can optimize the kernel for your specific CPU architecture, if you are using the GCC compiler: first make a backup copy of the Makefile: $ cd linux-source-6.1 $ cp arch/x86/Makefile arch/x86/Makefile.backup then edit "arch/x86/Makefile": $ cd linux-source-6.1 $ vi arch/x86/Makefile at line 152 change: cflags-$(CONFIG_MK8) += -march=k8 to cflags-$(CONFIG_MK8) += -march=znver3 and below at line 159 change rustflags-$(CONFIG_MK8) += -Ctarget-cpu=k8 to rustflags-$(CONFIG_MK8) += -Ctarget-cpu=znver3 save and exit vim. "znver3" is the GCC's switch for the µarch of your GPU.GPU or central processing unit?
I think is a GPU, the Gentoo wiki ¹ reports that the Kernel's driver is amdgpu ²
As long as you're not cross-compiling, how is march=znver3 better than march=native ?
Yes, "march=native" is the better choice until you haven't trouble (warning…) during the compile process. On my system I cannot use "native" because the optimization option chosen by GCC (bdver2) is not supported by objtool command, objtool is part of "linux-kbuild-6.1" package and it doesn't support all GCC's "march" options.
So in order to compile the kernel on my system I cannot use "march=native" but I've to use "march=bdver1". If you want to know more please see this my old bug report ³
On my machine, 'man gcc' has the "znver1" and "znver2" strings, but no "znver3" so it seems like "march=native" would be more correct.. or at least less chances of an error. ... assuming there are no drawbacks to using "march=native".
To see the available options of GCC's "march" you can use this command: $ gcc --target-help -march=foogiven a bogus architecture (foo) forces GCC to list all "march" options in the error message.
The GCC version I use is: "gcc (Debian 12.2.0-14) 12.2.0" ¹ https://wiki.gentoo.org/wiki/Ryzen#Ryzen_7 ² https://wiki.gentoo.org/wiki/AMDGPU ³ https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=935536 -- Franco Martelli