Building NewLib
Posted: Wed Jun 15, 2011 11:44 am
I am trying to create a port of NewLib for BareMetal OS so applications will be able to use standard C calls (like printf()). I have followed the Porting Newlib doc (http://wiki.osdev.org/Porting_Newlib) but ran into a few issues.
First of all it looks like Newlib 1.15.0 does not support x86-64 so I am using the latest (1.19.0). I am doing the compile in an Ubuntu 64-bit 11.04 VM and have the extracted Newlib and a "build" folder along side it.
I run this to generate the makefile:
../newlib-1.19.0/configure --target=x86_64-pc-none
I then had to adjust the makefile to tell it that the target programs are the same as the host programs (as I am on the same architecture, I don't need a cross-compiler setup?)
Running make looks good other than it is compiling with the "-m32" argument instead of "-m64". Eventually the build will fail with "Error: bad register name" because it does not recognize the 64-bit register names (probably because it looks to be compiling a 32-bit binary).
How can I force it to compile to 64-bit binaries?
Thanks in advance,
-Ian
Output when it fails:
First of all it looks like Newlib 1.15.0 does not support x86-64 so I am using the latest (1.19.0). I am doing the compile in an Ubuntu 64-bit 11.04 VM and have the extracted Newlib and a "build" folder along side it.
I run this to generate the makefile:
../newlib-1.19.0/configure --target=x86_64-pc-none
I then had to adjust the makefile to tell it that the target programs are the same as the host programs (as I am on the same architecture, I don't need a cross-compiler setup?)
Running make looks good other than it is compiling with the "-m32" argument instead of "-m64". Eventually the build will fail with "Error: bad register name" because it does not recognize the 64-bit register names (probably because it looks to be compiling a 32-bit binary).
How can I force it to compile to 64-bit binaries?
Thanks in advance,
-Ian
Output when it fails:
Code: Select all
make[8]: Leaving directory `/home/ian/Downloads/newlib/build/x86_64-pc-none/32/newlib/libc/misc'
Making all in machine
make[8]: Entering directory `/home/ian/Downloads/newlib/build/x86_64-pc-none/32/newlib/libc/machine'
Making all in x86_64
make[9]: Entering directory `/home/ian/Downloads/newlib/build/x86_64-pc-none/32/newlib/libc/machine/x86_64'
cc -B/home/ian/Downloads/newlib/build/x86_64-pc-none/32/newlib/ -isystem /home/ian/Downloads/newlib/build/x86_64-pc-none/32/newlib/targ-include -isystem /home/ian/Downloads/newlib/newlib-1.19.0/newlib/libc/include -B/home/ian/Downloads/newlib/build/x86_64-pc-none/32/libgloss/x86_64 -L/home/ian/Downloads/newlib/build/x86_64-pc-none/32/libgloss/libnosys -L/home/ian/Downloads/newlib/newlib-1.19.0/libgloss/x86_64 -m32 -DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\" -DPACKAGE_VERSION=\"1.19.0\" -DPACKAGE_STRING=\"newlib\ 1.19.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -I. -I../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64 -DMISSING_SYSCALL_NAMES -fno-builtin -DMISSING_SYSCALL_NAMES -fno-builtin -g -O2 -m32 -c -o lib_a-setjmp.o `test -f 'setjmp.S' || echo '../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/'`setjmp.S
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S: Assembler messages:
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:25: Error: bad register name `%rbx'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:26: Error: bad register name `%rbp'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:27: Error: bad register name `%r12'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:28: Error: bad register name `%r13'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:29: Error: bad register name `%r14'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:30: Error: bad register name `%r15'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:31: Error: bad register name `%rsp)'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:32: Error: bad register name `%rax'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:33: Error: bad register name `%rsp)'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:34: Error: bad register name `%rax'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:35: Error: bad register name `%rax'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:39: Error: bad register name `%rsi'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:41: Error: bad register name `%rdi)'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:44: Error: bad register name `%rdi)'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:45: Error: bad register name `%rdi)'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:46: Error: bad register name `%rdi)'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:47: Error: bad register name `%rdi)'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:48: Error: bad register name `%rdi)'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:49: Error: bad register name `%rdi)'
../../../../../../../newlib-1.19.0/newlib/libc/machine/x86_64/setjmp.S:50: Error: bad register name `%rdi)'
make[9]: *** [lib_a-setjmp.o] Error 1
make[9]: Leaving directory `/home/ian/Downloads/newlib/build/x86_64-pc-none/32/newlib/libc/machine/x86_64'
make[8]: *** [all-recursive] Error 1
make[8]: Leaving directory `/home/ian/Downloads/newlib/build/x86_64-pc-none/32/newlib/libc/machine'
make[7]: *** [all-recursive] Error 1
make[7]: Leaving directory `/home/ian/Downloads/newlib/build/x86_64-pc-none/32/newlib/libc'
make[6]: *** [all-recursive] Error 1
make[6]: Leaving directory `/home/ian/Downloads/newlib/build/x86_64-pc-none/32/newlib'
make[5]: *** [all] Error 2
make[5]: Leaving directory `/home/ian/Downloads/newlib/build/x86_64-pc-none/32/newlib'
make[4]: *** [multi-do] Error 1
make[4]: Leaving directory `/home/ian/Downloads/newlib/build/x86_64-pc-none/newlib'
make[3]: *** [all-multi] Error 2
make[3]: Leaving directory `/home/ian/Downloads/newlib/build/x86_64-pc-none/newlib'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/ian/Downloads/newlib/build/x86_64-pc-none/newlib'
make[1]: *** [all-target-newlib] Error 2
make[1]: Leaving directory `/home/ian/Downloads/newlib/build'
make: *** [all] Error 2