This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See crosstool-NG for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Using x86_64-unknown-elf to generate 32bit binaries


I've used crosstool-ng to create i386-unknown-elf and
x86_64-unkown-elf tool chains and using them with my baremetal-ng
project.

Things are working pretty well I can use i386-unkown-elf-gcc to create
32 binaries and x86_64-unknown-elf for 64 bit. But if I try to use the
-m64 with i386-unknown-elf I get the that the 64-bit mode is not
compiled in:

$ BITNESS=64 make
i386-unknown-elf-gcc -m64 -std=c11 -ffreestanding -O2 -g -static -Wall
-Wextra -nostdlib -nostartfiles -nodefaultlibs -c boot.S -o boot.o
boot.S:1:0: sorry, unimplemented: 64-bit mode not compiled in
 /*
 ^
Makefile:31: recipe for target 'boot.o' failed
make: *** [boot.o] Error 1

That seemed odd, but acceptable, some what more surprising is that
when I use the x86_64-unknown-elf compiler I can compile with -m32 or
-m64 but when I try to link with -m32 I get an error that the i386
architecture is incompatible with i386:x86_64:

$ CC_FLAVOR=x86_64 LK_FLAVOR=x86_64 bitness=32 make
x86_64-unknown-elf-gcc -m32 -std=c11 -ffreestanding -O2 -g -static
-Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs -c boot.S -o
boot.o
x86_64-unknown-elf-gcc -m32 -std=c11 -ffreestanding -O2 -g -static
-Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs -c kmain.c -o
kmain.o
x86_64-unknown-elf-gcc -m32 -std=c11 -ffreestanding -O2 -g -static
-Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs -Wl,-T,link.ld -o
kmain.elf boot.o kmain.o -lgcc
/home/wink/x-tools/x86_64-unknown-elf/lib/gcc/x86_64-unknown-elf/5.2.0/../../../../x86_64-unknown-elf/bin/ld:
i386 architecture of input file `boot.o' is incompatible with
i386:x86-64 output
/home/wink/x-tools/x86_64-unknown-elf/lib/gcc/x86_64-unknown-elf/5.2.0/../../../../x86_64-unknown-elf/bin/ld:
i386 architecture of input file `kmain.o' is incompatible with
i386:x86-64 output
collect2: error: ld returned 1 exit status
Makefile:28: recipe for target 'kmain.elf' failed
make: *** [kmain.elf] Error 1


Ideally I'd like to be able to use the x86_64-unknown-elf for either
32 or 64 bit and not have to create two tool chains, is that possible
using crosstool-ng?

Attached are my two config files and I'm using github master as of today.

My host system is an x86_64 arch-linux, uname -a:

$ uname -a
Linux wink-envy 4.2.5-1-ARCH #1 SMP PREEMPT Tue Oct 27 08:13:28 CET
2015 x86_64 GNU/Linux

-- wink

Attachment: config.i386-unknown-elf
Description: Binary data

Attachment: config.x86_64-unknown-elf
Description: Binary data

--
For unsubscribe information see http://sourceware.org/lists.html#faq

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]