Patchwork eglibc: include libgcc when libpthread is enabled

login
register
mail settings
Submitter Bogdan Marinescu
Date May 9, 2013, 12:55 p.m.
Message ID <1368104132-30116-1-git-send-email-bogdan.a.marinescu@intel.com>
Download mbox | patch
Permalink /patch/49633/
State New
Headers show

Comments

Bogdan Marinescu - May 9, 2013, 12:55 p.m.
libpthread needs libgcc to function properly. Without libgcc I get
the following error:

root@qemux86:~# tclsh
% exit 0
libgcc_s.so.1 must be installed for pthread_cancel to work
Aborted
root@qemux86:~#

This patch fixes the above issue and similar ones by adding a
runtime dependency of libgcc to eglibc when threads are enabled.

Signed-off-by: Bogdan Marinescu <bogdan.a.marinescu@intel.com>
---
 meta/recipes-core/eglibc/eglibc.inc |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Richard Purdie - May 9, 2013, 1:19 p.m.
On Thu, 2013-05-09 at 15:55 +0300, Bogdan Marinescu wrote:
> libpthread needs libgcc to function properly. Without libgcc I get
> the following error:
> 
> root@qemux86:~# tclsh
> % exit 0
> libgcc_s.so.1 must be installed for pthread_cancel to work
> Aborted
> root@qemux86:~#
> 
> This patch fixes the above issue and similar ones by adding a
> runtime dependency of libgcc to eglibc when threads are enabled.
> 
> Signed-off-by: Bogdan Marinescu <bogdan.a.marinescu@intel.com>
> ---
>  meta/recipes-core/eglibc/eglibc.inc |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/recipes-core/eglibc/eglibc.inc b/meta/recipes-core/eglibc/eglibc.inc
> index 1e04197..24fb05b 100644
> --- a/meta/recipes-core/eglibc/eglibc.inc
> +++ b/meta/recipes-core/eglibc/eglibc.inc
> @@ -35,7 +35,7 @@ siteconfig_do_siteconfig_gencache_prepend = " \
>  # nptl needs unwind support in gcc, which can't be built without glibc.
>  DEPENDS = "virtual/${TARGET_PREFIX}gcc-initial linux-libc-headers virtual/${TARGET_PREFIX}libc-initial"
>  # nptl needs libgcc but dlopens it, so our shlibs code doesn't detect this
> -#RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
> +RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
>  PROVIDES = "virtual/libc virtual/${TARGET_PREFIX}libc-for-gcc"
>  PROVIDES += "virtual/libintl virtual/libiconv"
>  inherit autotools

Why/when was that line commented out originally? Also, afaik glibc
doesn't support anything other than nptl these days so we can probably
drop the GLIBC_ADDONS check. Khem/Phil?

Cheers,

Richard
Phil Blundell - May 9, 2013, 1:20 p.m.
On Thu, 2013-05-09 at 15:55 +0300, Bogdan Marinescu wrote:
>  # nptl needs libgcc but dlopens it, so our shlibs code doesn't detect this
> -#RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
> +RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"

Wow, it seems like this has been broken since 2008 and nobody noticed.
That line was commented out in oe-classic e96e82cd without any real
explanation and it's been that way ever since.

That said, forcing libgcc into RDEPENDS_${PN} unconditionally like this
is suboptimal, because programs that don't link -lpthread (or possibly
even programs that do, if they don't use cancellation) still don't need
libgcc.  With this change it will be impossible to avoid getting libgcc
in an image, which will be a loss for those trying to build small images
with single threaded programs.

p.
Bogdan Marinescu - May 9, 2013, 1:28 p.m.
On Thu, May 9, 2013 at 4:20 PM, Phil Blundell <pb@pbcl.net> wrote:

> On Thu, 2013-05-09 at 15:55 +0300, Bogdan Marinescu wrote:
> >  # nptl needs libgcc but dlopens it, so our shlibs code doesn't detect
> this
> > -#RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
> > +RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
>
> Wow, it seems like this has been broken since 2008 and nobody noticed.
> That line was commented out in oe-classic e96e82cd without any real
> explanation and it's been that way ever since.
>
> That said, forcing libgcc into RDEPENDS_${PN} unconditionally like this
>

