This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Link extra-libs consistently with libc and

On Fri, 17 May 2013, Roland McGrath wrote:

> elfobjdir and elf-objpfx are redundant.  We should consolidate on just one
> or the other.  I don't think it matters which.  For linking, using
> makes sense.  There is no need to use $(rtld-installed-name).

I've added this consolidation to the wiki todo list.

> > * Some libraries need to link with the internal linkobj/,
> >   rather than the normal, because of use of obsolete RPC
> >   interfaces.  To support this, the rule in Makerules allows
> >   $($(@F)-libc) to be used instead of the default
> >   $(common-objpfx)
> What bad things would happen if we just always used linkobj/ for
> linking?

The elf/ directory builds using $(build-module-asneeded), 
which uses $(link-libc-args) (which is desirable, on the principle of 
consistency of linking), but is (or may be) built before linkobj/ 
is built.  When I tried changing the dependencies of to 
include $(link-libc-deps), I got a build failure because of this (since 
link-libc-deps always includes linkobj/, and elf/Makefile doesn't 
know how to build that file).

Now, maybe could be built in a different way that happens 
after linkobj/ is built.  But the principle of consistency with 
building with an installed compiler and libc suggests that linkobj/ 
should only be used when necessary.

> > +# Compiler arguments to use to link a shared object with libc and
> > +#  This is intended to be as similar as possible to a default
> > +# link with an installed libc.
> > +link-libc-args = -Wl,--start-group \
> > +		 $(if $($(@F)-libc),$($(@F)-libc),$(common-objpfx) \
> > +		 $(common-objpfx)libc_nonshared.a \
> > +		 $(as-needed) $(common-objpfx)elf/ $(no-as-needed) \
> > +		 -Wl,--end-group
> Given the stated intent, perhaps an approach more likely to ensure it's
> followed would be to generate a linker script with a rule sharing most of
> its logic with the $(inst_libdir)/ rule.  If that uses file names
> without leading slash and -L$(common-objdir) before it, then I think it
> will pick up the right builddir files.

I'd think such a linker script might as well include absolute paths; a 
helper script that generates the linker script, given arguments that are 
the directory names that should go in the linker script, might be a 
sensible way of sharing the logic.  (Either the links$( and $(rtld-installed-name) are then being used 
at build time to link against, or else the names within the directory also 
need to vary between the linker scripts.)

> You said just, "Tested."  Does that mean you tested that all the object
> came out completely unchanged from before the patch?

No, tested with normal testsuite runs.  I don't expect everything to be 
unchanged, given that various objects were previously linked 
unconditionally with and after the patch have a --as-needed link 
with (so some may not end up with a dependency on after all).

Joseph S. Myers

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]