Linux kbuild/kconfig development
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@ti.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Felipe Balbi <balbi@ti.com>, Arnaud Lacombe <lacombar@gmail.com>,
	Michal Nazarewicz <mina86@mina86.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Greg KH <greg@kroah.com>,
	Linux USB Mailing List <linux-usb@vger.kernel.org>,
	linux-kbuild@vger.kernel.org
Subject: Re: generate one module from multiple object files (was: Re: [PATCH 2/2] usb: gadget: convert all users to the new udc)
Date: Tue, 14 Jun 2011 20:29:01 +0300	[thread overview]
Message-ID: <20110614172859.GS2353@legolas.emea.dhcp.ti.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1106141301000.2102-100000@iolanthe.rowland.org>

[-- Attachment #1: Type: text/plain, Size: 3177 bytes --]

On Tue, Jun 14, 2011 at 01:06:16PM -0400, Alan Stern wrote:
> On Tue, 14 Jun 2011, Felipe Balbi wrote:
> 
> > > --- a/drivers/usb/gadget/Makefile
> > > +++ b/drivers/usb/gadget/Makefile
> > > @@ -34,6 +34,12 @@ obj-$(CONFIG_USB_FUSB300)    += fusb300_udc.o
> > >  # USB gadget drivers
> > >  #
> > >  g_zero-y                       := zero.o
> > > +g_zero-y                       += composite.o
> > > +g_zero-y                       += usbstring.o
> > > +g_zero-y                       += config.o
> > > +g_zero-y                       += epautoconf.o
> > > +g_zero-y                       += f_sourcesink.o
> > > +g_zero-y                       += f_loopback.o
> > 
> > yes, you can do that. But the problem is the runtime memory footprint
> > that we will have with that. At least that was the reason why Greg had
> > asked Dave to change it to how it is done now.
> 
> What exactly is the runtime memory footprint problem?  I thought the
> whole reason for #include'ing .c files was that back then, the kbuild
> system wasn't able to do this.

not at all. Kbuild has always been able to generate one module from
several objects. But then we need to remove "static" from many
functions to achieve that.

> > Do we support gcc --combine already ?
> 
> As far as I know, the only advantage of gcc -combine is that it allows
> the optimizer to work on more than one file at a time.  Would that
> really make any significant difference for these particular source
> files?

AFAICT, gcc --combine will really combine the files as if they were one,
pretty much the same as including the entire C source.

Just look at the rationale from the commit log itself:

commit 4e9ba518ec19c6c961bf6074ec05ae1a927230bc
Author: David Brownell <dbrownell@users.sourceforge.net>
Date:   Mon Aug 18 17:41:02 2008 -0700

    usb gadget: link fixes for serial gadget
    
    Change how the serial gadget driver builds:  don't use
    separate compilation, since it works poorly when key parts
    are library code (with init sections etc).  Instead be as
    close as we can to "gcc --combine ...".
    
    Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

part of it is also in any gadget driver:

/*
 * Kbuild is not very cooperative with respect to linking separately
 * compiled library objects into one module.  So for now we won't use
 * separate compilation ... ensuring init/exit sections work to shrink
 * the runtime footprint, and giving us at least some parts of what
 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
 */

you can find all such commits by:

$ git log --author="David Brownell" --grep="link fixes" -- drivers/usb/gadget/

And here are the original discussions:

http://marc.info/?l=linux-usb&m=121868805717787&w=2
http://marc.info/?l=linux-usb&m=121875765411492&w=2

In summary:

We don't want to have library code into their own drivers because, well,
you can only have one gadget driver at a time anyway. And we don't want
separate compilation due to having stuff out of init sections.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

  parent reply	other threads:[~2011-06-14 17:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20110613085534.GD3633@legolas.emea.dhcp.ti.com>
     [not found] ` <Pine.LNX.4.44L0.1106131024100.1983-100000@iolanthe.rowland.org>
     [not found]   ` <20110613153516.GC2353@legolas.emea.dhcp.ti.com>
     [not found]     ` <op.vw1yw3ol3l0zgt@mnazarewicz-glaptop>
2011-06-14  7:32       ` generate one module from multiple object files (was: Re: [PATCH 2/2] usb: gadget: convert all users to the new udc) Felipe Balbi
2011-06-14 15:33         ` Arnaud Lacombe
2011-06-14 16:45           ` Felipe Balbi
2011-06-14 17:06             ` Alan Stern
2011-06-14 17:16               ` Sebastian Andrzej Siewior
2011-06-14 17:29               ` Felipe Balbi [this message]
2011-06-14 17:48                 ` Arnaud Lacombe
2011-06-14 18:36                   ` Felipe Balbi
2011-06-14 20:21                     ` Greg KH
2011-06-14 19:27                 ` Alan Stern
2011-06-14 19:41                   ` Felipe Balbi
2011-06-14 20:01                     ` Alan Stern
2011-06-14 20:16                       ` Felipe Balbi
2011-06-14 20:24                         ` Greg KH
2011-06-14 17:15             ` Arnaud Lacombe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110614172859.GS2353@legolas.emea.dhcp.ti.com \
    --to=balbi@ti.com \
    --cc=bigeasy@linutronix.de \
    --cc=greg@kroah.com \
    --cc=lacombar@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mina86@mina86.com \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox