Skip to contentSkip to conversation

Some Cross Compiling Questions

DISCUSSION Grant Carter 3 participants 3 messages Jul 14, 1999 – Jul 15, 1999

lore
Share & tools
lore
#0 lore raw

Hi all

I am very new at using the GNU tools and cross compilers etc and am wanting to compile Linux for the RPXLite Board running a PowerPC 823. I have gone throught the CrossGCC FAQ as well as a document on Cross Development for Linux/PPC but I still have a few questions/problems which I hope someone can help me with please.

I am running an i386-FreeBSD system and, as I said before, am wanting to build a PowerPC-linux system. I have built binutils-2.9.1.0.25 and egcs-1.1.2 successfully and have used that to build the LinuxPPC kernel (2.2.5). Everything compiled fine but I want to know 2 things: I have read about libgcc.o and was wondering if I had to provide my own one or if gcc knew enough about the 823 to build its own. Secondly, how do I get floating point emulation running as the 823 doesn't provide hardware floating point. I saw a --nfp in the configuration options - should I enable this?

Next I tried to compile both glibc which failed. The error message was as follows:

../sysdeps/powerpc/s_isnan.c: In function `__isnan':
../sysdeps/powerpc/s_isnan.c:32: fixed or forbidden register 32 (0) was spilled for class FLOAT_REGS. This may be due to a compiler bug or to impossible asm statements or clauses.

Is this related to my needing the correct libgcc.o file so that the assembler knows how to implement these functions or what?

I also tried newlib 1.8.1 and newlib 1.7.1. They were complaining about crt1.0 and crt1.s respectively. I believe that I need one of these files built for my target platform. Can someone provide me with one or do I have to write my own? If so, can someone please point me in the direction of some documentation about the contents of these files?

Thanks in advance
Grant

Signature · 9 lines
Grant Carter                              [email protected]
Department of Electrical Engineering      University of Cape Town
Tel: +27 (0)21 650-3467                   Fax: +27 (0)21 650-3465
                     "Coffee not found - operator halted!"

[[ This message was sent via the linuxppc-dev mailing list.  Replies are ]]
[[ not  forced  back  to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting.   ]]
#1 lore raw
Quoted 9 lines · Grant Carter

Hi all

I am very new at using the GNU tools and cross compilers etc and am wanting to compile Linux for the RPXLite Board running a PowerPC 823. I have gone throught the CrossGCC FAQ as well as a document on Cross Development for Linux/PPC but I still have a few questions/problems which I hope someone can help me with please.

Quoted 9 lines

I am running an i386-FreeBSD system and, as I said before, am wanting to build a PowerPC-linux system. I have built binutils-2.9.1.0.25 and egcs-1.1.2 successfully and have used that to build the LinuxPPC kernel (2.2.5). Everything compiled fine but I want to know 2 things: I have read about libgcc.o and was wondering if I had to provide my own one or if gcc knew enough about the 823 to build its own. Secondly, how do I get floating point emulation running as the 823 doesn't provide hardware floating point. I saw a --nfp in the configuration options - should I enable this?

You want -msoft-float. Most likely when you build egcs it will build a bunch of files in subdirectories named nof. These are used when you specify -msoft-float on the command line.

Quoted 10 lines

Next I tried to compile both glibc which failed. The error message was as follows:

../sysdeps/powerpc/s_isnan.c: In function `__isnan':
../sysdeps/powerpc/s_isnan.c:32: fixed or forbidden register 32 (0) was spilled for class FLOAT_REGS. This may be due to a compiler bug or to impossible asm statements or clauses.

Is this related to my needing the correct libgcc.o file so that the assembler knows how to implement these functions or what?

Bad version of gcc. Try the latest 2.95 snapshots.

Quoted 5 lines

I also tried newlib 1.8.1 and newlib 1.7.1. They were complaining about crt1.0 and crt1.s respectively. I believe that I need one of these files built for my target platform. Can someone provide me with one or do I have to write my own? If so, can someone please point me in the direction of some documentation about the contents of these files?

crt*.o come partly with glibc and partly with egcs; crt1.o is from glibc. I would expect newlib to have it.

Dan

/--------------------------------\ /--------------------------------\

|       Daniel Jacobowitz        |__|        SCS Class of 2002       |
|   Debian GNU/Linux Developer    __    Carnegie Mellon University   |
|         [email protected]         |  |       [email protected]      |
\--------------------------------/  \--------------------------------/

[[ This message was sent via the linuxppc-dev mailing list. Replies are ]] [[ not forced back to the list, so be sure to Cc linuxppc-dev if your ]] [[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting. ]]

#2 lore raw
In reply to Grant Carter
Quoted 9 lines · Grant Carter

Hi all

I am very new at using the GNU tools and cross compilers etc and am wanting to compile Linux for the RPXLite Board running a PowerPC 823. I have gone throught the CrossGCC FAQ as well as a document on Cross Development for Linux/PPC but I still have a few questions/problems which I hope someone can help me with please.

Quoted 6 lines

I am running an i386-FreeBSD system and, as I said before, am wanting to build a PowerPC-linux system. I have built binutils-2.9.1.0.25 and egcs-1.1.2 successfully and have used that to build the LinuxPPC kernel (2.2.5). Everything compiled fine but I want to know 2 things: I have read about libgcc.o and was wondering if I had to provide my own one or if gcc knew enough about the 823 to build its own.

To build libgcc gcc must find some of the C-library include files. But you can't build the C-library until you have a compiler... I don't rember exectly how I solved this as it was a long time since I did a rebuild from scratch, but basicly you have to do a "multipass" installation, first compile and install gcc without libgcc, then get the necessary include files out of glibc and install them, and finally build the rest of gcc with libgcc and such.