It's not exactly unconditional, it is conditioned by 'nptl' in
${GLIBC_ADDONS}. I don't know of a better way to handle this, please let me
know if you have any suggestions.
About why this line was commented out, I don't know. git blame didn't help
with this.

Thanks,
Bogdan


> is suboptimal, because programs that don't link -lpthread (or possibly
> even programs that do, if they don't use cancellation) still don't need
> libgcc.  With this change it will be impossible to avoid getting libgcc
> in an image, which will be a loss for those trying to build small images
> with single threaded programs.
>
> p.
>
>
>
Phil Blundell - May 9, 2013, 2:08 p.m.
On Thu, 2013-05-09 at 16:28 +0300, Marinescu, Bogdan A wrote:

> It's not exactly unconditional, it is conditioned by 'nptl' in
> ${GLIBC_ADDONS}. 


Well, true, but nptl is more or less mandatory nowadays.  That
conditional is an artifact from the days when linuxthreads was the
default and you had to enable nptl explicitly if you were lucky enough
to be using an architecture where it was supported.  I'm not sure if
linuxthreads even still works and I doubt anybody is building eglibc
without nptl any more.

In fact, the whole GLIBC_ADDONS variable appears to be vestigial and, as
far as I can tell, no longer does anything useful.  EXTRA_OECONF in
eglibc.bb is hard-coded to pass just "--enable-add-ons" which causes
eglibc to enable all the add-ons it can find (and even this is
unnecessary since that is the default behaviour anyway). 


> I don't know of a better way to handle this, please let me know if you
> have any suggestions.

There was some previous discussion of how to detect the precise
situation that caused libgcc_s to be required, though my recollection of
all the details is a bit hazy.  I'll see if I can find it in the
archives.  

In the meantime, it's maybe worth noting that the whole way that eglibc
is packaged is basically unchanged from the way that it was first done
back in 2003 and, to put it bluntly, is teh suck.  (Notably, eglibc.inc
mentions LEAD_SONAME, which is usually quite a clear sign that suckage
can be found nearby.)  If libpthread were packaged separately rather
than bundled up into eglibc, the dependency could go there and this
would probably solve 95% of the problem.

p.
Khem Raj - May 9, 2013, 2:25 p.m.
On May 9, 2013, at 5:55 AM, Bogdan Marinescu <bogdan.a.marinescu@intel.com> wrote:

> libpthread needs libgcc to function properly. Without libgcc I get
> the following error:
> 
> root@qemux86:~# tclsh
> % exit 0
> libgcc_s.so.1 must be installed for pthread_cancel to work
> Aborted
> root@qemux86:~#
> 
> This patch fixes the above issue and similar ones by adding a
> runtime dependency of libgcc to eglibc when threads are enabled.
> 

Looks OK 

> Signed-off-by: Bogdan Marinescu <bogdan.a.marinescu@intel.com>
> ---
> meta/recipes-core/eglibc/eglibc.inc |    2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/recipes-core/eglibc/eglibc.inc b/meta/recipes-core/eglibc/eglibc.inc
> index 1e04197..24fb05b 100644
> --- a/meta/recipes-core/eglibc/eglibc.inc
> +++ b/meta/recipes-core/eglibc/eglibc.inc
> @@ -35,7 +35,7 @@ siteconfig_do_siteconfig_gencache_prepend = " \
> # nptl needs unwind support in gcc, which can't be built without glibc.
> DEPENDS = "virtual/${TARGET_PREFIX}gcc-initial linux-libc-headers virtual/${TARGET_PREFIX}libc-initial"
> # nptl needs libgcc but dlopens it, so our shlibs code doesn't detect this
> -#RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
> +RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
> PROVIDES = "virtual/libc virtual/${TARGET_PREFIX}libc-for-gcc"
> PROVIDES += "virtual/libintl virtual/libiconv"
> inherit autotools
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Khem Raj - May 9, 2013, 2:32 p.m.
On May 9, 2013, at 5:55 AM, Bogdan Marinescu <bogdan.a.marinescu@intel.com> wrote:

