View previous topic :: View next topic |
Author |
Message |
EliasJonsson n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/1650876378617d48d40e2f9.jpg)
Joined: 18 Oct 2017 Posts: 53
|
Posted: Mon Apr 03, 2023 4:29 am Post subject: Does genkernel compile with make.conf CFLAGS? |
|
|
Hello Gentoo Community,
when using genkernel, is the kernel compiled using the custom cflags in the /etc/portage/make.conf when the is executed?
Last edited by EliasJonsson on Mon Apr 03, 2023 3:16 pm; edited 2 times in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
EliasJonsson n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/1650876378617d48d40e2f9.jpg)
Joined: 18 Oct 2017 Posts: 53
|
Posted: Mon Apr 03, 2023 5:40 am Post subject: |
|
|
found the solution elsewhere:
Code: | nano /etc/genkernel.conf
|
And add the line:
Code: |
KERNEL_CFLAGS="-O2 -march=native -pipe -fomit-frame-pointer"
|
Then go to linux source folder and issue the command:
Verify CFLAGS using
Code: |
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 |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
logrusx Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/176594205966916859b5145.jpg)
Joined: 22 Feb 2018 Posts: 2699
|
Posted: Mon Apr 03, 2023 6:04 am Post subject: |
|
|
I think it depends on your kernel config.
Best Regards,
Georgi |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Gladdle Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/585553426498c8f99ae269.jpg)
Joined: 27 Jul 2008 Posts: 313 Location: Cleebronn, Germany
|
Posted: Mon Apr 03, 2023 8:13 am Post subject: |
|
|
May i quote from the file /etc/genkernel.conf: Code: | # 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)" |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
EliasJonsson n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/1650876378617d48d40e2f9.jpg)
Joined: 18 Oct 2017 Posts: 53
|
Posted: Mon Apr 03, 2023 3:21 pm Post subject: |
|
|
Gladdle wrote: | May i quote from the file /etc/genkernel.conf: Code: | # 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? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23100
|
Posted: Mon Apr 03, 2023 4:56 pm Post subject: |
|
|
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? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
EliasJonsson n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/1650876378617d48d40e2f9.jpg)
Joined: 18 Oct 2017 Posts: 53
|
Posted: Tue Apr 04, 2023 2:07 am Post subject: |
|
|
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: | 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? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23100
|
Posted: Tue Apr 04, 2023 2:52 pm Post subject: |
|
|
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). |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
GDH-gentoo Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/4552800915d460a483ae8d.jpg)
Joined: 20 Jul 2019 Posts: 1806 Location: South America
|
Posted: Tue Apr 04, 2023 5:12 pm Post subject: |
|
|
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. _________________
NeddySeagoon wrote: | I'm not a witch, I'm a retired electronics engineer ![Smile :)](images/smiles/icon_smile.gif) |
Ionen wrote: | As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though ![Smile :)](images/smiles/icon_smile.gif) |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
sublogic Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/92700334162390783722aa.png)
Joined: 21 Mar 2022 Posts: 310 Location: Pennsylvania, USA
|
Posted: Tue Apr 04, 2023 10:19 pm Post subject: |
|
|
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. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
EliasJonsson n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/1650876378617d48d40e2f9.jpg)
Joined: 18 Oct 2017 Posts: 53
|
Posted: Wed Apr 05, 2023 3:17 am Post subject: |
|
|
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: | KERNEL_CFLAGS="-O2 -march=native -pipe -fomit-frame-pointer" |
and
to /etc/genkernel.conf
went to /usr/src/linux/ and issued the command Code: | genkernel --zfs all |
while I looked at the, now V=1erbose output in Code: | 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 |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
EliasJonsson n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/1650876378617d48d40e2f9.jpg)
Joined: 18 Oct 2017 Posts: 53
|
Posted: Wed Apr 05, 2023 3:20 am Post subject: |
|
|
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
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 ![Very Happy :D](images/smiles/icon_biggrin.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
logrusx Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/176594205966916859b5145.jpg)
Joined: 22 Feb 2018 Posts: 2699
|
Posted: Wed Apr 05, 2023 8:23 am Post subject: |
|
|
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 |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23100
|
Posted: Wed Apr 05, 2023 11:54 am Post subject: |
|
|
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 ![Very Happy :D](images/smiles/icon_biggrin.gif) | 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. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|