Subject: compiling glibc

From: Benjamin Menküc <[email-masked]>
Date: Fri, 9 May 2003 21:45:43 +0200

Hi,

I cross-compiled binutils 2.13 and gcc-3.2.3 successfully for mips.

[benmen@linuxpc1 mipsel-glibc] LD_LIBRARY_PATH="" CFLAGS="-O2 -g 
-finline-limit=10000" ../glibc-2.3.2/configure --build=i686-linux 
--host=mipsel-linux --enable-add-ons --prefix=/home/benmen/mipsel

...

When I try to compile glibc I get this error:

[benmen@linuxpc1 mipsel-glibc] make
make -r PARALLELMFLAGS="" CVSOPTS="" -C ../glibc-2.3.2 objdir=`pwd` all
...
make[2]: Leaving directory `/home/benmen/mips/glibc-2.3.2/csu'
make[2]: Entering directory `/home/benmen/mips/glibc-2.3.2/csu'
gcc ../sysdeps/unix/sysv/linux/init-first.c -c -std=gnu99 -O2 -Wall -Winline 
-Wstrict-prototypes -Wwrite-strings -finline-limit=10000 -g      -I../include 
-I. -I/home/benmen/mips/mipsel-glibc/csu -I.. -I../libio  
-I/home/benmen/mips/mipsel-glibc -I../sysdeps/mips/elf 
-I../linuxthreads/sysdeps/unix/sysv/linux/mips 
-I../linuxthreads/sysdeps/unix/sysv/linux -I../linuxthreads/sysdeps/pthread 
-I../sysdeps/pthread -I../linuxthreads/sysdeps/unix/sysv 
-I../linuxthreads/sysdeps/unix -I../linuxthreads/sysdeps/mips 
-I../sysdeps/unix/sysv/linux/mips -I../sysdeps/unix/sysv/linux 
-I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman 
-I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix/mips 
-I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/mips/mipsel 
-I../sysdeps/mips/fpu -I../sysdeps/mips -I../sysdeps/wordsize-32 
-I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754 
-I../sysdeps/generic/elf -I../sysdeps/generic   -D_LIBC_REENTRANT -include 
../include/libc-symbols.h       -DHAVE_INITFINI -o 
/home/benmen/mips/mipsel-glibc/csu/init-first.o
In file included from ../linuxthreads/descr.h:42,
                 from ../linuxthreads/internals.h:29,
                 from ../linuxthreads/sysdeps/pthread/bits/libc-lock.h:27,
                 from ../sysdeps/generic/ldsodefs.h:38,
                 from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
                 from ../sysdeps/mips/elf/ldsodefs.h:25,
                 from ../sysdeps/unix/sysv/linux/init-first.c:30:
../linuxthreads/sysdeps/mips/pt-machine.h:48: invalid register name for 
`stack_pointer'
In file included from ../sysdeps/unix/sysv/linux/mips/sys/procfs.h:29,
                 from ../linuxthreads_db/proc_service.h:20,
                 from ../linuxthreads_db/thread_dbP.h:7,
                 from ../linuxthreads/descr.h:43,
                 from ../linuxthreads/internals.h:29,
                 from ../linuxthreads/sysdeps/pthread/bits/libc-lock.h:27,
                 from ../sysdeps/generic/ldsodefs.h:38,
                 from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
                 from ../sysdeps/mips/elf/ldsodefs.h:25,
                 from ../sysdeps/unix/sysv/linux/init-first.c:30:
../sysdeps/unix/sysv/linux/mips/sys/user.h:26:21: asm/reg.h: Datei oder 
Verzeichnis nicht gefunden
In file included from ../sysdeps/unix/sysv/linux/mips/sys/procfs.h:29,
                 from ../linuxthreads_db/proc_service.h:20,
                 from ../linuxthreads_db/thread_dbP.h:7,
                 from ../linuxthreads/descr.h:43,
                 from ../linuxthreads/internals.h:29,
                 from ../linuxthreads/sysdeps/pthread/bits/libc-lock.h:27,
                 from ../sysdeps/generic/ldsodefs.h:38,
                 from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
                 from ../sysdeps/mips/elf/ldsodefs.h:25,
                 from ../sysdeps/unix/sysv/linux/init-first.c:30:
../sysdeps/unix/sysv/linux/mips/sys/user.h:30: `EF_SIZE' undeclared here (not 
in a function)
../sysdeps/unix/sysv/linux/mips/sys/user.h:41: confused by earlier errors, 
bailing out
make[2]: *** [/home/benmen/mips/mipsel-glibc/csu/init-first.o] Fehler 1
make[2]: Leaving directory `/home/benmen/mips/glibc-2.3.2/csu'
make[1]: *** [csu/subdir_lib] Fehler 2
make[1]: Leaving directory `/home/benmen/mips/glibc-2.3.2'
make: *** [all] Fehler 2
Verzeichnis: ~/mips/mipsel-glibc
[benmen@linuxpc1 mipsel-glibc]

