How to build rust for cross-compiling?


#1

I downloaded rust beta 5 ant try to build it for cross-compiling:
./configure --disable-dist-host-only --target=arm-unknown-linux-gnueabihf,x86_64-unknown-linux-gnu,x86_64-pc-windows-gnu && make

i got error:
`/usr/lib/gcc/arm-linux-gnueabi/4.9.2/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory

include_next <stdint.h>

                      ^

compilation aborted.`

What you need to do to solve this?
Is there any official documentation for assembly Rust for cross-compiling?


#2

This may mean that the toolchain being used to compile the arm-unknown-linux-gnueabihf C code may be misconfigured or may not be installed correctly. Could you try running make VERBOSE=1 and then seeing what command is run to compile this file? Running and/or debugging that manually may shed some light.

In general though that’s how to build a compiler which can cross to other targets!


#5

`[chessnokov@np300v4a rustc-1.0.0]$ make VERBOSE=1
cfg: version 1.0.0-dev (built 2015-05-16)
cfg: build triple x86_64-unknown-linux-gnu
cfg: host triples x86_64-unknown-linux-gnu
cfg: target triples x86_64-unknown-linux-gnu arm-unknown-linux-gnueabihf x86_64-pc-windows-gnu
cfg: non-build target triples arm-unknown-linux-gnueabihf x86_64-pc-windows-gnu
cfg: host for x86_64-unknown-linux-gnu is x86_64
cfg: host for arm-unknown-linux-gnueabihf is arm
cfg: host for x86_64-pc-windows-gnu is x86_64
cfg: os for x86_64-unknown-linux-gnu is unknown-linux-gnu
cfg: os for arm-unknown-linux-gnueabihf is unknown-linux-gnueabihf
cfg: os for x86_64-pc-windows-gnu is pc-windows-gnu
cfg: good valgrind for x86_64-unknown-linux-gnu is 1
cfg: good valgrind for arm-unknown-linux-gnueabihf is
cfg: good valgrind for x86_64-pc-windows-gnu is
cfg: using CC=gcc (CFG_CC)
cfg: enabling valgrind run-pass tests (CFG_ENABLE_VALGRIND_RPASS)
cfg: valgrind-rpass command set to
cfg: no xelatex found, disabling LaTeX docs
cfg: no pandoc found, omitting PDF and EPUB docs
make -C “/home/chessnokov/rustc-1.0.0/src/compiler-rt” ProjSrcRoot="/home/chessnokov/rustc-1.0.0/src/compiler-rt" ProjObjRoot="/home/chessnokov/rustc-1.0.0/arm-unknown-linux-gnueabihf/rt/compiler-rt" CC=“arm-linux-gnueabihf-gcc” AR=“arm-linux-gnueabihf-ar” RANLIB=“arm-linux-gnueabihf-ar s” CFLAGS="-Wall -g -fPIC -D__arm__ " TargetTriple=arm-unknown-linux-gnueabihf triple-builtins
make[1]: Entering directory '/home/chessnokov/rustc-1.0.0/src/compiler-rt’
warning: clang_darwin.mk: dropping arch ‘i386’ from lib ‘eprintf’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘i386’ from lib ‘10.4’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64’ from lib ‘10.4’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘i386’ from lib ‘ios’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64’ from lib ‘ios’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64h’ from lib ‘ios’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘armv7’ from lib ‘ios’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘i386’ from lib ‘osx’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64’ from lib ‘osx’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64h’ from lib ‘osx’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘armv7’ from lib ‘cc_kext’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘i386’ from lib ‘cc_kext’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64’ from lib ‘cc_kext’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64h’ from lib ‘cc_kext’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64’ from lib ‘cc_kext_ios5’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64h’ from lib ‘cc_kext_ios5’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘armv7’ from lib ‘cc_kext_ios5’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘i386’ from lib ‘profile_osx’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64’ from lib ‘profile_osx’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64h’ from lib ‘profile_osx’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘i386’ from lib ‘profile_ios’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64’ from lib ‘profile_ios’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64h’ from lib ‘profile_ios’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘armv7’ from lib ‘profile_ios’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘i386’ from lib ‘asan_osx_dynamic’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64’ from lib ‘asan_osx_dynamic’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64h’ from lib ‘asan_osx_dynamic’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘i386’ from lib ‘ubsan_osx’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64’ from lib ‘ubsan_osx’ (clang does not support it)
warning: clang_darwin.mk: dropping arch ‘x86_64h’ from lib ‘ubsan_osx’ (clang does not support it)
warning: clang_macho_embedded.mk: dropping arch ‘armv6m’ from lib 'soft_static’
warning: clang_macho_embedded.mk: dropping arch ‘armv7m’ from lib 'soft_static’
warning: clang_macho_embedded.mk: dropping arch ‘armv7em’ from lib 'soft_static’
warning: clang_macho_embedded.mk: dropping arch ‘armv7’ from lib 'soft_static’
warning: clang_macho_embedded.mk: dropping arch ‘armv7em’ from lib 'hard_static’
warning: clang_macho_embedded.mk: dropping arch ‘armv7’ from lib 'hard_static’
warning: clang_macho_embedded.mk: dropping arch ‘i386’ from lib 'hard_static’
warning: clang_macho_embedded.mk: dropping arch ‘x86_64’ from lib 'hard_static’
warning: clang_macho_embedded.mk: dropping arch ‘armv6m’ from lib 'soft_pic’
warning: clang_macho_embedded.mk: dropping arch ‘armv7m’ from lib 'soft_pic’
warning: clang_macho_embedded.mk: dropping arch ‘armv7em’ from lib 'soft_pic’
warning: clang_macho_embedded.mk: dropping arch ‘armv7’ from lib 'soft_pic’
warning: clang_macho_embedded.mk: dropping arch ‘armv7em’ from lib 'hard_pic’
warning: clang_macho_embedded.mk: dropping arch ‘armv7’ from lib 'hard_pic’
warning: clang_macho_embedded.mk: dropping arch ‘i386’ from lib 'hard_pic’
warning: clang_macho_embedded.mk: dropping arch ‘x86_64’ from lib 'hard_pic’
COMPILE: triple/builtins/arm: /home/chessnokov/rustc-1.0.0/src/compiler-rt/lib/builtins/absvdi2.c
arm-linux-gnueabihf-gcc -I/home/chessnokov/rustc-1.0.0/src/compiler-rt/lib -I/home/chessnokov/rustc-1.0.0/src/compiler-rt/include -Wall -g -fPIC -D__arm__ -std=c99 -c -o /home/chessnokov/rustc-1.0.0/arm-unknown-linux-gnueabihf/rt/compiler-rt/triple/builtins/arm/SubDir.lib__builtins/absvdi2.o /home/chessnokov/rustc-1.0.0/src/compiler-rt/lib/builtins/absvdi2.c
In file included from /home/chessnokov/rustc-1.0.0/src/compiler-rt/lib/builtins/int_lib.h:45:0,
from /home/chessnokov/rustc-1.0.0/src/compiler-rt/lib/builtins/absvdi2.c:15:
/usr/lib/gcc/arm-linux-gnueabi/4.9.2/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory

include_next <stdint.h>

                      ^

compilation terminated.
Makefile:267: recipe for target ‘/home/chessnokov/rustc-1.0.0/arm-unknown-linux-gnueabihf/rt/compiler-rt/triple/builtins/arm/SubDir.lib__builtins/absvdi2.o’ failed
make[1]: *** [/home/chessnokov/rustc-1.0.0/arm-unknown-linux-gnueabihf/rt/compiler-rt/triple/builtins/arm/SubDir.lib__builtins/absvdi2.o] Error 1
make[1]: Leaving directory ‘/home/chessnokov/rustc-1.0.0/src/compiler-rt’
/home/chessnokov/rustc-1.0.0/mk/rt.mk:318: recipe for target ‘arm-unknown-linux-gnueabihf/rt/libcompiler-rt.a’ failed
make: *** [arm-unknown-linux-gnueabihf/rt/libcompiler-rt.a] Error 2`


#6

Ah yes the problem here is this command:

arm-linux-gnueabihf-gcc -I/home/chessnokov/rustc-1.0.0/src/compiler-rt/lib  -I/home/chessnokov/rustc-1.0.0/src/compiler-rt/include -Wall -g -fPIC  -D__arm__ -std=c99 -c -o  /home/chessnokov/rustc-1.0.0/arm-unknown-linux-gnueabihf/rt/compiler-rt/triple/builtins/arm/SubDir.lib__builtins/absvdi2.o  /home/chessnokov/rustc-1.0.0/src/compiler-rt/lib/builtins/absvdi2.c

You may want to try running that manually and see if you can diagnose the problem further through that.


#7

Fixed by setup linaro toolchain.