On Jan 24, 2008 7:53 PM, Andrew Haley <aph@xxxxxxxxxx> wrote: > > Angelo Leto wrote: > > On Jan 24, 2008 5:12 PM, Andrew Haley <aph@xxxxxxxxxx> wrote: > >> Angelo Leto wrote: > >>> On Jan 24, 2008 12:18 PM, Andrew Haley <aph@xxxxxxxxxx> wrote: > >>>> Angelo leto wrote: > >>>>> Hi, I'm trying to build statically all the gcc executables in order to > >>>>> generate a portable compiler package, in particular I need a package > >>>>> which is not dependent from a specific dynamic loader version > >>>>> (ld-linux.so.2), could you please help me to find a way to obtain > >>>>> this? > >>>>> For instance I can run gcc using the command "ld-linux.so.2 > >>>>> ~/mygcc/usr/bin/c++", but c++ then calls cc1plus which also needs > >>>>> ld-linux.so.2 .... > >>>> The short answer is to set the makefile args to that gcc links with > >>>> -static. Simply "make LDFLAGS=-static" might work for you. > >>> I already tried this, but seems not to work. > >> It works for me. You need to tell us in what way it seems not to > >> work for you. We can't get far by guessing. > > > > The steps I execute are: > > 1) I downloaded gcc-4.2.2 from > > ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.2.2/gcc-4.2.2.tar.bz2 > > 2) enter gcc-4.2.2 > > 3) make LDFLAGS=-static > > 4) /usr/local/src/gcc-4.2.2 # ldd host-i686-pc-linux-gnu/gcc/cc1plus > > linux-gate.so.1 => (0xffffe000) > > libc.so.6 => /lib/libc.so.6 (0xb7e94000) > > /lib/ld-linux.so.2 (0xb7fdd000) > > That's odd, because when I tried it, it worked. Perhaps because I built > without bootstrapping. Maybe it's because you're building a different > version of gcc. > > If you go into the gcc dir, > > # rm cc1plus > # make cc1plus LDFLAGS=-static > > what happens? it works if I enter the directory host-i686-pc-linux-gnu/gcc and then i do `make LDFLAGS=-static` but if I run the command from the gcc-4.2.2 directory it build almost all dynamically. Anyway it's ok now. > > I do sympathize, but I think you're doing the wrong thing. Yes, you are > going to have to have two versions of your gcc binaries, one with > ld-linux.so.2 and one with ld-linux.so.1, but that should be all. no, there are diffences in symbols between the ld-linux.so.2 coming from libc6 2.3.6 (debian 4.0) and the ld-linux.so.2 coming e.g. from gentoo (http://distfiles.gentoo.org/distfiles/glibc-2.6.1.tar.bz2) but the same thing append also with a newer debian version. This difference may be due to different building flags, patches .... ########## LINUX BOX 1 debian 4.0 libc 2.3.6.ds1-8 ############## root@nowhere:/lib# dpkg -s libc6 Package: libc6 Status: install ok installed .... Maintainer: GNU Libc Maintainers <debian-glibc@xxxxxxxxxxxxxxxx> Architecture: i386 Source: glibc Version: 2.3.6.ds1-8 root@nowhere:/lib# dpkg -L libc6 .... /lib/libm.so.6 /lib/libcidn.so.1 /lib/libc.so.6 /lib/libanl.so.1 /lib/ld-linux.so.2 <<< ============= /lib/tls/libutil.so.1 /lib/tls/libresolv.so.2 ..... root@nowhere:/lib# readelf -s /lib/ld-linux.so.2 Symbol table '.dynsym' contains 35 entries: Num: Value Size Type Bind Vis Ndx Name 0: 00000000 0 NOTYPE LOCAL DEFAULT UND 1: 00000790 0 SECTION LOCAL DEFAULT 9 2: 000112e0 0 SECTION LOCAL DEFAULT 10 3: 0001464c 0 SECTION LOCAL DEFAULT 11 4: 000146b0 0 SECTION LOCAL DEFAULT 12 5: 00015ca0 0 SECTION LOCAL DEFAULT 13 6: 00016020 0 SECTION LOCAL DEFAULT 17 7: 00016458 0 SECTION LOCAL DEFAULT 18 8: 00016020 1080 OBJECT GLOBAL DEFAULT 17 _rtld_global@@GLIBC_PRIVATE 9: 0000e6c0 279 FUNC GLOBAL DEFAULT 9 _dl_make_stack_executable@@GLIBC_PRIVATE 10: 00015f1c 4 OBJECT GLOBAL DEFAULT 13 __libc_stack_end@@GLIBC_2.1 11: 0000fc90 288 FUNC WEAK DEFAULT 9 __libc_memalign@@GLIBC_2.0 12: 0000fdb0 43 FUNC WEAK DEFAULT 9 malloc@@GLIBC_2.0 13: 00000000 0 OBJECT GLOBAL DEFAULT ABS GLIBC_2.1 14: 0000d9c0 88 FUNC GLOBAL DEFAULT 9 _dl_deallocate_tls@@GLIBC_PRIVATE 15: 00015f18 4 OBJECT GLOBAL DEFAULT 13 __libc_enable_secure@@GLIBC_PRIVATE 16: 0000d980 13 FUNC GLOBAL DEFAULT 9 __tls_get_addr@@GLIBC_2.3 17: 0000d990 34 FUNC GLOBAL DEFAULT 9 _dl_get_tls_static_info@@GLIBC_PRIVATE 18: 0000fe90 39 FUNC WEAK DEFAULT 9 calloc@@GLIBC_2.0 19: 0000c010 5 FUNC GLOBAL DEFAULT 9 _dl_debug_state@@GLIBC_PRIVATE 20: 00015ca0 4 OBJECT GLOBAL DEFAULT 13 _dl_argv@@GLIBC_PRIVATE 21: 0000df40 522 FUNC GLOBAL DEFAULT 9 _dl_allocate_tls_init@@GLIBC_PRIVATE 22: 00000000 0 OBJECT GLOBAL DEFAULT ABS GLIBC_2.0 23: 00000000 0 OBJECT GLOBAL DEFAULT ABS GLIBC_PRIVATE 24: 00015cc0 460 OBJECT GLOBAL DEFAULT 13 _rtld_global_ro@@GLIBC_PRIVATE 25: 0000fde0 171 FUNC WEAK DEFAULT 9 realloc@@GLIBC_2.0 26: 0000e480 203 FUNC GLOBAL DEFAULT 9 _dl_tls_setup@@GLIBC_PRIVATE 27: 00006460 405 FUNC GLOBAL DEFAULT 9 _dl_rtld_di_serinfo@@GLIBC_PRIVATE 28: 00011b99 14 OBJECT GLOBAL DEFAULT 10 _dl_out_of_memory@@GLIBC_PRIVATE 29: 0000cec0 557 FUNC GLOBAL DEFAULT 9 _dl_mcount@@GLIBC_2.1 30: 0000e240 39 FUNC GLOBAL DEFAULT 9 _dl_allocate_tls@@GLIBC_PRIVATE 31: 0000db60 990 FUNC GLOBAL DEFAULT 9 ___tls_get_addr@@GLIBC_2.3 32: 000164e4 20 OBJECT GLOBAL DEFAULT 18 _r_debug@@GLIBC_2.0 33: 00000000 0 OBJECT GLOBAL DEFAULT ABS GLIBC_2.3 34: 0000fc40 79 FUNC WEAK DEFAULT 9 free@@GLIBC_2.0 ########## END LINUX BOX 1 debian 4.0 libc 2.3.6.ds1-8 ############## ########## LINUX BOX 2 gentoo glibc-2.6.1 ############## root@localhost:/lib# readelf -s /lib/ld-linux.so.2 Symbol table '.dynsym' contains 31 entries: Num: Value Size Type Bind Vis Ndx Name 0: 00000000 0 NOTYPE LOCAL DEFAULT UND 1: 00000000 0 OBJECT GLOBAL DEFAULT ABS GLIBC_2.1 2: 0000fd60 34 FUNC GLOBAL DEFAULT 10 _dl_get_tls_static_info@@GLIBC_PRIVATE 3: 00000000 0 OBJECT GLOBAL DEFAULT ABS GLIBC_PRIVATE 4: 00000000 0 OBJECT GLOBAL DEFAULT ABS GLIBC_2.3 5: 00000000 0 OBJECT GLOBAL DEFAULT ABS GLIBC_2.4 6: 000140b0 81 FUNC WEAK DEFAULT 10 free@@GLIBC_2.0 7: 00014260 154 FUNC WEAK DEFAULT 10 realloc@@GLIBC_2.0 8: 000107f0 29 FUNC GLOBAL DEFAULT 10 _dl_allocate_tls@@GLIBC_PRIVATE 9: 0001b63c 20 OBJECT GLOBAL DEFAULT 20 _r_debug@@GLIBC_2.0 10: 0001aef4 4 OBJECT GLOBAL DEFAULT 15 __libc_stack_end@@GLIBC_2.1 11: 0000fe80 133 FUNC GLOBAL DEFAULT 10 _dl_tls_get_addr_soft@@GLIBC_PRIVATE 12: 00014110 278 FUNC WEAK DEFAULT 10 __libc_memalign@@GLIBC_2.0 13: 000102a0 137 FUNC GLOBAL DEFAULT 10 _dl_deallocate_tls@@GLIBC_PRIVATE 14: 00014300 96 FUNC WEAK DEFAULT 10 calloc@@GLIBC_2.0 15: 0001ac80 4 OBJECT GLOBAL DEFAULT 15 _dl_argv@@GLIBC_PRIVATE 16: 0000f240 582 FUNC GLOBAL DEFAULT 10 _dl_mcount@@GLIBC_2.1 17: 00010a30 198 FUNC GLOBAL DEFAULT 10 _dl_tls_setup@@GLIBC_PRIVATE 18: 0000e2d0 5 FUNC GLOBAL DEFAULT 10 _dl_debug_state@@GLIBC_PRIVATE 19: 00000000 0 OBJECT GLOBAL DEFAULT ABS GLIBC_2.3.2 20: 000105e0 280 FUNC GLOBAL DEFAULT 10 ___tls_get_addr@@GLIBC_2.3 21: 0001b000 1420 OBJECT GLOBAL DEFAULT 18 _rtld_global@@GLIBC_PRIVATE 22: 0000fd50 12 FUNC GLOBAL DEFAULT 10 __tls_get_addr@@GLIBC_2.3 23: 00010c90 182 FUNC GLOBAL DEFAULT 10 _dl_make_stack_executable@@GLIBC_PRIVATE 24: 00014230 43 FUNC WEAK DEFAULT 10 malloc@@GLIBC_2.0 25: 00010020 567 FUNC GLOBAL DEFAULT 10 _dl_allocate_tls_init@@GLIBC_PRIVATE 26: 0001aca0 448 OBJECT GLOBAL DEFAULT 15 _rtld_global_ro@@GLIBC_PRIVATE 27: 0001aec8 4 OBJECT WEAK DEFAULT 15 __guard@@GLIBC_2.3.2 28: 0001aef0 4 OBJECT GLOBAL DEFAULT 15 __libc_enable_secure@@GLIBC_PRIVATE 29: 00000000 0 OBJECT GLOBAL DEFAULT ABS GLIBC_2.0 30: 00007e20 394 FUNC GLOBAL DEFAULT 10 _dl_rtld_di_serinfo@@GLIBC_PRIVATE ########## END LINUX BOX 2 gentoo glibc-2.6.1 ############## The output of the two readelf commands differs, and the linkers are both ld-linux.so.2 and not ld-linux.so.1 In particular the symbol #11 _dl_tls_get_addr_soft exists in ld-linux.so.2 from linux box 2 but not in ld-linux.so.1 from linux box 1 Angelo > > Andrew. >