> libpthread needs libgcc to function properly. Without libgcc I get
> the following error:
> 
> root@qemux86:~# tclsh
> % exit 0
> libgcc_s.so.1 must be installed for pthread_cancel to work
> Aborted
> root@qemux86:~#
> 
> This patch fixes the above issue and similar ones by adding a
> runtime dependency of libgcc to eglibc when threads are enabled.
> 
> Signed-off-by: Bogdan Marinescu <bogdan.a.marinescu@intel.com>
> ---
> meta/recipes-core/eglibc/eglibc.inc |    2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/recipes-core/eglibc/eglibc.inc b/meta/recipes-core/eglibc/eglibc.inc
> index 1e04197..24fb05b 100644
> --- a/meta/recipes-core/eglibc/eglibc.inc
> +++ b/meta/recipes-core/eglibc/eglibc.inc
> @@ -35,7 +35,7 @@ siteconfig_do_siteconfig_gencache_prepend = " \
> # nptl needs unwind support in gcc, which can't be built without glibc.
> DEPENDS = "virtual/${TARGET_PREFIX}gcc-initial linux-libc-headers virtual/${TARGET_PREFIX}libc-initial"
> # nptl needs libgcc but dlopens it, so our shlibs code doesn't detect this
> -#RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
> +RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"

ah too early. I think you should spin out libpthread into separate package and then RDEPEND_libpthread = "…"
and don't use nptl we do not have any other option now a days.


> PROVIDES = "virtual/libc virtual/${TARGET_PREFIX}libc-for-gcc"
> PROVIDES += "virtual/libintl virtual/libiconv"
> inherit autotools
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Phil Blundell - May 9, 2013, 2:32 p.m.
On Thu, 2013-05-09 at 14:19 +0100, Richard Purdie wrote:
> On Thu, 2013-05-09 at 15:55 +0300, Bogdan Marinescu wrote:
> > diff --git a/meta/recipes-core/eglibc/eglibc.inc b/meta/recipes-core/eglibc/eglibc.inc
> > index 1e04197..24fb05b 100644
> > --- a/meta/recipes-core/eglibc/eglibc.inc
> > +++ b/meta/recipes-core/eglibc/eglibc.inc
> > @@ -35,7 +35,7 @@ siteconfig_do_siteconfig_gencache_prepend = " \
> >  # nptl needs unwind support in gcc, which can't be built without glibc.
> >  DEPENDS = "virtual/${TARGET_PREFIX}gcc-initial linux-libc-headers virtual/${TARGET_PREFIX}libc-initial"
> >  # nptl needs libgcc but dlopens it, so our shlibs code doesn't detect this
> > -#RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
> > +RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
> >  PROVIDES = "virtual/libc virtual/${TARGET_PREFIX}libc-for-gcc"
> >  PROVIDES += "virtual/libintl virtual/libiconv"
> >  inherit autotools
> 
> Why/when was that line commented out originally? Also, afaik glibc
> doesn't support anything other than nptl these days so we can probably
> drop the GLIBC_ADDONS check. Khem/Phil?

It was commented out by Khem in this patch:

http://git.openembedded.org/openembedded/commit/?id=e96e82cd

for reasons that are slightly obscure but, if I had to guess, I'd say
that it had something to do with avoiding circular dependencies during
the toolchain bootstrap process.  As far as I can tell nothing else was
added to replace it and the dependency just got lost from that point
onwards.  I'm not sure whether the circularity issue still applies but
it would be worth checking that the toolchain really does still
bootstrap with the dependency reinstated.

p.
Phil Blundell - May 9, 2013, 3:02 p.m.
On Thu, 2013-05-09 at 15:08 +0100, Phil Blundell wrote:
> There was some previous discussion of how to detect the precise
> situation that caused libgcc_s to be required, though my recollection
> of all the details is a bit hazy.  I'll see if I can find it in the
> archives.  

It turns out that the previous discussion was actually on irc, not on
the mailing list.  See:

