mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* How to speed up building of modules?
@ 2003-04-04  8:57 Stephen Cameron
  2003-04-04 21:17 ` Richard B. Johnson
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Stephen Cameron @ 2003-04-04  8:57 UTC (permalink / raw)
  To: linux-kernel

Hi

I'm wondering if you guys know any tricks to speed up building
of linux kernel modules.

First, some background.

We have to put out binary HBA driver modules for a variety
of linux distributions for things like driver diskettes, to allow
new drivers to be used during initial install.  (I'm thinking
of the cciss, cpqarray and cpqfc drivers.)

With all the distributions, and differnent
offerings of distributions, and errata kernels... today, I count
almost 40 distinct kernels we're trying to support, not counting the
mainline development on kernel.org, and not counting multiple
config file variations for each of those 40 or so kernels.

The main catch seems to be the symbol checksums.  In order for those
to match (and I'm not too interested in subverting those), the 
config files used during the compile need to be very similar.  That 
means building lots and lots of modules.  (Think about all the 
modules which are enabled in redhat's typical default config files.)
This takes time.  Mulitply 3 drivers * ~40 kernels * several config
files, and pretty soon... well, pretty soon you don't remember
what "preety soon" means.

It would be VERY nice if I could find a way to build only the modules
I care about  and not all the rest, which add hours and hours.
It seems that some things in the config file can be turned off without
harm, but it's not clear how I can know whether it's safe to turn a module
off  Also, sometimes I need to make changes to the Config.in files, 
add options, etc.  Ccache hasn't helped.  (I think because the different 
config files use different compiler flags, and otherwise the kernels 
just aren't the same.)

Any ideas?

Thanks,

-- steve


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to speed up building of modules?
  2003-04-04  8:57 How to speed up building of modules? Stephen Cameron
@ 2003-04-04 21:17 ` Richard B. Johnson
  2003-04-04 22:05   ` Robert White
  2003-04-05  7:48 ` Sam Ravnborg
  2003-04-06 22:09 ` Bernd Petrovitsch
  2 siblings, 1 reply; 6+ messages in thread
From: Richard B. Johnson @ 2003-04-04 21:17 UTC (permalink / raw)
  To: Stephen Cameron; +Cc: linux-kernel

On Fri, 4 Apr 2003, Stephen Cameron wrote:

> Hi
>
> I'm wondering if you guys know any tricks to speed up building
> of linux kernel modules.
>
> First, some background.
>
> We have to put out binary HBA driver modules for a variety
> of linux distributions for things like driver diskettes, to allow
> new drivers to be used during initial install.  (I'm thinking
> of the cciss, cpqarray and cpqfc drivers.)
>
> With all the distributions, and differnent
> offerings of distributions, and errata kernels... today, I count
> almost 40 distinct kernels we're trying to support, not counting the
> mainline development on kernel.org, and not counting multiple
> config file variations for each of those 40 or so kernels.
>
> The main catch seems to be the symbol checksums.  In order for those
> to match (and I'm not too interested in subverting those), the
> config files used during the compile need to be very similar.  That
> means building lots and lots of modules.  (Think about all the
> modules which are enabled in redhat's typical default config files.)
> This takes time.  Mulitply 3 drivers * ~40 kernels * several config
> files, and pretty soon... well, pretty soon you don't remember
> what "preety soon" means.
>
> It would be VERY nice if I could find a way to build only the modules
> I care about  and not all the rest, which add hours and hours.
> It seems that some things in the config file can be turned off without
> harm, but it's not clear how I can know whether it's safe to turn a module
> off  Also, sometimes I need to make changes to the Config.in files,
> add options, etc.  Ccache hasn't helped.  (I think because the different
> config files use different compiler flags, and otherwise the kernels
> just aren't the same.)
>
> Any ideas?
>
> Thanks,
>
> -- steve

You can create a Makefile to make only the modules you want.
All you need exists in a kernel tree that has (once) been configured
to build, at least, the modules that you want. It is trivial.
You have to remember to -DMODULE as well as -D__KERNEL__ as a
'C' compile parameter along with the other stuff on the command-line.

Understand that when somebody is designing a module, they just
build it in their own directory but, using -I on the command-line
make sure that the correct kernel headers are used (like
-I/usr/src/linux-2.4.20/include -I.).

So, a typical compile-command for a module would be to define the
correct includes and defines as CFLAGS, export those parameters, then
do make -C drivers/net 3x59x.o from inside your Makefile (to do the
3x59x.o module (it requires mii.o also).


Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: How to speed up building of modules?
  2003-04-04 21:17 ` Richard B. Johnson
