# How to build rust for cross-compiling?

**URL:** <https://users.rust-lang.org/t/how-to-build-rust-for-cross-compiling/1366>\
**Category:** help\
**Created:** [May 15, 2015, 5:00pm UTC](https://users.rust-lang.org/t/how-to-build-rust-for-cross-compiling/1366 "2015-05-15T17:00:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chessnokov](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/chessnokov/32/11926_2.png) [@chessnokov](https://users.rust-lang.org/u/chessnokov)\
**Post date:** [May 15, 2015, 5:00pm UTC](https://users.rust-lang.org/t/how-to-build-rust-for-cross-compiling/1366/1 "2015-05-15T17:00:20Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![alexcrichton](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/alexcrichton/32/12_2.png) [@alexcrichton](https://users.rust-lang.org/u/alexcrichton)\
**Post date:** [May 15, 2015, 6:21pm UTC](https://users.rust-lang.org/t/how-to-build-rust-for-cross-compiling/1366/2 "2015-05-15T18:21:49Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![chessnokov](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/chessnokov/32/11926_2.png) [@chessnokov](https://users.rust-lang.org/u/chessnokov)\
**Post date:** [May 16, 2015, 6:47am UTC](https://users.rust-lang.org/t/how-to-build-rust-for-cross-compiling/1366/5 "2015-05-16T06:47:05Z")

</div>

`[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`

---

<div class="post-metadata">

**Author:** ![alexcrichton](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/alexcrichton/32/12_2.png) [@alexcrichton](https://users.rust-lang.org/u/alexcrichton)\
**Post date:** [May 18, 2015, 3:22pm UTC](https://users.rust-lang.org/t/how-to-build-rust-for-cross-compiling/1366/6 "2015-05-18T15:22:23Z")

</div>

Ah yes the problem here is this command:

```rust
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.

---

<div class="post-metadata">

**Author:** ![chessnokov](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/chessnokov/32/11926_2.png) [@chessnokov](https://users.rust-lang.org/u/chessnokov)\
**Post date:** [October 1, 2015, 9:52am UTC](https://users.rust-lang.org/t/how-to-build-rust-for-cross-compiling/1366/7 "2015-10-01T09:52:32Z")

</div>

Fixed by setup linaro toolchain.

---

<div class="post-metadata">

**Author:** ![steffahn](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/steffahn/32/47569_2.png) [@steffahn](https://users.rust-lang.org/u/steffahn)\
**Post date:** [January 12, 2023, 8:37am UTC](https://users.rust-lang.org/t/how-to-build-rust-for-cross-compiling/1366/8 "2023-01-12T08:37:54Z")

</div>


