Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Kernel & Hardware
  • Search

Does genkernel compile with make.conf CFLAGS?

Kernel not recognizing your hardware? Problems with power management or PCMCIA? What hardware is compatible with Gentoo? See here. (Only for kernels supported by Gentoo.)
Post Reply
Advanced search
14 posts • Page 1 of 1
Author
Message
EliasJonsson
n00b
n00b
User avatar
Posts: 53
Joined: Wed Oct 18, 2017 12:32 pm

Does genkernel compile with make.conf CFLAGS?

  • Quote

Post by EliasJonsson » Mon Apr 03, 2023 4:29 am

Hello Gentoo Community,
when using genkernel, is the kernel compiled using the custom cflags in the /etc/portage/make.conf when the

Code: Select all

genkernel all
is executed?
Last edited by EliasJonsson on Mon Apr 03, 2023 3:16 pm, edited 2 times in total.
Top
EliasJonsson
n00b
n00b
User avatar
Posts: 53
Joined: Wed Oct 18, 2017 12:32 pm

  • Quote

Post by EliasJonsson » Mon Apr 03, 2023 5:40 am

found the solution elsewhere:

Code: Select all

nano /etc/genkernel.conf
And add the line:

Code: Select all

KERNEL_CFLAGS="-O2 -march=native -pipe -fomit-frame-pointer"
Then go to linux source folder and issue the command:

Code: Select all

genkernel all
Verify CFLAGS using

Code: Select all

nano /var/log/genkernel.log
look for the entry
genkernel.log wrote:* KERNEL_CFLAGS
My entry was:
genkernel.log wrote: * KERNEL_CFLAGS set in config file to "-O2 -march=native -pipe -fomit-frame-pointer"
Last edited by EliasJonsson on Mon Apr 03, 2023 2:58 pm, edited 4 times in total.
Top
logrusx
Advocate
Advocate
User avatar
Posts: 3534
Joined: Thu Feb 22, 2018 2:29 pm

  • Quote

Post by logrusx » Mon Apr 03, 2023 6:04 am

I think it depends on your kernel config.

Best Regards,
Georgi
Top
Gladdle
Guru
Guru
User avatar
Posts: 348
Joined: Sun Jul 27, 2008 12:44 am
Location: Cleebronn, Germany
Contact:
Contact Gladdle
Website

  • Quote

Post by Gladdle » Mon Apr 03, 2023 8:13 am

May i quote from the file /etc/genkernel.conf:

Code: Select all

# Genkernel uses an independent configuration for MAKEOPTS, and does not source
# /etc/portage/make.conf . You can override the default setting by uncommenting
# and tweaking the following line. Default setting is set up by
# ${GK_SHARE}/${ARCH_OVERRIDE}/config.sh . The recommended value for -j
# argument is: <number of processors>*<number of cores per processor>+1
#MAKEOPTS="$(portageq envvar MAKEOPTS)"
Top
EliasJonsson
n00b
n00b
User avatar
Posts: 53
Joined: Wed Oct 18, 2017 12:32 pm

  • Quote

Post by EliasJonsson » Mon Apr 03, 2023 3:21 pm

Gladdle wrote:May i quote from the file /etc/genkernel.conf:

Code: Select all

# Genkernel uses an independent configuration for MAKEOPTS, and does not source
# /etc/portage/make.conf . You can override the default setting by uncommenting
# and tweaking the following line. Default setting is set up by
# ${GK_SHARE}/${ARCH_OVERRIDE}/config.sh . The recommended value for -j
# argument is: <number of processors>*<number of cores per processor>+1
#MAKEOPTS="$(portageq envvar MAKEOPTS)"
Does that mean that CFLAGS can be gotten from make.conf?

I followed my own steps on how to make the kernel take custom CFLAGS, but the resulting binary was exactly the same as the un-optimized. What do you think, were the CFLAGS not applied to the kernel compilation process properly since the resulting binary size were exactly the same as the old one?
Top
Hu
Administrator
Administrator
Posts: 24401
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Mon Apr 03, 2023 4:56 pm

Assuming that the shown commented example means that shell indirections are legal here, then yes, I expect you could make it look up the CFLAGS configured for Portage.

Matching size is suspicious, but not definitive. What command line did make use to run gcc on the kernel source? What did you do that you expected to influence the kernel's build?
Top
EliasJonsson
n00b
n00b
User avatar
Posts: 53
Joined: Wed Oct 18, 2017 12:32 pm

  • Quote

Post by EliasJonsson » Tue Apr 04, 2023 2:07 am

Hu wrote: Matching size is suspicious, but not definitive. What command line did make use to run gcc on the kernel source? What did you do that you expected to influence the kernel's build?
See post #2 in this thread, I think that post answer your questions.

To get to the bottom with the similarities of the old, unoptimized kernel, I calculated the md5sum of the contents of the two kernels.

Code: Select all

lee /boot # md5sum vmlinuz-6.1.19-gentoo-x86_64
eb33224e0a715b8fb78a25047f0572ed  vmlinuz-6.1.19-gentoo-x86_64
lee /boot # md5sum vmlinuz-6.1.19-gentoo-x86_64.old 
54e162e35f0e8772be3c013f454e67cb  vmlinuz-6.1.19-gentoo-x86_64.old
lee /boot # du -b vmlinuz-6.1.19-gentoo-x86_64
10238784	vmlinuz-6.1.19-gentoo-x86_64
lee /boot # du -b vmlinuz-6.1.19-gentoo-x86_64.old 
10238784	vmlinuz-6.1.19-gentoo-x86_64.old
lee /boot # 
Is there a way of how to test what kernel CFLAGS were actually used to create the kernel binary and its modules?
Top
Hu
Administrator
Administrator
Posts: 24401
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Tue Apr 04, 2023 2:52 pm

