Skip to contentSkip to conversation

libgcc not being pulled into OABI images

DISCUSSION Richard Purdie 4 participants 4 messages Mar 30, 2008 – Apr 3, 2008

lore
Share & tools
lore
#0 lore raw

Hi,

Various people had reported problems with libgcc not being pulled into OABI images after some of the recent changes. Basically libgcc isn't being listed as NEEDED (in objdump -p) when it used to be.

I did some tests comparing a good build with a bad build and it looked like there was some problem with the crtbegin.o and crtbeginS.o files in the cross directory. Swapping those two files over makes the difference between libgcc appearing in NEEDED and not appearing.

These come from gcc-cross and the difference in compile options which seems to trigger the problem is the -Dinhibit_libc flag. This is set in the Makefile by the inhibit_libc option. Dependencies work as expected if its true and break if its false.

That variable is set from gcc/configure with:

# If this is a cross-compiler that does not

# have its own set of headers then define
# inhibit_libc

# If this is using newlib, without having the headers available now,

# then define inhibit_libc in LIBGCC2_CFLAGS.
# This prevents libgcc2 from containing any code which requires libc
# support.
inhibit_libc=false
if { { test x$host != x$target && test "x$with_sysroot" = x ; } ||
       test x$with_newlib = xyes ; } &&
     { test "x$with_headers" = x || test "x$with_headers" = xno ; } ;
then
       inhibit_libc=true
fi

and in the recent gcc changes we've messed around with a number of these options so this is likely to be the reason for the change.

I suspect in EABI builds something else causes libgcc to be pulled in since inhibit_libc=false for these too yet they don't break.

So no, I don't have a fix as such and someone needs to look into this further but at least we have a clue to the problem.

The bug reports were pthread related and it could be that specific library has a problem which this other change was masking until now...

Cheers,

Richard

#1 lore raw

Hi,

I tested on my host machine (AMD64) and libgcc is not it NEEDED but is installed anyway. So it seems to be no problem that libgcc is not in needed. So I investigated libpthread and found out that it tries to dlopen libgcc and fails if it can't. Our shlibs code can't detect this so libgcc does not get pulled into image. So I suggest something like:

glibc/glibc.inc 3aa1e1a80cf9f0f899b5a79b857bfa5427f5d54e renamed from glibc/glibc.inc e9a2a880277298ca08e7f53a4e5c69127415a5ed +0 -0
@@ -7,6 +7,8 @@ DEPENDS = "${@['virtual/${TARGET_PREFIX}

DEPENDS = "${@['virtual/${TARGET_PREFIX}gcc-initial', 'virtual/${TARGET_PREFIX}gcc']['nptl' in '${GLIBC_ADDONS}']} linux-libc-headers" #this leads to circular deps, so lets not add it yet
#RDEPENDS_ldd += " bash"
+# nptl needs libgcc but dlopens it, so our shlibs code doesn't detect this
+RDEPENDS += "${@['','libgcc']['ntpl' in '${GLIBC_ADDONS}']}"
PROVIDES = "virtual/libc ${@['virtual/${TARGET_PREFIX}libc-for-gcc', '']['nptl' in '${GLIBC_ADDONS}']}"
PROVIDES += "virtual/libintl virtual/libiconv"

Is it ok if I comit this (and bump PRs of all packages that use this file?)

Regards,
Thomas

#2 lore raw
Quoted 23 lines · Thomas Kunze

Hi,

I tested on my host machine (AMD64) and libgcc is not it NEEDED but is installed anyway. So it seems to be no problem that libgcc is not in needed. So I investigated libpthread and found out that it tries to dlopen libgcc and fails if it can't. Our shlibs code can't detect this so libgcc does not get pulled into image. So I suggest something like:

--- packages/glibc/glibc.inc e9a2a880277298ca08e7f53a4e5c69127415a5ed
+++ packages/glibc/glibc.inc 3aa1e1a80cf9f0f899b5a79b857bfa5427f5d54e
@@ -7,6 +7,8 @@ DEPENDS = "${@['virtual/${TARGET_PREFIX}
DEPENDS = "${@['virtual/${TARGET_PREFIX}gcc-initial',
'virtual/${TARGET_PREFIX}gcc']['nptl' in '${GLIBC_ADDONS}']} linux-libc-headers"
#this leads to circular deps, so lets not add it yet #RDEPENDS_ldd += " bash"
+# nptl needs libgcc but dlopens it, so our shlibs code doesn't detect this +RDEPENDS += "${@['','libgcc']['ntpl' in '${GLIBC_ADDONS}']}"
PROVIDES = "virtual/libc ${@['virtual/${TARGET_PREFIX}libc-for-gcc',
'']['nptl' in '${GLIBC_ADDONS}']}"
PROVIDES += "virtual/libintl virtual/libiconv"

Quoted 1 line

Is it ok if I comit this (and bump PRs of all packages that use this file?)

nptl glibc dlopens libgcc (e.g. code using exceptions) so this fix creating an explicit dependency looks ok to me.
it does not have it in DT_NEEDED section may be because it links with -static-libgcc when build

Quoted 11 lines

Regards,
Thomas

_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

#3 lore raw
In reply to Thomas Kunze
Quoted 1 line · Thomas Kunze

So I suggest something like:

Thomas,

thanks for your work on this. Unfortunately, the issue remains the same for me, even with that change. I added the lines you suggested, cleaned out tmp and compiled an altboot-console-image. The boot process hangs with "libgcc_so.1 must be installed for pthread_cancel to work"

Regards

Rolf