http://ibot.rikers.org/%23oe/20080725.html.gz

from about 21:56 onwards, and:

http://ibot.rikers.org/%23oe/20080729.html.gz

from about 21:10 onwards.

p.
Mark Hatle - May 9, 2013, 3:26 p.m.
On 5/9/13 9:32 AM, Khem Raj wrote:
>
> On May 9, 2013, at 5:55 AM, Bogdan Marinescu <bogdan.a.marinescu@intel.com> wrote:
>
>> libpthread needs libgcc to function properly. Without libgcc I get
>> the following error:
>>
>> root@qemux86:~# tclsh
>> % exit 0
>> libgcc_s.so.1 must be installed for pthread_cancel to work
>> Aborted
>> root@qemux86:~#
>>
>> This patch fixes the above issue and similar ones by adding a
>> runtime dependency of libgcc to eglibc when threads are enabled.
>>
>> Signed-off-by: Bogdan Marinescu <bogdan.a.marinescu@intel.com>
>> ---
>> meta/recipes-core/eglibc/eglibc.inc |    2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/meta/recipes-core/eglibc/eglibc.inc b/meta/recipes-core/eglibc/eglibc.inc
>> index 1e04197..24fb05b 100644
>> --- a/meta/recipes-core/eglibc/eglibc.inc
>> +++ b/meta/recipes-core/eglibc/eglibc.inc
>> @@ -35,7 +35,7 @@ siteconfig_do_siteconfig_gencache_prepend = " \
>> # nptl needs unwind support in gcc, which can't be built without glibc.
>> DEPENDS = "virtual/${TARGET_PREFIX}gcc-initial linux-libc-headers virtual/${TARGET_PREFIX}libc-initial"
>> # nptl needs libgcc but dlopens it, so our shlibs code doesn't detect this
>> -#RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
>> +RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
>
> ah too early. I think you should spin out libpthread into separate package and then RDEPEND_libpthread = "…"
> and don't use nptl we do not have any other option now a days.

This would be my suggestion.  I'd also want to make sure there is a 
libpthread-dev (which for some reason I think there already is) because the 
links in there are required for on-target thread debugging...

--Mark

>
>> PROVIDES = "virtual/libc virtual/${TARGET_PREFIX}libc-for-gcc"
>> PROVIDES += "virtual/libintl virtual/libiconv"
>> inherit autotools
>> --
>> 1.7.10.4
>>
>>
>> _______________________________________________
>> Openembedded-core mailing list
>> Openembedded-core@lists.openembedded.org
>> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>
Richard Purdie - May 9, 2013, 3:36 p.m.
On Thu, 2013-05-09 at 10:26 -0500, Mark Hatle wrote:
> On 5/9/13 9:32 AM, Khem Raj wrote:
> >
> > On May 9, 2013, at 5:55 AM, Bogdan Marinescu <bogdan.a.marinescu@intel.com> wrote:
> >
> >> libpthread needs libgcc to function properly. Without libgcc I get
> >> the following error:
> >>
> >> root@qemux86:~# tclsh
> >> % exit 0
> >> libgcc_s.so.1 must be installed for pthread_cancel to work
> >> Aborted
> >> root@qemux86:~#
> >>
> >> This patch fixes the above issue and similar ones by adding a
> >> runtime dependency of libgcc to eglibc when threads are enabled.
> >>
> >> Signed-off-by: Bogdan Marinescu <bogdan.a.marinescu@intel.com>
> >> ---
> >> meta/recipes-core/eglibc/eglibc.inc |    2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/meta/recipes-core/eglibc/eglibc.inc b/meta/recipes-core/eglibc/eglibc.inc
> >> index 1e04197..24fb05b 100644
> >> --- a/meta/recipes-core/eglibc/eglibc.inc
> >> +++ b/meta/recipes-core/eglibc/eglibc.inc
> >> @@ -35,7 +35,7 @@ siteconfig_do_siteconfig_gencache_prepend = " \
> >> # nptl needs unwind support in gcc, which can't be built without glibc.
> >> DEPENDS = "virtual/${TARGET_PREFIX}gcc-initial linux-libc-headers virtual/${TARGET_PREFIX}libc-initial"
> >> # nptl needs libgcc but dlopens it, so our shlibs code doesn't detect this
> >> -#RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
> >> +RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
> >
> > ah too early. I think you should spin out libpthread into separate package and then RDEPEND_libpthread = "…"
> > and don't use nptl we do not have any other option now a days.
> 
> This would be my suggestion.  I'd also want to make sure there is a 
> libpthread-dev (which for some reason I think there already is) because the 
> links in there are required for on-target thread debugging...

