Discussion:
Testing a glibc build
Carlos O'Donell
2013-06-11 20:26:53 UTC
Permalink
I've been reading http://sourceware.org/glibc/wiki/Testing/Builds and
found that the tip "Compile against glibc in fixed location". That
seems almost[*]to work fine for most applications and libraries, but
not when using it on glibc itself. Is that supposed to work? I cant
seem to find a way of setting the LDPATH (or really, the rpath) for
glibc.
[*] - glibc need to be configured with --prefix=/usr and 'make
install' needs DESTDIR=${SYSROOT} for that to work. If not gcc is
having trouble finding the startup files.
Please describe exactly what you are trying to do and what problem
you are seeing.

I've moved this conversation to libc-help.

Cheers,
Carlos.
Christer Solskogen
2013-06-11 20:51:03 UTC
Permalink
Post by Carlos O'Donell
Please describe exactly what you are trying to do and what problem
you are seeing.
Build and install glibc in a non-default directory (--prefix=/usr and
DESTDIR=${SYSROOT} )
set CC="gcc --sysroot=${SYSROOT} -Wl,-rpath=${SYSROOT}/lib
-Wl,--dynamic-linker=${SYSROOT}/lib/ld-linux-x86-64.so.2"
$CC hello.c -o hello
readelf -l says:
[Requesting program interpreter: ${SYSROOT}/lib/ld-linux-x86-64.so.2]
Running ./hello works fine

Build and install glibc again.
./hello will no longer run - This is the error:
Inconsistency detected by ld.so: get-dynamic-info.h: 134:
elf_get_dynamic_info: Assertion `info[15] == ((void *)0)' failed!
A recompile does not fix it.

objdump -x show the correct RPATH as well.
--
chs
Carlos O'Donell
2013-06-11 21:51:35 UTC
Permalink
Post by Carlos O'Donell
Please describe exactly what you are trying to do and what problem
you are seeing.
Build and install glibc in a non-default directory (--prefix=/usr and DESTDIR=${SYSROOT} )
set CC="gcc --sysroot=${SYSROOT} -Wl,-rpath=${SYSROOT}/lib -Wl,--dynamic-linker=${SYSROOT}/lib/ld-linux-x86-64.so.2"
$CC hello.c -o hello
[Requesting program interpreter: ${SYSROOT}/lib/ld-linux-x86-64.so.2]
Running ./hello works fine
Build and install glibc again.
Inconsistency detected by ld.so: get-dynamic-info.h: 134: elf_get_dynamic_info: Assertion `info[15] == ((void *)0)' failed!
A recompile does not fix it.
objdump -x show the correct RPATH as well.
The prefix is part of the ABI, you can't change it.

Cheers,
Carlos.
Carlos O'Donell
2013-06-11 21:52:41 UTC
Permalink
Post by Carlos O'Donell
Please describe exactly what you are trying to do and what problem
you are seeing.
Build and install glibc in a non-default directory (--prefix=/usr and DESTDIR=${SYSROOT} )
set CC="gcc --sysroot=${SYSROOT} -Wl,-rpath=${SYSROOT}/lib -Wl,--dynamic-linker=${SYSROOT}/lib/ld-linux-x86-64.so.2"
$CC hello.c -o hello
[Requesting program interpreter: ${SYSROOT}/lib/ld-linux-x86-64.so.2]
Running ./hello works fine
Build and install glibc again.
Inconsistency detected by ld.so: get-dynamic-info.h: 134: elf_get_dynamic_info: Assertion `info[15] == ((void *)0)' failed!
A recompile does not fix it.
objdump -x show the correct RPATH as well.
To put it another way... your first glibc has one ABI, the second glibc has another.

You compiled your first application against the first glibc.

Then you try to run your application against the second incompatible ABI glibc, which has prefix set to something else.

Cheers,
Carlos.
Christer Solskogen
2013-06-12 05:23:44 UTC
Permalink
Post by Carlos O'Donell
Post by Carlos O'Donell
Please describe exactly what you are trying to do and what problem
you are seeing.
Build and install glibc in a non-default directory (--prefix=/usr and DESTDIR=${SYSROOT} )
set CC="gcc --sysroot=${SYSROOT} -Wl,-rpath=${SYSROOT}/lib -Wl,--dynamic-linker=${SYSROOT}/lib/ld-linux-x86-64.so.2"
$CC hello.c -o hello
[Requesting program interpreter: ${SYSROOT}/lib/ld-linux-x86-64.so.2]
Running ./hello works fine
Build and install glibc again.
Inconsistency detected by ld.so: get-dynamic-info.h: 134: elf_get_dynamic_info: Assertion `info[15] == ((void *)0)' failed!
A recompile does not fix it.
objdump -x show the correct RPATH as well.
To put it another way... your first glibc has one ABI, the second glibc has another.
You compiled your first application against the first glibc.
Then you try to run your application against the second incompatible ABI glibc, which has prefix set to something else.
Why is it incompatible? I still get the same error if I run a
recompile on hello.c. (compiling works).
--prefix and ${SYSROOT} is the same on both glibc installations.

