Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 6th July 2009, 06:30 PM
jbkt23 Offline
Registered User
 
Join Date: Mar 2006
Posts: 510
Akmods not finding kernel source (& Kernel Module size too large in Custom Compile)

I have been trying to get the size of my custom compiled modules to be the same size as the distro release modules. The ones that I compile are 10 to 20 times the size of the same module in comparison.
I have looked through the srpm top level Makefile for the flags passed to gcc and found that " -O2" is the default. I increased this to "-O3" with no difference. I did not see any option call for debugging.
How do I find out what the default options to gcc are, and then how do I override them to get the results I want.
Please understand I know little about programming, but I have been compiling custom kernels for 10 years now. Initially to enable hardware to work but now I am just seeing what tweaks I can make to improve performance and satisfy my curiosity.
I have perused "man gcc" to get familiar with the options available.
__________________
jbkt23
Reply With Quote
  #2  
Old 6th July 2009, 06:48 PM
Hlingler's Avatar
Hlingler Offline
Administrator
 
Join Date: Sep 2006
Location: Connellsville, PA, USA
Posts: 11,289
Try prepending compiler options to whatever build command you use, e.g.:
$ CFLAGS="-O2 -pipe -m32 -march=i386 -mtune=generic" CXXFLAGS=$CFLAGS make ...

You would of course have to adjust the above options to suit your OS ARCH and so on.

'-g' switch is "include debugging", and therefore you could/should omit; '-O3' does NOT necessarily yield smaller binaries than '-O2', but rather "optimized" for speed and/or various other "optimizations".

V

P.S. You may never be able to build custom kmods to match the sizes that are compiled/included with "stock" kernels - I have not, rather, I see similar results to what you describe. Oh, well, if they work....

Last edited by Hlingler; 6th July 2009 at 06:51 PM.
Reply With Quote
  #3  
Old 6th July 2009, 07:53 PM
jbkt23 Offline
Registered User
 
Join Date: Mar 2006
Posts: 510
Thanks Hlingler,
I did as you recommended the other night with no net change in module size. I've also diffed the .config for my kernel and the stock kernel to see if there was a telling difference and I saw nothing there.
I'm wondering what I would get if I ran "strings" on the stock module and my module. Is there a lot of commentary in mine that is stripped out by the professionals? Well tonight I will see.
__________________
jbkt23
Reply With Quote
  #4  
Old 6th July 2009, 07:55 PM
sideways's Avatar
sideways Offline
Retired User
 
Join Date: Oct 2004
Location: London, UK
Posts: 4,999
are you compiling from a kernel source tree? if so, run make menuconfig and disable Kernel debugging in the Kernel hacking section.
Reply With Quote
  #5  
Old 7th July 2009, 04:17 AM
jbkt23 Offline
Registered User
 
Join Date: Mar 2006
Posts: 510
Sideways, you nailed it. I knew and in the past have disabled this. When I compared the stock config that is installed in boot the hacking debug was enabled.
I just finished compiling and the finished rpm is 1/10th the size of my previous compile. I don't know if what I compiled works but that is for tomorrow to find out.

till next
__________________
jbkt23
Reply With Quote
  #6  
Old 7th July 2009, 01:59 PM
jbkt23 Offline
Registered User
 
Join Date: Mar 2006
Posts: 510
The new kernel booted but the akmod couldn't build the nvidia driver nor could dkms build the VBox module. So I need to do some research. If I can't figure it out I'll start a new thread in a different forum.
__________________
jbkt23
Reply With Quote
  #7  
Old 7th July 2009, 02:14 PM
sideways's Avatar
sideways Offline
Retired User
 
Join Date: Oct 2004
Location: London, UK
Posts: 4,999
Quote:
Originally Posted by jbkt23 View Post
The new kernel booted but the akmod couldn't build the nvidia driver nor could dkms build the VBox module. So I need to do some research. If I can't figure it out I'll start a new thread in a different forum.
that's because you don't have a kernel-devel package to match the custom kernel.

You can create the custom kernel and kernel-devel rpms using this guide

(basically, instead of running 'make' after the usual kernel build steps you run rpmbuild)

alternatively, create a symbolic link from /usr/src/kernels/$(uname -r) to the kernel source directory you have used to compile the kernel.

'uname -r' is just the name of the current booted kernel, which will be what you called it when compiling (usually by specifying the EXTRAVERSION in the makefile)
Reply With Quote
  #8  
Old 9th July 2009, 06:09 PM
jbkt23 Offline
Registered User
 
Join Date: Mar 2006
Posts: 510
Akmods not finding kernel source

I have compiled a custom kernel rpm and installed it. I created the symlinks to the source from /lib/modules/<kernelversion>/build & source. I have traversed the links to confirm they are valid. The .config and Makefile are valid for my kernel in the source directory.

When I boot into this custom kernel akmod is complaining it can't find the source and fails.
Oh, there is one other boot message that says something to the effect that the device.mapper is ???? sorry, can't remember the message verbatim. Now that I think of it I may have to remake initrd. I bind certain directory paths when I compile that don't exist after rpmbuild is done. So, initrd is looking in the wrong place.

I'll check when I get home and do a fresh mkinitrd.
__________________
jbkt23
Reply With Quote
  #9  
Old 9th July 2009, 06:52 PM
Hlingler's Avatar
Hlingler Offline
Administrator
 
Join Date: Sep 2006
Location: Connellsville, PA, USA
Posts: 11,289
The question appears to be answered in sideways' last post of your other kernel-related thread: http://forums.fedoraforum.org/showthread.php?t=225820

Is there any reason why this discussion cannot be continued in the other thread?

V
Reply With Quote
  #10  
Old 9th July 2009, 08:32 PM
jbkt23 Offline
Registered User
 