The headers including asm/reg.h are located in /home/benmen/mipsel/include ...
the mipsel-linux-gcc + binutils stuff is in /home/benmen/mipsel/bin ...

Thanks for Your help.

regards,

Ben

---

From: Thiemo Seufer <[email-masked]>
Date: Fri, 9 May 2003 23:45:01 +0200

> --host=mipsel-linux --enable-add-ons --prefix=/home/benmen/mipsel

It also needs the headers of the already correctly configured
kernel, added by --with-headers=/path/to/linux/headers.

Thiemo

---

From: Benjamin Menküc <[email-masked]>
Date: Sat, 10 May 2003 03:03:48 +0200

When I add the include stuff I still get this error:

[benmen@linuxpc1 mipsel-glibc] LD_LIBRARY_PATH="" CFLAGS="-O2 -g 
-finline-limit=10000" ../glibc-2.3.2/configure --build=i686-linux 
--host=mipsel-linux --enable-add-ons --prefix=/home/benmen/mipsel 
--with-headers=/home/benmen/mips/kernel/mips-2.4.20/include

....

...

-I../sysdeps/generic/elf -I../sysdeps/generic  -nostdinc -isystem 
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.2/include -isystem 
/home/benmen/mips/kernel/mips-2.4.20/include -D_LIBC_REENTRANT -include 

regards,

Ben

---

From: Daniel Jacobowitz <[email-masked]>
Date: Sat, 10 May 2003 00:25:35 -0400

> --with-headers=/home/benmen/mips/kernel/mips-2.4.20/include

You didn't set CC and AS.  It's using the native compiler, not the
cross.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

---

From: Benjamin Menküc <[email-masked]>
Date: Sat, 10 May 2003 11:56:08 +0200

Okay, it works now when I set CC=mipsel-linux-gcc and AS=mipsel-linux-as

[benmen@linuxpc1 mipsel-glibc] LD_LIBRARY_PATH="" CFLAGS="-O2 -g 
-finline-limit=10000" CC="mipsel-linux-gcc" AS="mipsel-linux-as" 
../glibc-2.3.2/configure --build=i686-linux --host=mipsel-linux 
--enable-add-ons --prefix=/home/benmen/mipsel 
--with-headers=/home/benmen/mips/kernel/mips-2.4.20/include

until this comes:

make[2]: Entering directory `/home/benmen/mips/glibc-2.3.2/misc'
make[2]: *** Keine Regel vorhanden, um das Target 
»/home/benmen/mips/mipsel-glibc/misc/cachectl.o«,
  benötigt von »/home/benmen/mips/mipsel-glibc/misc/stamp.o«, zu erstellen.  
Schluss.
make[2]: Leaving directory `/home/benmen/mips/glibc-2.3.2/misc'
make[1]: *** [misc/subdir_lib] Fehler 2
make[1]: Leaving directory `/home/benmen/mips/glibc-2.3.2'
make: *** [all] Fehler 2
Verzeichnis: ~/mips/mipsel-glibc
[benmen@linuxpc1 mipsel-glibc]

PS: shouldn't the Makefile take care of the CC and AS variables?

regards,

Ben

---

From: Benjamin Menküc <[email-masked]>
Date: Sat, 10 May 2003 13:21:21 +0200

Okay, I fixed this problem by adding --disable-profile:

--with-headers=/home/benmen/mips/kernel/mips-2.4.20/include --disable-profile

...

Now I can compile until this comes:

[benmen@linuxpc1 mipsel-glibc] BUILD_CC=gcc CC=mipsel-linux-gcc ma

...

make[3]: Leaving directory `/home/benmen/mips/glibc-2.3.2/elf'
mipsel-linux-gcc   -nostdlib -nostartfiles -r -o 
/home/benmen/mips/mipsel-glibc/elf/librtld.os '-Wl,-(' 
/home/benmen/mips/mipsel-glibc/elf/dl-allobjs.os 
/home/benmen/mips/mipsel-glibc/elf/rtld-libc.a -lgcc '-Wl,-)'
mipsel-linux-gcc   -nostdlib -nostartfiles -shared                      \
   -Wl,-z,defs -Wl,--verbose 2>&1 |     \
          sed -e '/^=========/,/^=========/!d;/^=========/d'    \
              -e 's/\. = 0 + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' 
\
          > /home/benmen/mips/mipsel-glibc/elf/ld.so.lds
mipsel-linux-gcc   -nostdlib -nostartfiles -shared -o 
/home/benmen/mips/mipsel-glibc/elf/ld.so                  \
           -Wl,-z,defs                          \
          /home/benmen/mips/mipsel-glibc/elf/librtld.os 
-Wl,--version-script=/home/benmen/mips/mipsel-glibc/ld.map    \
          -Wl,-soname=ld.so.1 -T /home/benmen/mips/mipsel-glibc/elf/ld.so.lds
/home/benmen/mips/mipsel-glibc/elf/librtld.os: In function 
`_dl_resolve_conflicts':
/home/benmen/mips/glibc-2.3.2/elf/dl-conflict.c:65: undefined reference to 
`elf_machine_rela.7'
collect2: ld returned 1 exit status
make[2]: *** [/home/benmen/mips/mipsel-glibc/elf/ld.so] Fehler 1
make[2]: Leaving directory `/home/benmen/mips/glibc-2.3.2/elf'
make[1]: *** [elf/subdir_lib] Fehler 2
make[1]: Leaving directory `/home/benmen/mips/glibc-2.3.2'
make: *** [all] Fehler 2
Verzeichnis: ~/mips/mipsel-glibc
[benmen@linuxpc1 mipsel-glibc]

regards,

Ben

---

From: Daniel Jacobowitz <[email-masked]>
Date: Sat, 10 May 2003 15:43:51 -0400

> Now I can compile until this comes:

Try glibc from CVS instead of 2.3.2.  Known bug.

---

From: Benjamin Menküc <[email-masked]>
Date: Sun, 11 May 2003 02:35:14 +0200

Hi,

now I get this weird error:

...

