On Sat, Jan 4, 2025 at 4:17 PM <poc...@homemail.com> wrote:
>
> > Sent: Saturday, January 04, 2025 at 11:54 AM
> > From: "Lee" <ler...@gmail.com>
> > To: "Franco Martelli" <martelli...@gmail.com>
> > Cc: debian-user@lists.debian.org
> > Subject: Re: debian kernel compiler
> >
> > On Sat, Jan 4, 2025 at 7:52 AM Franco Martelli wrote:
> > >
> > > On 02/01/25 at 12:53, Istvan Toth wrote:
> > > > amd 5700G cpu
> > >
> > > If 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?
> >
> > As long as you're not cross-compiling, how is march=znver3 better than
> > march=native ?
> >
> > 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".
>
> As someone that has compiled many a kernel on different platforms over 30 
> years......
>
> gcc has a facility to interrogate the system it is on, it will tell you what 
> is available on the platform hardware and flag wise.
>
> You should use that.

The option to compile for "this machine" or "compiling machine" is
-march=native. It should be added to CFLAGS and CXXFLAGS, assuming GNU
makefile rules.

The native option is available on certain targets. See, for example,
<https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html>.

Jeff

Reply via email to