Quoted 4 lines

Secondly, how do I
get floating point emulation running as the 823 doesn't provide hardware floating point. I saw a --nfp in the configuration options - should I enable this?

Using --nfp and --with-cpu=823 when compiling egcs will make it generate soft float code by default, but it will _NOT_ make _SOFT_FLOAT be defined in the preprocessor by default, unless you hack the specs file. This caused me great confusion as the va_* variable argument macros check for the _SOFT_FLOAT define to know whether floating point arguments are in fp registers or in memory. As the compiler doesn't use this define things will get really messed up when you pass float arguments to things like printf().

The simple solution is to _not_ use --nfp and pass -msoft-float to gcc when compiling PPC code instead.

Quoted 7 lines

Next I tried to compile both glibc which failed. The error message was as follows:

../sysdeps/powerpc/s_isnan.c: In function `__isnan':
../sysdeps/powerpc/s_isnan.c:32: fixed or forbidden register 32 (0) was spilled for class FLOAT_REGS. This may be due to a compiler bug or to impossible asm statements or clauses.

I believe it is a compiler bug, but this file should not be used anyway if you want to have a soft float glibc.

Note that there are two kinds of people here:
Those that (like me) want to use MPC8xx processors as purely embedded processors, compiling all libraries and apps themselves with -msoft-float, and only doing cross-development.
And then those that want full floating point emulation in the kernel in order to use normal PPC binaries and libraries, and who wants to do native development on 8xx boards.

I don't consider any method "right", it's simply matter of taste and of the particulart application you want to use your 8xx board for. Therefore I believe that both the kernel (I already know one person working on full fp emulation) and glibc should allow both ways by the means of a simple config option.

As for glibc and embedded powerpc the very least you have to do is to move sysdeps/powerpc/memset.S out of the way and apply this diff:

sysdeps/powerpc/dl-machine.c renamed from glibc-2.1.1/sysdeps/powerpc/dl-machine.c +4 -0
diff -ur orig/glibc-2.1.1/sysdeps/powerpc/dl-machine.c glibc-2.1.1/sysdeps/powerpc/dl-machine.c
@@ -250,7 +250,11 @@
 	 PowerPC processors have line sizes of exactly 32 bytes.  */
 
       size_modified = lazy ? rel_offset_words : PLT_INITIAL_ENTRY_WORDS;
+#ifdef PPC_CACHELINESIZE_32
       for (i = 0; i < size_modified; i+= 8)
+#else
+      for (i = 0; i < size_modified; i+= 4)
+#endif
 	PPC_DCBST (plt + i);
       PPC_DCBST (plt + size_modified - 1);
       PPC_SYNC;

This will fix the infamous cache line size problem.
If you want a soft float library (incompatible with normal PPC binaries) you need to pipe this diff though the attached script:

sysdeps/powerpc/Dist renamed from glibc-2.1.1/sysdeps/powerpc/Dist +0 -4
diff -ur orig/glibc-2.1.1/sysdeps/powerpc/Dist glibc-2.1.1/sysdeps/powerpc/Dist
@@ -1,7 +1,3 @@
 dl-machine.c
 dl-start.S
-fenv_const.c
-fenv_libc.h
 ppc-mcount.S
-fe_nomask.c
-t_sqrt.c
sysdeps/powerpc/Makefile renamed from glibc-2.1.1/sysdeps/powerpc/Makefile +0 -4
diff -ur orig/glibc-2.1.1/sysdeps/powerpc/Makefile glibc-2.1.1/sysdeps/powerpc/Makefile
@@ -1,7 +1,3 @@
-ifeq ($(subdir),math)
-libm-support += fenv_const fe_nomask t_sqrt
-endif
-
 ifeq ($(subdir),gmon)
 sysdep_routines += ppc-mcount
 endif

//Marcus

Signature · 4 lines
-------------------------------+------------------------------------
        Marcus Sundberg        | http://www.stacken.kth.se/~mackan/
 Royal Institute of Technology |       Phone: +46 707 295404
       Stockholm, Sweden       |   E-Mail: [email protected]

#!/bin/sh

FPUFILES="
Versions
bits/fenv.h
bits/mathdef.h
bits/mathinline.h
e_sqrt.c
e_sqrtf.c
fclrexcpt.c
fe_nomask.c
fegetenv.c
fegetround.c
feholdexcpt.c
fenv_const.c
fenv_libc.h
fesetenv.c
fesetround.c
feupdateenv.c
fgetexcptflg.c
fpu_control.h
fraiseexcpt.c
fsetexcptflg.c
ftestexcept.c
s_copysign.S
s_copysignf.S
s_fabs.S
s_fabsf.S
s_fmax.S
s_fmaxf.S
s_fmin.S
s_fminf.S
s_isnan.c
s_isnanf.S
s_lrint.c
s_lrintf.S
s_rint.c
s_rintf.c
t_sqrt.c
w_sqrt.c
w_sqrtf.c
"

FPUDISTFILES="fenv_const.c
fenv_libc.h
fe_nomask.c
t_sqrt.c
"

MAKEFILE='-ifeq ($(subdir),math)
-libm-support += fenv_const fe_nomask t_sqrt
-endif'

patch -p1

cd sysdeps/powerpc #|| exit 1
mkdir -p fpu/bits || exit 2

for a in $FPUFILES; do
mv "$a" "fpu/$a" && echo "Moved $a -> fpu/$a"
done

fail=
for a in $FPUDISTFILES; do
echo "$a" >> fpu/Dist || fail=1
done
test "$fail" || echo "Created fpu/Dist"

echo "$MAKEFILE" >fpu/Makefile && echo "Created fpu/Makefile"