Join Date: Mar 2006
Posts: 510
I didn't consider this a programming issue. Akmod and dkms are software that I am not compiling. Also, I've done in essence the second option that sideways suggested which has worked when I needed to compile additional modules for the running kernel. The source does exist at /usr/src/kernels/<kernelversion>

How do akmod and dkms find the sourec? Do they follow the links from lib/modules or do they look for an environment variable that is exported to the shell? Or do they search /usr/src/kernels/$uname -r ?

I'll eventually figure it out and the answer to the above questions will be of interest to the wider audience of the forum than just programmers.
__________________
jbkt23
Reply With Quote
  #11  
Old 10th July 2009, 12:06 AM
Hlingler's Avatar
Hlingler Offline
Administrator
 
Join Date: Sep 2006
Location: Connellsville, PA, USA
Posts: 11,289
OK then, I've merged the two threads, moved to "Software" section, and re-titled. Send me a PM if there's any problem with any of that, and I'll fix/change it again.

In future: you can always send a PM to any on-line Staff member asking for a thread to be moved, re-titled, & etc.

V
Reply With Quote
  #12  
Old 10th July 2009, 03:38 AM
jbkt23 Offline
Registered User
 
Join Date: Mar 2006
Posts: 510
I've figured out from reading the logs /var/cache/akmods/nvidia/<nvidia-version>.log that akmod looks for kernel-devel-<kernel version> in the rpm data base and if it can't find it it fails. Their appears to be no way to change this behavior or pass the path on the command line. So I will have to go and build the source with rpmbuild and install it.
Dkms also looks for the kernel-devel package but the documentation indicates you can change the path to the source on the command line.
__________________
jbkt23
Reply With Quote
  #13  
Old 11th July 2009, 06:36 PM
jbkt23 Offline
Registered User
 
Join Date: Mar 2006
Posts: 510
So how do you make a kernel-devel package for a custom kernel?
There is no target to do so with rpmbuild.
Is there a way to rename the kernel-devel<nearest-kernel-version>.rpm to match my kernel name and also edit the path within the rpm to match the custom kernel?
That way I could install the rpm to the correct location and then substitute the files that differ for my custom kernel version like the .config, Makefile, system.map and I think maybe two other files.
__________________
jbkt23
Reply With Quote
  #14  
Old 12th July 2009, 01:17 PM
Gödel's Avatar
Gödel Offline
Registered User
 
Join Date: Jul 2009
Location: London,England
Posts: 1,095
Quote:
Originally Posted by jbkt23 View Post
So how do you make a kernel-devel package for a custom kernel?
There is no target to do so with rpmbuild.
Is there a way to rename the kernel-devel<nearest-kernel-version>.rpm to match my kernel name and also edit the path within the rpm to match the custom kernel?
That way I could install the rpm to the correct location and then substitute the files that differ for my custom kernel version like the .config, Makefile, system.map and I think maybe two other files.
If you need to apply specific code patches then see http://fedoraproject.org/wiki/Docs/CustomKernel

If you are just compiling with a custom .config choice, then instead of 'make' use the rpmbuild command to build the -devel (and -firmware) packages

Install the source and make the custom .config as usual (with make menuconfig)

Code:
yumdownloader --source kernel
rpm -ihv kernel*.src.rpm
rpmbuild -bp ~/rpmbuild/SPECS/kernel.spec
cd ~/rpmbuild/BUILD/kernel*/linux*/
cp /boot/config-$(uname -r) .config
make oldconfig
make menuconfig
(ensuring you disable Kernel debugging in the Kernel hacking section as pointed out above)

Now add '# i386' or '# x86_64' to the first line of .config and copy to ~/rpmbuild/SOURCES/config-i686 or ~/rpmbuild/SOURCES/config-x86_64-generic. Then edit the kernel.spec file to uncomment the line '#% define buildid .local', (remove any spaces around the '%' so it's '%define'), change .local to .test or whatever as desired.

Now run this to generate kernel, kernel-devel, kernel-headers and kernel-firmware: (for a multithreaded compile use alias make='make -jN' where N>=2, the number of threads)

Quote:
rpmbuild -bb --target=$(uname -m) --with baseonly --with firmware --without debuginfo ~/rpmbuild/SPECS/kernel.spec
and the rpms will end up in ~/rpmbuild/RPMS/$(uname -m)
Reply With Quote
  #15  
Old 13th July 2009, 06:02 PM
jbkt23 Offline
Registered User
 
Join Date: Mar 2006
Posts: 510
I did has Godel outlined and the build provided the kernel, kernel-devel, kernel-firmware and kernel-header packages. I have not installed them because I need to go back and tweak the configs.

One question I have is why does the "bb" option rebuild the sources that were already built for the target platform with the "bp" option when I initially installed and configured the source? It seems a waist of clock ticks and created some problems because I didn't anticipate that.

Is there a way to prevent rebuilding the source again?
__________________
jbkt23

Last edited by jbkt23; 13th July 2009 at 06:08 PM. Reason: Clarified question
Reply With Quote
Reply

Tags
akmods, compile, custom, finding, kernel, large, module, size, source

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom nvidia module for a Custom kernel jbkt23 Using Fedora 0 2nd October 2007 04:01 AM
Compile custom kernel Billybob Using Fedora 7 14th March 2005 11:21 PM
How To Compile A custom Kernel??? Tru Using Fedora 35 30th October 2004 09:15 AM
why is my custom kernel so large? inha Using Fedora 2 21st September 2004 05:14 PM
FAQ: doing custom 2.6.1 kernel out of arjanv's kernel-source feenixx Fedora Core 2 Test Releases 2 4th February 2004 01:38 AM


Current GMT-time: 08:49 (Thursday, 23-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat