public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: Chris Metcalf <cmetcalf@tilera.com>
To: Roland McGrath <roland@hack.frob.com>
Cc: <libc-alpha@sourceware.org>, <libc-ports@sourceware.org>
Subject: Re: [PATCH] tile: support very large shared objects
Date: Sat, 03 Nov 2012 13:28:00 -0000	[thread overview]
Message-ID: <50951C10.2050704@tilera.com> (raw)
In-Reply-To: <20121103044725.73A6A2C0FA@topped-with-meat.com>

On 11/3/2012 12:47 AM, Roland McGrath wrote:
> The elf.h changes are OK provided binutils trunk already has all those
> exact names and numbers for those reloc codes.  That's always good as
> an isolated commit.

OK, pushed.

> I think we can avoid the changes to the generic configure/config.make for
> something only one port uses in a couple of ways.
>
> In sysdeps/tile/Makefile do "include $(common-objpfx)config-tile.make".
> That file will contain 'config-cflags-mcmodel = ...' or whatever you need.
> Now, you have a couple of ways to go about creating that file.
>
> [...]
> The other way is to create on the fly at build time.  Either way you want
> to add a $(common-objpfx)config-tile.make target in sysdeps/tile/Makefile.

I took this approach.

> 	$(common-objpfx)config-tile.make: $(common-objpfx)config.make
> 		mcmodel=no; \
> 		$(CC) -S -o /dev/null -xc /dev/null -mcmodel=large || mcmodel=yes; \
> 		echo "config-cflags-mcmodel = $mcmodel" > $@

I used cflags-mcmodel-large as the variable name, and
cflags-mcmodel-large.mk as the fragment filename.

> csu/ is not enough.  You also need to use the flag for all of *_nonshared.a
> (.oS files).  That too is code that's always statically linked into
> applications.

I did think about this.  My conclusion was that since *_nonshared.a is
linked last, it will always be at the end of the generated object, so jumps
and calls will always be able to "reach" other things linked in from
*_nonshared.a as well as the PLT, which immediately follows the text
section.  Thus, no need for large model.  In practice this does appear to
be the case.  (And this large model code is noticeably slower than regular
mode, and we've verified that it works at the customer with the actual
large object this way, for what that's worth.)

> And elf-init is not all of csu/, there's also gmon-start and
> so forth.

Ah, I didn't think about gmon-start.  That ends up linked into the object
statically for profiling, now that I look at it.  Is it true that the rest
are linked statically into shared objects?  I thought many of them were
just there for purely static build support.

> Not to mention libc.a--do you not want fully-static linking to
> work with -mcmodel=large?

I think the performance penalty is enough that the answer is "no" by
default.  (A one-instruction call or jump becomes a four-instruction "load
a register and jump" sequence.)  If some customer needs a ginormous static
binary, it's actually reasonable to just say "build a libc.a yourself and
link against it".  We just want to make sure the shared-object
infrastructure "just works" for the case of large objects (as you suggest
further down in your email).

>   So I think you want to do:
>
> 	CFLAGS-.o += -mcmodel=large
>
> (This will cover .oS files too, which is what you're after most.)  If it's
> too costly to do this for all of libc.a and you think people only want
> static linking without the possibility of using -mcmodel=large or dynamic
> linking with the possibility, then you can instead do:
>
> 	ifeq ($(subdir),csu)
> 	CFLAGS-.o += -mcmodel=large
> 	else
> 	CFLAGS-.oS += -mcmodel=large
> 	endif

Thanks for your feedback.  I'll post a modified patch for review shortly.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com

  reply	other threads:[~2012-11-03 13:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-03  3:42 Chris Metcalf
2012-11-03  4:47 ` Roland McGrath
2012-11-03 13:28   ` Chris Metcalf [this message]
2012-11-05 21:31     ` Chris Metcalf
2012-11-07 18:12     ` Roland McGrath

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=50951C10.2050704@tilera.com \
    --to=cmetcalf@tilera.com \
    --cc=libc-alpha@sourceware.org \
    --cc=libc-ports@sourceware.org \
    --cc=roland@hack.frob.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).