@ 2003-04-04 22:05   ` Robert White
  0 siblings, 0 replies; 6+ messages in thread
From: Robert White @ 2003-04-04 22:05 UTC (permalink / raw)
  To: root, Stephen Cameron; +Cc: linux-kernel

I would add (or amplify) that if you use the target-dependent or conditional
variable assignment features of gmake you can make one Makefile that will
build a module a number of ways.

Consider this extemporaneous example (e.g. I just typed this in to this
email, you may have to play with it to get it to work correctly.)

===== BEGIN =====
OBJECTS = Driver_2.4.20.o Driver_2.4.18.o Driver_RedHat.o
all: $OBJECTS

# note the colon before the equal sign.
# you *DON'T* want the sub-values expanded here, you want them expanded
during use.
# or you could put this after all the conditional assignments
CFLAGS := $(KERNEL_INCLUDE) $(OTHER_CFLAGS) -DMODULE -D_KERNEL_

#OTHER_CFLAGS could be anything for any driver (say architecture -m686
or -m386 etc)
Driver_2.4.20.o: KERNEL_INCLUDE = -I/usr/src/linux-2.4.20/include
Driver_2.4.18.o: KERNEL_INCLUDE = -I/usr/src/linux-2.4.18/include
# etc...

#Set suitable Defaults if nothing else was set
KERNEL_INCLUDE ?= -I/usr/src/linux/include

# The generic dependencies, note that these dependencies *DON'T* look into
the
#   kernel specific directories.  They *could* with some work, but I leave
that
#   as an exercise as I am in a hurry here 8-).  (you might need "::"
instead of just ":"
$(OBJECTS): Driver.c Driver.h
	$(CC) $(CFLAGS) $< -o $@
# Finally you needed a build rule to make the target, you will use $< and $@
and such
#   Since "Driver.c" is the first prerequisite, that is what $< will always
be.
#   (yes, it could have been hard coded 8-).  $@ is the module you are
building just now.
===== END =====

In some early versions of make, you couldn't do the "all" thing because that
would have been the target for the entire make.  I don't know if this is
still true.  If it is, you probably don't need it at all because then the
first target would be the "$(OBJECTS):" line.  If make still gripes, just
make a script that uses this kind of make file in a loop, that is which
repeatedly invokes "make $TargetName" once for each target module.

Like I said, you may have to play with it.

"info make" is your friend.  Just read the whole thing or follow the various
paths to the "target dependent assignments" and "static rules" and such.

Rob.

-----Original Message-----
From: linux-kernel-owner@vger.kernel.org
[mailto:linux-kernel-owner@vger.kernel.org]On Behalf Of Richard B.
Johnson
Sent: Friday, April 04, 2003 1:17 PM
To: Stephen Cameron
Cc: linux-kernel@vger.kernel.org
Subject: Re: How to speed up building of modules?


On Fri, 4 Apr 2003, Stephen Cameron wrote:

> Hi
>
> I'm wondering if you guys know any tricks to speed up building
> of linux kernel modules.
>
> First, some background.
>
> We have to put out binary HBA driver modules for a variety
> of linux distributions for things like driver diskettes, to allow
> new drivers to be used during initial install.  (I'm thinking
> of the cciss, cpqarray and cpqfc drivers.)
>
> With all the distributions, and differnent
> offerings of distributions, and errata kernels... today, I count
> almost 40 distinct kernels we're trying to support, not counting the
> mainline development on kernel.org, and not counting multiple
> config file variations for each of those 40 or so kernels.
>
> The main catch seems to be the symbol checksums.  In order for those
> to match (and I'm not too interested in subverting those), the
> config files used during the compile need to be very similar.  That
> means building lots and lots of modules.  (Think about all the
> modules which are enabled in redhat's typical default config files.)
> This takes time.  Mulitply 3 drivers * ~40 kernels * several config
> files, and pretty soon... well, pretty soon you don't remember
> what "preety soon" means.
>
> It would be VERY nice if I could find a way to build only the modules
> I care about  and not all the rest, which add hours and hours.
> It seems that some things in the config file can be turned off without
> harm, but it's not clear how I can know whether it's safe to turn a module
> off  Also, sometimes I need to make changes to the Config.in files,
> add options, etc.  Ccache hasn't helped.  (I think because the different
> config files use different compiler flags, and otherwise the kernels
> just aren't the same.)
>
> Any ideas?
>
> Thanks,
>
> -- steve

You can create a Makefile to make only the modules you want.
All you need exists in a kernel tree that has (once) been configured
to build, at least, the modules that you want. It is trivial.
You have to remember to -DMODULE as well as -D__KERNEL__ as a
'C' compile parameter along with the other stuff on the command-line.

Understand that when somebody is designing a module, they just
build it in their own directory but, using -I on the command-line
make sure that the correct kernel headers are used (like
-I/usr/src/linux-2.4.20/include -I.).

So, a typical compile-command for a module would be to define the
correct includes and defines as CFLAGS, export those parameters, then
do make -C drivers/net 3x59x.o from inside your Makefile (to do the
3x59x.o module (it requires mii.o also).


Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to speed up building of modules?
  2003-04-04  8:57 How to speed up building of modules? Stephen Cameron
  2003-04-04 21:17 ` Richard B. Johnson
@ 2003-04-05  7:48 ` Sam Ravnborg
  2003-04-06 22:09 ` Bernd Petrovitsch
  2 siblings, 0 replies; 6+ messages in thread
From: Sam Ravnborg @ 2003-04-05  7:48 UTC (permalink / raw)
  To: Stephen Cameron; +Cc: linux-kernel

On Fri, Apr 04, 2003 at 02:57:40PM +0600, Stephen Cameron wrote:
> Hi
> 
> I'm wondering if you guys know any tricks to speed up building
> of linux kernel modules.

Have you looked at: LKMB (Linux Kernel Module Builder)
Try google at bit after it. An URL has been posted here a couple of times.

There is also: DKMS: Dynamic Kernel Module Support
Gary Lerhaupt from Dell has mede this and he would be glad for any feedback.

In general I advice you to use:
$ make -C path/to/kernel/src SUBDIRS=$PWD modules
when building modules. That's the _only_ way to make sure you have correct
CFLAGS etc.
This should work for 2. as weel as 2.5.

The Makefile than has to be kbuild conformant, as described in
Documentation/kbuild/makefiles.txt

	Sam

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to speed up building of modules?
  2003-04-04  8:57 How to speed up building of modules? Stephen Cameron
  2003-04-04 21:17 ` Richard B. Johnson
  2003-04-05  7:48 ` Sam Ravnborg
@ 2003-04-06 22:09 ` Bernd Petrovitsch
  2 siblings, 0 replies; 6+ messages in thread
From: Bernd Petrovitsch @ 2003-04-06 22:09 UTC (permalink / raw)
  To: steve.cameron; +Cc: linux-kernel

Stephen Cameron <steve.cameron@hp.com> wrote:
>With all the distributions, and differnent
>offerings of distributions, and errata kernels... today, I count
>almost 40 distinct kernels we're trying to support, not counting the
>mainline development on kernel.org, and not counting multiple
>config file variations for each of those 40 or so kernels.
>
>The main catch seems to be the symbol checksums.  In order for those
>to match (and I'm not too interested in subverting those), the 
>config files used during the compile need to be very similar.  That 
>means building lots and lots of modules.  (Think about all the 
>modules which are enabled in redhat's typical default config files.)
>This takes time.  Mulitply 3 drivers * ~40 kernels * several config
>files, and pretty soon... well, pretty soon you don't remember
>what "preety soon" means.
[...]
>Any ideas?

http://ccache.samba.org/

	Bernd
-- 
Bernd Petrovitsch                              Email : bernd@gams.at
g.a.m.s gmbh                                  Fax : +43 1 205255-900
Prinz-Eugen-Straße 8                    A-1040 Vienna/Austria/Europe
                     LUGA : http://www.luga.at



^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: How to speed up building of modules?
@ 2003-04-07 14:27 Cameron, Steve
  0 siblings, 0 replies; 6+ messages in thread
From: Cameron, Steve @ 2003-04-07 14:27 UTC (permalink / raw)
  To: linux-kernel

Sam Ravnborg wrote:
On Fri, Apr 04, 2003 at 02:57:40PM +0600, Stephen Cameron wrote:
> Hi
> 
> I'm wondering if you guys know any tricks to speed up building
> of linux kernel modules.
[...]
In general I advice you to use:
$ make -C path/to/kernel/src SUBDIRS=$PWD modules
when building modules. 

Ok, thanks to everybody who replied.  I believe I've
got something that's going to work for me now and 
save us a lot of time.   Thanks.
-- steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-04-07 14:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-04  8:57 How to speed up building of modules? Stephen Cameron
2003-04-04 21:17 ` Richard B. Johnson
2003-04-04 22:05   ` Robert White
2003-04-05  7:48 ` Sam Ravnborg
2003-04-06 22:09 ` Bernd Petrovitsch
2003-04-07 14:27 Cameron, Steve

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®