Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
Due to network maintenance being performed by our provider, LQ will be down starting at 05:01 AM UTC. The exact duration of the downtime isn't currently known. We apologize for the inconvenience.
|
 |
01-16-2006, 12:27 PM
|
#1
|
|
Member
Registered: Dec 2005
Location: New York
Distribution: Debian/GNU
Posts: 235
Rep:
|
How to get local gcc to link with local glibc
I just finished compiling gcc with, I thought, my local build of glibc-2.3.6. However, the new compiler won't automatically link to the new libraries.
Observe ->
Code:
radish% which gcc
/usr/local/bin/gcc
radish% which ldd
/usr/glibc2/bin/ldd
radish% ldd `which gcc`
libc.so.6 => /usr/glibc2/lib/libc.so.6 (0x40018000)
/usr/glibc2/lib/ld-linux.so.2 (0x40000000)
radish% gcc test.c -o exec
radish% ldd exec
libc.so.6 => /lib/libc.so.6 (0x40019000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
the output executable is still linked to the old linux loader. WTF? I can force it by passing "-Wl,--dynamic-linker=/usr/glibc2/lib/ld-linux.so.2" to it every single time I run gcc, but that's not really a solution. I know it's somehow a problem with how I compiled GCC. I tried cross-compiling gcc with /usr/glibc2 as the system root, but it fails at the stage one compiler, saying it can't find certain symbols which I can see in /usr/glibc2/lib/ld-linux.so.2, so I know that its not using the right loader either.
Any help will be very appreciated. They flat refused to help me on gcc bugzilla ( http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25794). I've been trying to get this working for weeks now and I'm starting to lose my nerve.
-dave
|
|
|
|
01-16-2006, 02:39 PM
|
#2
|
|
Member
Registered: Dec 2005
Location: New York
Distribution: Debian/GNU
Posts: 235
Original Poster
Rep:
|
please please let there be someone who knows what I'm talking about. I just tried probably my 70th configuration and EVERY FREAKIN TIME it exits after compiling for about an hour with linker errors.
Code:
stage1/xgcc -Bstage1/ -B/usr/glibc2/i686-pc-linux-gnu/bin/ -O2 -g -fomit-frame-pointer -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wold-style-definition -DHAVE_CONFIG_H -DGENERATOR_FILE -Wl,--dynamic-linker=/usr/glibc2/lib/ld-linux.so.2 -o build/genmodes \
build/genmodes.o build/errors.o ../build-i686-pc-linux-gnu/libiberty/libiberty.a
/usr/glibc2/lib/libc.so.6: undefined reference to `_rtld_global@GLIBC_PRIVATE'
/usr/glibc2/lib/libc.so.6: undefined reference to `__libc_enable_secure@GLIBC_PRIVATE'
/usr/glibc2/lib/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE'
/usr/glibc2/lib/libc.so.6: undefined reference to `_dl_out_of_memory@GLIBC_PRIVATE'
/usr/glibc2/lib/libc.so.6: undefined reference to `_dl_argv@GLIBC_PRIVATE'
collect2: ld returned 1 exit status
make[2]: *** [build/genmodes] Error 1
make[2]: Leaving directory `/usr/home/davek/src/gcc-build/gcc'
make[1]: *** [stage2_build] Error 2
make[1]: Leaving directory `/usr/home/davek/src/gcc-build/gcc'
make: *** [bootstrap4] Error 2
And I even know that the stage1 compiler is using the new libs ->
Code:
$ ldd gcc/stage1/xgcc
libc.so.6 => /usr/glibc2/lib/libc.so.6 (0x40018000)
/usr/glibc2/lib/ld-linux.so.2 (0x40000000)
I'm on my last straw. I can't build a system if I can't build gcc.
|
|
|
|
01-16-2006, 02:51 PM
|
#3
|
|
Senior Member
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973
Rep:
|
have you edited the gcc specs file? (/usr/local/lib/gcc-lib/*/*/specs)
|
|
|
|
01-16-2006, 10:37 PM
|
#4
|
|
Member
Registered: Dec 2005
Location: New York
Distribution: Debian/GNU
Posts: 235
Original Poster
Rep:
|
radish% ls /usr/local/lib/gcc-lib
ls: /usr/local/lib/gcc-lib: No such file or directory
radish% find /usr/local -name specs
radish% find /usr/local -name \*specs\*
[noting]
I just installed a local build of gcc (using old libs). Perhaps I should use system gcc, but that's pretty old. I can't find the specs file for the local gcc.
|
|
|
|
01-17-2006, 02:46 AM
|
#5
|
|
Senior Member
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973
Rep:
|
the command to find the specs file is:
Code:
gcc --print-file specs
( note that the gcc you built and installed has to be the first one in your path for this to work, if not, then you need to adjust your path. for example, if the newer gcc was installed in /usr/local and gcc is in /usr/local/bin:
Code:
export PATH=/usr/local/bin:$PATH
will make the one in /usr/local/bin the first one encountered when you enter the command gcc. also, what configure options did you pass when you built the new gcc?)
It would probably help if you stated what you are trying to accomplish, if you are building another system, it might help if you look here:
http://www.linuxfromscratch.org/lfs/view/stable/
it's probably not exactly what you want, but it has instructions on building a temporary toolchain used to build a linux system, linking against a fresh glibc build.
hope this helps.
Last edited by __J; 01-17-2006 at 02:50 AM.
|
|
|
|
01-17-2006, 02:47 PM
|
#6
|
|
Member
Registered: Dec 2005
Location: New York
Distribution: Debian/GNU
Posts: 235
Original Poster
Rep:
|
that link looks very helpfull, thanks.
I've tried dozens of different configurations, and I always come up with linker errors. The only way I can get it to continue is to actually switch the makefile mid-build. I can't imagine that makes for a usable compiler.
I figured out that my gcc has compiled in specs. I just did "./configure ; make bootstrap" for the thing. I did a "gcc -dumpspecs", and I assume the important lines are:
*dynamic_linker:
/lib/ld-linux.so.2
and that should be /usr/glibc2/lib/ld-linux.so.2 (at least at compile time). I'm using the compiler flag -Wl,--dynamic-linker=/usr/glibc2/lib/ld-linux.so.2, but I still get unresolved symbols.
Last edited by dombrowsky; 01-17-2006 at 02:48 PM.
|
|
|
|
01-17-2006, 11:50 PM
|
#7
|
|
Member
Registered: Dec 2005
Location: New York
Distribution: Debian/GNU
Posts: 235
Original Poster
Rep:
|
Got it to build this time, but the compiler won't work without hacking.
/home/davek/src/gcc-build/gcc/xgcc -Bgcc test.c
/usr/glibc2/lib/libc.so.6: undefined reference to `_rtld_global@GLIBC_PRIVATE'
/usr/glibc2/lib/libc.so.6: undefined reference to `__libc_enable_secure@GLIBC_PRIVATE'
/usr/glibc2/lib/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE'
/usr/glibc2/lib/libc.so.6: undefined reference to `_dl_out_of_memory@GLIBC_PRIVATE'
/usr/glibc2/lib/libc.so.6: undefined reference to `_dl_argv@GLIBC_PRIVATE'
collect2: ld returned 1 exit status
those symbols are defined in /usr/glibc2/lib/ld-linux.so.2. I know the compiler us using that as the linker, becuase it prints it in the specs. However, the executable is still linked to old libs.
$ ldd gcc/xgcc
libc.so.6 => /lib/libc.so.6 (0x40019000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
annoying. any help would be wonderful.
|
|
|
|
01-18-2006, 12:48 AM
|
#8
|
|
Member
Registered: Dec 2005
Location: New York
Distribution: Debian/GNU
Posts: 235
Original Poster
Rep:
|
The compiler won't run without flags, for example ->
gcc -Wl,-rpath,/usr/glibc2/lib test.c
anyone know what I configured wrong? The tests won't pass if it has to pass those wierdo flags to it.
I also noticed something else. Observe ->
Code:
$ export LD_LIBRARY_PATH=/usr/glibc2/lib
$ gcc test.c
/usr/local/lib/gcc/i686-pc-linux-gnu/4.0.2/../../../../i686-pc-linux-gnu/bin/as: /lib/ld-linux.so.2: version `GLIBC_PRIVATE' not found (required by /usr/glibc2/lib/libc.so.6)
isn't 'as' in binutils? Perhaps I should recompile binutils with new glibc first.
|
|
|
|
01-20-2006, 12:34 AM
|
#9
|
|
Member
Registered: Dec 2005
Location: New York
Distribution: Debian/GNU
Posts: 235
Original Poster
Rep:
|
From reading the linux from scratch pages, I realize that I didn't understand something fundamental about the process. Rebuilding glibc is basically building a new system. You have to bootstrap it by first building
new tools with old libs and then new tools with the new libs. A much longer process than I thought....
|
|
|
|
01-20-2006, 02:01 PM
|
#10
|
|
Member
Registered: Dec 2005
Location: New York
Distribution: Debian/GNU
Posts: 235
Original Poster
Rep:
|
SUCCESS!
$ gcc test.c
$ ldd a.out
libc.so.6 => /usr/glibc2/lib/libc.so.6 (0x40018000)
/usr/glibc2/lib/ld-linux.so.2 (0x40000000)
$ readelf -l a.out | grep lib
[Requesting program interpreter: /usr/glibc2/lib/ld-linux.so.2]
I now have a compiler which will automatically link to the new glibc libraries. My previous approach was actually correct, I was just doing things in the wrong order. In short, here's how to construct a new glibc system from sources:
- Compile binutils using old gcc
- Compile new gcc using bootstrap and old gcc
- Compile new glibc using new gcc
- recompile and install ld in binutils with LIB_PATH=/usr/glibc2
- recompile and install new gcc using new glibc. this is the hard part, it requires figuring out how to get gcc to link to the new libraries. In my system, I gcc compiled by default WITHOUT a specs file, so I had to change gcc/config/i386/linux.h to point to the new linker, then add LDFLAGS=-Wl,--dynamic-linker=/usr/glibc2/lib/ld-linux.so.2 . This is the part of the process which requires the most magic
- recompile and install binutils using new-linked gcc in /usr/glibc2
- take over world
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 07:28 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|