As I keep mentioning, rightly or probably more wrongly we support one
-dev package per recipe right now, not multiple packages.

Cheers,

Richard
Phil Blundell - May 9, 2013, 3:40 p.m.
On Thu, 2013-05-09 at 10:26 -0500, Mark Hatle wrote:
> This would be my suggestion.  I'd also want to make sure there is a 
> libpthread-dev (which for some reason I think there already is) because the 
> links in there are required for on-target thread debugging...

Really?  If those links are needed for thread debugging then it sounds
like they should be in libthread-db, not in any -dev package.

p.
Mark Hatle - May 9, 2013, 4:04 p.m.
On 5/9/13 10:40 AM, Phil Blundell wrote:
> On Thu, 2013-05-09 at 10:26 -0500, Mark Hatle wrote:
>> This would be my suggestion.  I'd also want to make sure there is a
>> libpthread-dev (which for some reason I think there already is) because the
>> links in there are required for on-target thread debugging...
>
> Really?  If those links are needed for thread debugging then it sounds
> like they should be in libthread-db, not in any -dev package.

I'm pretty sure I'm misremembering the issue.  It's the libthread-db that needs 
the link for debugging.  Last time I was playing with this was pre-Denzil and it 
didn't quite work right.  (gdb on the target debugging threads would say "hey I 
need the ....so to debug".)

If nobody has seen that recently, then ignore that.. it's been resolved.

--Mark

> p.
>
>
Khem Raj - May 9, 2013, 4:40 p.m.
On May 9, 2013, at 9:04 AM, Mark Hatle <mark.hatle@windriver.com> wrote:

> On 5/9/13 10:40 AM, Phil Blundell wrote:
>> On Thu, 2013-05-09 at 10:26 -0500, Mark Hatle wrote:
>>> This would be my suggestion.  I'd also want to make sure there is a
>>> libpthread-dev (which for some reason I think there already is) because the
>>> links in there are required for on-target thread debugging...
>> 
>> Really?  If those links are needed for thread debugging then it sounds
>> like they should be in libthread-db, not in any -dev package.
> 
> I'm pretty sure I'm misremembering the issue.  It's the libthread-db that needs the link for debugging.  Last time I was playing with this was pre-Denzil and it didn't quite work right.  (gdb on the target debugging threads would say "hey I need the ....so to debug".)
> 

No its not needed for debugging rather for unwinding and cancellations to work. 

> If nobody has seen that recently, then ignore that.. it's been resolved.
> 
> --Mark
> 
>> p.
>> 
>> 
> 
> 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Patch

diff --git a/meta/recipes-core/eglibc/eglibc.inc b/meta/recipes-core/eglibc/eglibc.inc
index 1e04197..24fb05b 100644
--- a/meta/recipes-core/eglibc/eglibc.inc
+++ b/meta/recipes-core/eglibc/eglibc.inc
@@ -35,7 +35,7 @@  siteconfig_do_siteconfig_gencache_prepend = " \
 # nptl needs unwind support in gcc, which can't be built without glibc.
 DEPENDS = "virtual/${TARGET_PREFIX}gcc-initial linux-libc-headers virtual/${TARGET_PREFIX}libc-initial"
 # nptl needs libgcc but dlopens it, so our shlibs code doesn't detect this
-#RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
+RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
 PROVIDES = "virtual/libc virtual/${TARGET_PREFIX}libc-for-gcc"
 PROVIDES += "virtual/libintl virtual/libiconv"
 inherit autotools