That post does not show the output of make as it invoked gcc. That post assumes use of genkernel. It's not clear from your most recent posts if you built the kernel by hand or if you let genkernel do it.

Additionally, to your repeated question, the definitive answer for knowing what flags were used is to see the full command that make ran, which will show the flags if they were used. You might be able to derive the answer from the contents of the kernel's generated dependency files (*.cmd files).
Top
GDH-gentoo
Advocate
Advocate
User avatar
Posts: 2115
Joined: Sat Jul 20, 2019 7:02 pm
Location: South America

  • Quote

Post by GDH-gentoo » Tue Apr 04, 2023 5:12 pm

For a manual build of the kernel, make V=1 makefile_target will show the full compiler invocations, including compiler options used. I don't know how to do it when Genkernel is used to build the kernel, though.
Ionen wrote:As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Top
sublogic
Guru
Guru
User avatar
Posts: 388
Joined: Mon Mar 21, 2022 3:02 am
Location: Pennsylvania, USA

  • Quote

Post by sublogic » Tue Apr 04, 2023 10:19 pm

GDH-gentoo wrote:For a manual build of the kernel, make V=1 makefile_target will show the full compiler invocations, including compiler options used. I don't know how to do it when Genkernel is used to build the kernel, though.
I would suggest MAKEOPTS="V=1" in /etc/genkernel.conf. Not tested though.
Top
EliasJonsson
n00b
n00b
User avatar
Posts: 53
Joined: Wed Oct 18, 2017 12:32 pm

  • Quote

Post by EliasJonsson » Wed Apr 05, 2023 3:17 am

sublogic wrote:
GDH-gentoo wrote:For a manual build of the kernel, make V=1 makefile_target will show the full compiler invocations, including compiler options used. I don't know how to do it when Genkernel is used to build the kernel, though.
I would suggest MAKEOPTS="V=1" in /etc/genkernel.conf. Not tested though.
Added

Code: Select all

KERNEL_CFLAGS="-O2 -march=native -pipe -fomit-frame-pointer"
and

Code: Select all

MAKEOPTS="-j5 V=1"
to /etc/genkernel.conf
went to /usr/src/linux/ and issued the command

Code: Select all

genkernel --zfs all
while I looked at the, now V=1erbose output in

Code: Select all

less +F /var/log/genkernel.log
there was no `-march` in that file except for genkernel telling me that the KERNEL_CLFLAGS had been set. I can only conclude that adding the KERNEL_CFLAGS was ineffective.
Last edited by EliasJonsson on Wed Apr 05, 2023 3:43 am, edited 1 time in total.
Top
EliasJonsson
n00b
n00b
User avatar
Posts: 53
Joined: Wed Oct 18, 2017 12:32 pm

  • Quote

Post by EliasJonsson » Wed Apr 05, 2023 3:20 am

Hu wrote:That post does not show the output of make as it invoked gcc. That post assumes use of genkernel. It's not clear from your most recent posts if you built the kernel by hand or if you let genkernel do it.
I built the kernel using

Code: Select all

genkernel all
Hu wrote: You might be able to derive the answer from the contents of the kernel's generated dependency files (*.cmd files).
I would love the learn how to do that :D
Top
logrusx
Advocate
Advocate
User avatar
Posts: 3534
Joined: Thu Feb 22, 2018 2:29 pm

  • Quote

Post by logrusx » Wed Apr 05, 2023 8:23 am

Once again, I think the kernel CFLAGS are defined by what processor family is selected in your kernel config. If it was for genkernel to determine that you could, well at least attempt to, compile a kernel for one architecture with cflags for another.

Not to mention this optimization is of little to no benefit. Better emerge gentoo-sources with experimental use flag enabled which will apply patches allowing you to select exactly what CPU you have in the kernel config.

Best Regards,
Georgi
Top
Hu
Administrator
Administrator
Posts: 24401
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Wed Apr 05, 2023 11:54 am

EliasJonsson wrote:
Hu wrote:You might be able to derive the answer from the contents of the kernel's generated dependency files (*.cmd files).
I would love the learn how to do that :D
The files are plain text, in a format suitable for inclusion in GNU make, so cat /path/to/.cmd-file should work. You should find these files in your $KBUILD_OUTPUT directory (default for basic kernel build: .; default for genkernel: unknown). find "${KBUILD_OUTPUT:-.}" -name '*.cmd' should work to find them, if run from the kernel build directory.
logrusx wrote:I think the kernel CFLAGS are defined by what processor family is selected in your kernel config.
That can also pick CFLAGS for you, yes. However, most build systems, including the kernel build system, also allow the user to pass arbitrary additional flags. These flags can help or hurt, but it is the user's choice to use them.

The kernel should automatically enable compiler optimizations and frame pointer omission, so I think the only option that OP is requesting that is not redundant is -march=native.
Top
Post Reply

14 posts • Page 1 of 1

Return to “Kernel & Hardware”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic