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 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 |
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 \ Code:
$ ldd gcc/stage1/xgcc |
have you edited the gcc specs file? (/usr/local/lib/gcc-lib/*/*/specs)
|
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. |
the command to find the specs file is:
Code:
gcc --print-file specs Code:
export PATH=/usr/local/bin:$PATH 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. |
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. |
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. |
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 |
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.... |
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:
|
All times are GMT -5. The time now is 01:48 PM. |