[lttng-dev] [PATCH] Fix linker library order

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Wed May 15 02:05:54 EDT 2013


* Simon Marchi (simon.marchi at polymtl.ca) wrote:
> On 14 May 2013 08:37, Mathieu Desnoyers <mathieu.desnoyers at efficios.com> wrote:
> >
> > * Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote:
> > > * Alexandre Montplaisir (alexmonthy at voxpopuli.im) wrote:
> > > > On 13-05-11 10:59 PM, Mathieu Desnoyers wrote:
> > > > > * Francis Giraldeau (francis.giraldeau at gmail.com) wrote:
> > > > >> Libraries must be specified after the binary target.
> > > > > merged, thanks!
> > > > >
> > > > > Mathieu
> > > >
> > > > This seems to have broken the daily PPA packages:
> > > > https://launchpadlibrarian.net/139804087/buildlog_ubuntu-saucy-amd64.lttng-ust_2.2~pre-0%2Bbzr1574%2Bpack37%2B201305131247~saucy1_FAILEDTOBUILD.txt.gz
> > > >
> > > > That package has no particular patches. If I build it locally from
> > > > source it builds fine, but if I build the package locally (with
> > > > dpkg-buildpackage), I get the same error. It could be related to the
> > > > --as-needed problem we've had before...
> > >
> > > Francis, can you explain why your change was needed in the first place ?
> >
> > Hrm, actually, these patches are wrong.
> 
> 
> I believe these patches are correct.
> 
> >
> > commit 725e63c5194bfdcde0a2a3507aca156ba36cf49f for instance:
> >
> > "Libraries must be specified after the binary target."
> >
> >  demo: demo.o
> > -       $(CC) -o $@ $(LIBS) $^
> > +       $(CC) -o $@ $^ $(LIBS)
> >
> > the binary target here is "$@".
> >
> > $^ is the source file name (demo.c).
> >
> > this patch moves the source file name prior to the libraries, which is
> > incorrect (ref: gcc(1)). The input files should appear last.
> >
> > So it breaks builds where $(LIBS) is non-empty.
> 
> Actually, $^ here is "demo.o", not "demo. Also, the libs should appear
> after the objects on the command line. See the "-l" section in
> http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html. On most setup
> this doesn't matter, since -Wl,--no-as-needed was the default pretty
> much everywhere. Ubuntu decided to use -Wl,--as-needed to avoid
> unnecessary dependencies, so the order becomes important. If you try
> to manual build on a recent Ubuntu you will get undefined references
> to dlopen and such. So this patch is good.
> 
> If you read carefully the log sent by Alexandre, you see that it is
> when building the shared libs in this directory
> (lttng-ust-provider-ust-tests-demo.so) that the build fails. I don't
> know why it fails, but Alexandre hinted that passing "-fPIE -pie" to
> build a shared library is weird (it is usually -fPIC -pic). I am not
> sure where that comes from. This behaviour only happens when building
> the package, not when building manually.

OK, I'm reverting the 2 reverts (now that's clumsy) ;-).

I'm adding your explanation to the changelog of those reverts.

Thanks,

Mathieu

> 
> >
> > I will revert commits:
> >
> > commit a51ac6d9a011ba10b0be396dc1e801b2fc829651
> > Author: Francis Giraldeau <francis.giraldeau at gmail.com>
> > Date:   Sat May 11 22:59:21 2013 -0400
> >
> >     Fix (another) linker library order
> >
> >     Libraries must be specified after the binary target.
> >
> >     Signed-off-by: Francis Giraldeau <francis.giraldeau at gmail.com>
> >     Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> >
> > commit 725e63c5194bfdcde0a2a3507aca156ba36cf49f
> > Author: Francis Giraldeau <francis.giraldeau at gmail.com>
> > Date:   Sat May 11 22:58:12 2013 -0400
> >
> >     Fix linker library order
> >
> >     Libraries must be specified after the binary target.
> >
> >     Signed-off-by: Francis Giraldeau <francis.giraldeau at gmail.com>
> >     Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> >
> >
> > Thanks,
> >
> > Mathieu
> >
> > >
> > > Thanks,
> > >
> > > Mathieu
> > >
> > > >
> > > > Cheers,
> > > > Alex
> > > >
> > > > >
> > > > >> Signed-off-by: Francis Giraldeau <francis.giraldeau at gmail.com>
> > > > >> ---
> > > > >>  doc/examples/demo/Makefile | 2 +-
> > > > >>  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >>
> > > > >> diff --git a/doc/examples/demo/Makefile b/doc/examples/demo/Makefile
> > > > >> index 7ae6547..bbc8ccb 100644
> > > > >> --- a/doc/examples/demo/Makefile
> > > > >> +++ b/doc/examples/demo/Makefile
> > > > >> @@ -55,7 +55,7 @@ demo.o: demo.c
> > > > >>          $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
> > > > >>
> > > > >>  demo: demo.o
> > > > >> -        $(CC) -o $@ $(LIBS) $^
> > > > >> +        $(CC) -o $@ $^ $(LIBS)
> > > > >>
> > > > >>  .PHONY: clean
> > > > >>  clean:
> > > > >> --
> > > > >> 1.8.1.2
> > > > >>
> > > > >>
> > > > >> _______________________________________________
> > > > >> lttng-dev mailing list
> > > > >> lttng-dev at lists.lttng.org
> > > > >> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
> > > >
> > >
> > > --
> > > Mathieu Desnoyers
> > > EfficiOS Inc.
> > > http://www.efficios.com
> > >
> > > _______________________________________________
> > > lttng-dev mailing list
> > > lttng-dev at lists.lttng.org
> > > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
> >
> > --
> > Mathieu Desnoyers
> > EfficiOS Inc.
> > http://www.efficios.com
> >
> > _______________________________________________
> > lttng-dev mailing list
> > lttng-dev at lists.lttng.org
> > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list