make[2]: Entering directory `/home/benmen/mips/glibc-cvs/misc'
rm -f /home/benmen/mips/mipsel-glibc/misc/syscall-list.d-t
{ \
 echo '/* Generated at libc build time from kernel syscall list.  */';\
 echo ''; \
 echo '#ifndef _SYSCALL_H'; \
 echo '# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> 
instead."'; \
 echo '#endif'; \
 echo ''; \
 rm -f /home/benmen/mips/mipsel-glibc/misc/syscall-list.h.newt; \
 SUNPRO_DEPENDENCIES='/home/benmen/mips/mipsel-glibc/misc/syscall-list.d-t 
/home/benmen/mips/mipsel-glibc/misc/syscall-list.d' \
 mipsel-linux-gcc -mabi=32 -E -x c -I /home/benmen/mips/mipsel-glibc -nostdinc 
-isystem /home/benmen/mipsel/lib/gcc-lib/mipsel-linux/3.2.3/include -isystem 
/home/benmen/mips/kernel/mips-2.4.20/include 
../sysdeps/unix/sysv/linux/mips/sys/syscall.h -D_LIBC -dM | \
 sed -n 's@^#define __NR_\([^ ]*\) .*$@#define SYS_\1 __NR_\1@p' > 
/home/benmen/mips/mipsel-glibc/misc/syscall-list.h.newt; \
 if grep SYS_O32_ /home/benmen/mips/mipsel-glibc/misc/syscall-list.h.newt > 
/dev/null; then \
   echo '#if defined _ABI64 && _MIPS_SIM == _ABI64'; \
   sed -n 's/^\(#define SYS_\)N64_/\1/p' < 
/home/benmen/mips/mipsel-glibc/misc/syscall-list.h.newt; \
   echo '#elif defined _ABIN32 && _MIPS_SIM == _ABIN32'; \
   sed -n 's/^\(#define SYS_\)N32_/\1/p' < 
/home/benmen/mips/mipsel-glibc/misc/syscall-list.h.newt; \
   echo '#else'; \
   sed -n 's/^\(#define SYS_\)O32_/\1/p' < 
/home/benmen/mips/mipsel-glibc/misc/syscall-list.h.newt; \
   echo '#endif'; \
   sed -n '/^#define SYS_\([ON]32\|N64\)_/p' < 
/home/benmen/mips/mipsel-glibc/misc/syscall-list.h.newt; \
 else \
   cat /home/benmen/mips/mipsel-glibc/misc/syscall-list.h.newt; \
 fi; \
 rm /home/benmen/mips/mipsel-glibc/misc/syscall-list.h.newt; \
} > /home/benmen/mips/mipsel-glibc/misc/syscall-list.h.new
/bin/sh: line 1: /home/benmen/mips/mipsel-glibc/misc/syscall-list.h.new: Datei 
oder Verzeichnis nicht gefunden
mv -f /home/benmen/mips/mipsel-glibc/misc/syscall-list.h.new 
/home/benmen/mips/mipsel-glibc/misc/syscall-list.h
mv: Aufruf von stat für 
»/home/benmen/mips/mipsel-glibc/misc/syscall-list.h.new« nicht möglich: Datei 
oder Verzeichnis nicht gefunden
make[2]: *** [/home/benmen/mips/mipsel-glibc/misc/syscall-list.d] Fehler 1
make[2]: Leaving directory `/home/benmen/mips/glibc-cvs/misc'
make[1]: *** [misc/subdir_lib] Fehler 2
make[1]: Leaving directory `/home/benmen/mips/glibc-cvs'
make: *** [all] Fehler 2
Verzeichnis: ~/mips/mipsel-glibc
[benmen@linuxpc1 mipsel-glibc]

regards,

Ben

---

From: Guido Guenther <[email-masked]>
Date: Sun, 11 May 2003 11:28:29 +0200

On Sun, May 11, 2003 at 02:35:14AM +0200, Benjamin Menküc wrote:
[..snip..] 
> /home/benmen/mips/mipsel-glibc/misc/syscall-list.h
[..snip..] 

Index: sysdeps/unix/sysv/linux/mips/Makefile
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/mips/Makefile,v
retrieving revision 1.8
diff -u -p -u -r1.8 Makefile
--- sysdeps/unix/sysv/linux/mips/Makefile	17 Mar 2003 15:50:05 -0000	1.8
+++ sysdeps/unix/sysv/linux/mips/Makefile	5 May 2003 08:53:35 -0000
@@ -15,6 +15,7 @@ no_syscall_list_h = 1
 # We generate not only SYS_<syscall>, pointing at SYS_<abi>_<syscall> if
 # it exists, but also define SYS_<abi>_<syscall> for all ABIs.
 $(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/mips/sys/syscall.h
+	mkdir -p $(objpfx)
 	rm -f $(@:.h=.d)-t
 	{ \
 	 echo '/* Generated at libc build time from kernel syscall list.  */';\

Hope that helps,
 -- Guido

---

From: Benjamin Menküc <[email-masked]>
Date: Sun, 11 May 2003 12:52:52 +0200

Now it went a little further until here:

make[2]: Leaving directory `/home/benmen/mips/glibc-cvs/misc'
make[2]: Entering directory `/home/benmen/mips/glibc-cvs/misc'
mipsel-linux-gcc -mabi=32 ../sysdeps/unix/sysv/linux/mips/brk.c -c -std=gnu99 
-O2 -Wall -Winline -Wstrict-prototypes -Wwrite-strings -finline-limit=10000 
-g      -I../include -I. -I/home/benmen/mips/mipsel-glibc/misc -I.. 
-I../libio  -I/home/benmen/mips/mipsel-glibc -I../sysdeps/mips/elf 
-I../linuxthreads/sysdeps/unix/sysv/linux/mips 
-I../linuxthreads/sysdeps/unix/sysv/linux -I../linuxthreads/sysdeps/pthread 
-I../sysdeps/pthread -I../linuxthreads/sysdeps/unix/sysv 
-I../linuxthreads/sysdeps/unix -I../linuxthreads/sysdeps/mips 
-I../sysdeps/unix/sysv/linux/mips/mips32 -I../sysdeps/unix/sysv/linux/mips 
-I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common 
-I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../sysdeps/unix/sysv 
-I../sysdeps/unix/mips/mips32 -I../sysdeps/unix/mips -I../sysdeps/unix 
-I../sysdeps/posix -I../sysdeps/mips/mips32 -I../sysdeps/mips 
-I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754/dbl-64 
-I../sysdeps/wordsize-32 -I../sysdeps/mips/fpu -I../sysdeps/ieee754 
-I../sysdeps/generic/elf -I../sysdeps/generic -nostdinc -isystem 
/home/benmen/mipsel/lib/gcc-lib/mipsel-linux/3.2.3/include -isystem 
/home/benmen/mips/kernel/mips-2.4.20/include -D_LIBC_REENTRANT -include 
../include/libc-symbols.h  -DPIC     -o 
/home/benmen/mips/mipsel-glibc/misc/brk.o -MD -MP -MF 
/home/benmen/mips/mipsel-glibc/misc/brk.o.dt
as: Unbekannte Option »-O2«
make[2]: *** [/home/benmen/mips/mipsel-glibc/misc/brk.o] Fehler 1
make[2]: Leaving directory `/home/benmen/mips/glibc-cvs/misc'
make[1]: *** [misc/subdir_lib] Fehler 2
make[1]: Leaving directory `/home/benmen/mips/glibc-cvs'
make: *** [all] Fehler 2
Verzeichnis: ~/mips/mipsel-glibc
[benmen@linuxpc1 mipsel-glibc]

I am going the try now if it works when I remove the CFLAGS="-O2 ..." from my 
configure line.... however it should be possible to compile it with O2 
shouldn't it?

regards,

Ben

---

From: Benjamin Menküc <[email-masked]>
Date: Sun, 11 May 2003 13:00:50 +0200

I have to put some optimization flag into CFLAG="" because otherwise I get the 
error: glibc can't be compiled without optimization...

what should I do?

regards,

Ben

---

From: Guido Guenther <[email-masked]>
Date: Sun, 11 May 2003 23:48:01 +0200

> error: glibc can't be compiled without optimization...
Does it work when you don't set CFLAGS at all? Please use LC_ALL=C for
the error messages.
 -- Guido