--
chs,
Carlos O'Donell
2013-06-12 14:40:42 UTC
Permalink
Post by Christer Solskogen
Why is it incompatible? I still get the same error if I run a
recompile on hello.c. (compiling works). --prefix and ${SYSROOT} is
the same on both glibc installations.
The prefix is used to lookup files and therefore it's part of the
distribution selected ABI. You can't change it without ensuring that
exactly what was at the previous prefix is also in the current prefix.

If you used exactly the same --prefix and ${SYSROOT} and it still fails
then we need detailed instructions from you e.g. step by step.

Cheers,
Carlos.
Christer Solskogen
2013-06-12 15:02:35 UTC
Permalink
Post by Carlos O'Donell
If you used exactly the same --prefix and ${SYSROOT} and it still fails
then we need detailed instructions from you e.g. step by step.
I think I did, but probably not clearly.

SYSROOT=$HOME/glibc

Compile glibc:
configure --prefix=/usr
make && make install DESTDIR=${SYSROOT}

export CC="gcc --sysroot=${SYSROOT} -Wl,-rpath=${SYSROOT}/lib
-Wl,--dynamic-linker=${SYSROOT}/lib/ld-linux-x86-64.so.2"
$CC hello.c hello
./hello (works)

Confgure, make and make install glibc again with the same instructions as above.
run ./hello again.

--
chs,
Carlos O'Donell
2013-06-12 20:06:43 UTC
Permalink
Post by Christer Solskogen
Post by Carlos O'Donell
If you used exactly the same --prefix and ${SYSROOT} and it still fails
then we need detailed instructions from you e.g. step by step.
I think I did, but probably not clearly.
SYSROOT=$HOME/glibc
configure --prefix=/usr
make && make install DESTDIR=${SYSROOT}
export CC="gcc --sysroot=${SYSROOT} -Wl,-rpath=${SYSROOT}/lib
-Wl,--dynamic-linker=${SYSROOT}/lib/ld-linux-x86-64.so.2"
$CC hello.c hello
./hello (works)
Confgure, make and make install glibc again with the same instructions as above.
run ./hello again.
Works fine for me, so it must be a difference in the build tools or the
sysroot setup.

I'm not saying I don't believe you, but I must be doing something different.

I'm using upstream binutils compiled with --with-sysroot=${SYSROOT}.

Then I use the same binutils in the link.

Cheers,
Carlos.
Christer Solskogen
2013-06-12 21:08:20 UTC
Permalink
Post by Carlos O'Donell
Works fine for me, so it must be a difference in the build tools or the
sysroot setup.
Okay, thanks for trying it out. Can you post your instructions?
Post by Carlos O'Donell
I'm using upstream binutils compiled with --with-sysroot=${SYSROOT}.
I did not do that, but I'll try that as well. Thanks!

