Building for x86_64 on Mac OS X Yosemite appears to try to link i386 intermediates
Created by: rowedonalde
Prereq: Obtain x86_64 tools per the instructions at https://github.com/redox-os/redox/issues/165#issuecomment-152465299
Reproduction: cd to root of cloned repo, and then:
export ARCH=x86_64
make all
Expected behavior: Redox builds successfully in x86_64, and I can run it with make qemu
Actual behavior: make all
fails while compiling crates/init/main.rs
and complains that linking fails because the input files are i386
Build information: Output from make all
:
mkdir -p build/x86_64-unknown-redox/debug
RUST_BACKTRACE=1 rustc --target=x86_64-unknown-redox.json -L build/x86_64-unknown-redox/debug -C no-prepopulate-passes -C no-stack-check -C opt-level=2 -Z no-landing-pads -A dead_co
de -C ar=x86_64-elf-ar -C linker=x86_64-elf-gcc -o build/x86_64-unknown-redox/debug/libcore.rlib rust/src/libcore/lib.rs
RUST_BACKTRACE=1 rustc --target=x86_64-unknown-redox.json -L build/x86_64-unknown-redox/debug -C no-prepopulate-passes -C no-stack-check -C opt-level=2 -Z no-landing-pads -A dead_co
de -C ar=x86_64-elf-ar -C linker=x86_64-elf-gcc --crate-name bitflags --crate-type lib -o build/x86_64-unknown-redox/debug/libbitflags.rlib crates/bitflags/src/lib.rs
RUST_BACKTRACE=1 rustc --target=x86_64-unknown-redox.json -L build/x86_64-unknown-redox/debug -C no-prepopulate-passes -C no-stack-check -C opt-level=2 -Z no-landing-pads -A dead_co
de -C ar=x86_64-elf-ar -C linker=x86_64-elf-gcc -o build/x86_64-unknown-redox/debug/libio.rlib crates/io/lib.rs
RUST_BACKTRACE=1 rustc --target=x86_64-unknown-redox.json -L build/x86_64-unknown-redox/debug -C no-prepopulate-passes -C no-stack-check -C opt-level=2 -Z no-landing-pads -A dead_co
de -C ar=x86_64-elf-ar -C linker=x86_64-elf-gcc -o build/x86_64-unknown-redox/debug/liballoc_malloc.rlib liballoc_malloc/lib.rs -L native=libc/lib/
RUST_BACKTRACE=1 rustc --target=x86_64-unknown-redox.json -L build/x86_64-unknown-redox/debug -C no-prepopulate-passes -C no-stack-check -C opt-level=2 -Z no-landing-pads -A dead_co
de -C ar=x86_64-elf-ar -C linker=x86_64-elf-gcc -o build/x86_64-unknown-redox/debug/liballoc_system.rlib liballoc_system/lib.rs
RUST_BACKTRACE=1 rustc --target=x86_64-unknown-redox.json -L build/x86_64-unknown-redox/debug -C no-prepopulate-passes -C no-stack-check -C opt-level=2 -Z no-landing-pads -A dead_co
de -C ar=x86_64-elf-ar -C linker=x86_64-elf-gcc -o build/x86_64-unknown-redox/debug/liballoc.rlib rust/src/liballoc/lib.rs
RUST_BACKTRACE=1 rustc --target=x86_64-unknown-redox.json -L build/x86_64-unknown-redox/debug -C no-prepopulate-passes -C no-stack-check -C opt-level=2 -Z no-landing-pads -A dead_co
de -C ar=x86_64-elf-ar -C linker=x86_64-elf-gcc -o build/x86_64-unknown-redox/debug/librustc_unicode.rlib rust/src/librustc_unicode/lib.rs
RUST_BACKTRACE=1 rustc --target=x86_64-unknown-redox.json -L build/x86_64-unknown-redox/debug -C no-prepopulate-passes -C no-stack-check -C opt-level=2 -Z no-landing-pads -A dead_co
de -C ar=x86_64-elf-ar -C linker=x86_64-elf-gcc -o build/x86_64-unknown-redox/debug/libcollections.rlib rust/src/libcollections/lib.rs
RUST_BACKTRACE=1 rustc --target=x86_64-unknown-redox.json -L build/x86_64-unknown-redox/debug -C no-prepopulate-passes -C no-stack-check -C opt-level=2 -Z no-landing-pads -A dead_co
de -C ar=x86_64-elf-ar -C linker=x86_64-elf-gcc -o build/x86_64-unknown-redox/debug/librand.rlib rust/src/librand/lib.rs
RUST_BACKTRACE=1 rustc --target=x86_64-unknown-redox.json -L build/x86_64-unknown-redox/debug -C no-prepopulate-passes -C no-stack-check -C opt-level=2 -Z no-landing-pads -A dead_co
de -C ar=x86_64-elf-ar -C linker=x86_64-elf-gcc -o build/x86_64-unknown-redox/debug/libsystem.rlib crates/system/lib.rs
RUST_BACKTRACE=1 rustc --target=x86_64-unknown-redox.json -L build/x86_64-unknown-redox/debug -C no-prepopulate-passes -C no-stack-check -C opt-level=2 -Z no-landing-pads -A dead_co
de -C ar=x86_64-elf-ar -C linker=x86_64-elf-gcc -o build/x86_64-unknown-redox/debug/libstd.rlib libstd/src/lib.rs -L native=libc/lib/
mkdir -p initfs/bin/
RUST_BACKTRACE=1 rustc --target=x86_64-unknown-redox.json -L build/x86_64-unknown-redox/debug -C no-prepopulate-passes -C no-stack-check -C opt-level=2 -Z no-landing-pads -A dead_co
de -C ar=x86_64-elf-ar -C linker=x86_64-elf-gcc -C lto --crate-type bin -o initfs/bin/init crates/init/main.rs
error: linking with `x86_64-elf-gcc` failed: exit code: 1
note: "x86_64-elf-gcc" "-m64" "-nostdlib" "-static" "-L" "/Users/don/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-redox.json/lib" "initfs/bin/init.0.o" "-o" "initfs/bin/
init" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "build/x86_64-unknown-redox/debug" "-L" "/Users/don/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-redox.json/lib" "-Wl,-Bs
tatic" "-Wl,-Bdynamic" "/var/folders/x6/r9vc_y8n0hqc_txxy1wz7r9w0000gn/T/rustc.lruKETKEvdFz/libstd.rlib" "/var/folders/x6/r9vc_y8n0hqc_txxy1wz7r9w0000gn/T/rustc.lruKETKEvdFz/libcoll
ections.rlib" "/var/folders/x6/r9vc_y8n0hqc_txxy1wz7r9w0000gn/T/rustc.lruKETKEvdFz/libsystem.rlib" "/var/folders/x6/r9vc_y8n0hqc_txxy1wz7r9w0000gn/T/rustc.lruKETKEvdFz/liballoc.rlib
" "/var/folders/x6/r9vc_y8n0hqc_txxy1wz7r9w0000gn/T/rustc.lruKETKEvdFz/liballoc_malloc.rlib" "/var/folders/x6/r9vc_y8n0hqc_txxy1wz7r9w0000gn/T/rustc.lruKETKEvdFz/librand.rlib" "/var
/folders/x6/r9vc_y8n0hqc_txxy1wz7r9w0000gn/T/rustc.lruKETKEvdFz/librustc_unicode.rlib" "/var/folders/x6/r9vc_y8n0hqc_txxy1wz7r9w0000gn/T/rustc.lruKETKEvdFz/libcore.rlib"
note: /usr/local/Cellar/x86_64-elf-gcc/5.3.0/lib/gcc/x86_64-elf/5.3.0/../../../../x86_64-elf/bin/ld: i386 architecture of input file `/var/folders/x6/r9vc_y8n0hqc_txxy1wz7r9w0000gn/
T/rustc.lruKETKEvdFz/liballoc_malloc.rlib(lib_a-malloc.o)' is incompatible with i386:x86-64 output
/usr/local/Cellar/x86_64-elf-gcc/5.3.0/lib/gcc/x86_64-elf/5.3.0/../../../../x86_64-elf/bin/ld: i386 architecture of input file `/var/folders/x6/r9vc_y8n0hqc_txxy1wz7r9w0000gn/T/rust
c.lruKETKEvdFz/liballoc_malloc.rlib(lib_a-mallocr.o)' is incompatible with i386:x86-64 output
[...and so on...]
Running readelf -h build/x86_64-unknown-redox/debug/*.rlib
reveals a mixture of ELF32 and ELF64 classes like
File: build/x86_64-unknown-redox/debug/libsystem.rlib(libsystem.0.o)
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 49096 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 64 (bytes)
Number of section headers: 357
Section header string table index: 1
and
File: build/x86_64-unknown-redox/debug/libstd.rlib(lib_a-w_tgamma.o)
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 10356 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 40 (bytes)
Number of section headers: 14
Section header string table index: 11