--
chs,
Carlos O'Donell
2013-06-13 14:35:47 UTC
Permalink
Post by Christer Solskogen
Post by Carlos O'Donell
Works fine for me, so it must be a difference in the build tools or the
sysroot setup.
Okay, thanks for trying it out. Can you post your instructions?
Post by Carlos O'Donell
I'm using upstream binutils compiled with --with-sysroot=${SYSROOT}.
I did not do that, but I'll try that as well. Thanks!
Untested, but roughly:

Download linux master
Defconfig it.
make headers_install INSTALL_HDR_PATH=/home/carlos/install-linux

Download binutils cvs head.
configure --prefix=/usr --with-sysroot=/home/carlos/install-glibc
make
make install
make install DESTDIR=/home/carlos/install-glibc/

Download glibc master
/home/carlos/src/glibc/configure \
--with-headers="/home/carlos/install-linux/include" \
--prefix=/usr \
--enable-add-ons=nptl,ports
make -j4
make install DESTDIR=/home/carlos/install-glibc

Build test application:
# Need access to new ld for --sysroot support.
export PATH=/home/carlos/install-glibc/usr/bin:$PATH
gcc -g3 -O0 --sysroot=/home/carlos/install-glibc/ \
-Wl,-rpath=/home/carlos/install-glibc/lib:\
/home/carlos/install-glibc/usr/lib:\
/home/carlos/install-glibc/usr/lib64:\
/home/carlos/install-glibc/lib64 \
-Wl,--dynamic-linker=/home/carlos/install-glibc/lib64/ld-linux-x86-64.so.2 \
-o test test.c -Wl,-Map,linkmap.txt

Reconfigure and rebuild glibc:
/home/carlos/src/glibc/configure \
--with-headers="/home/carlos/install-linux/include" \
--prefix=/usr \
--enable-add-ons=nptl,ports
make -j4
make install DESTDIR=/home/carlos/install-glibc

Rerun previously built test application.

Cheers,
Carlos.
Christer Solskogen
2013-06-14 06:38:36 UTC
Permalink
Post by Carlos O'Donell
Post by Christer Solskogen
Post by Carlos O'Donell
Works fine for me, so it must be a difference in the build tools or the
sysroot setup.
Okay, thanks for trying it out. Can you post your instructions?
Post by Carlos O'Donell
I'm using upstream binutils compiled with --with-sysroot=${SYSROOT}.
I did not do that, but I'll try that as well. Thanks!
Download linux master
Defconfig it.
make headers_install INSTALL_HDR_PATH=/home/carlos/install-linux
Download binutils cvs head.
configure --prefix=/usr --with-sysroot=/home/carlos/install-glibc
make
make install
make install DESTDIR=/home/carlos/install-glibc/
Download glibc master
/home/carlos/src/glibc/configure \
--with-headers="/home/carlos/install-linux/include" \
--prefix=/usr \
--enable-add-ons=nptl,ports
make -j4
make install DESTDIR=/home/carlos/install-glibc
# Need access to new ld for --sysroot support.
export PATH=/home/carlos/install-glibc/usr/bin:$PATH
gcc -g3 -O0 --sysroot=/home/carlos/install-glibc/ \
-Wl,-rpath=/home/carlos/install-glibc/lib:\
/home/carlos/install-glibc/usr/lib:\
/home/carlos/install-glibc/usr/lib64:\
/home/carlos/install-glibc/lib64 \
-Wl,--dynamic-linker=/home/carlos/install-glibc/lib64/ld-linux-x86-64.so.2 \
-o test test.c -Wl,-Map,linkmap.txt
/home/carlos/src/glibc/configure \
--with-headers="/home/carlos/install-linux/include" \
--prefix=/usr \
--enable-add-ons=nptl,ports
make -j4
make install DESTDIR=/home/carlos/install-glibc
Rerun previously built test application.
Thanks! That worked for me as well :-)


--
chs,
Carlos O'Donell
2013-06-14 13:49:23 UTC
Permalink
Post by Christer Solskogen
Thanks! That worked for me as well :-)
Excellent. Please pass it on, or help others
who have similar problems :-)

Cheers,
Carlos.

Continue reading on narkive:
Loading...