Xargo build cross compiler for armv5te (tier 3)

I want to build rustc cross compiler for armv5te-unknown-linux-gnueabi.
I google and found that xargo looks like is what I want,
but I stuck after reading readme:

$ rustup component add rust-src
info: component 'rust-src' is up to date

$ rustc --version
rustc 1.22.0-nightly (f6d751454 2017-10-17)

$ rustc -Z unstable-options --print target-spec-json --target armv5te-unknown-linux-gnueabi > armv5te-unknown-linux-gnueabi.json
$ ls
armv5te-unknown-linux-gnueabi.json  Xargo.toml
$ cat Xargo.toml 
[dependencies]
std = {default-features=false, features = ["jemalloc"]}
$ xargo build --target armv5te-unknown-linux-gnueabi
error: could not find `Cargo.toml` in `/home/user/projects/rust_armv5` or any parent directory

What kind of Cargo.toml xargo want?

1 Like

Hi @davemilter, rustc is already a cross compiler for armv5te-unknown-linux-gnueabi, it's just doesn't come with the sysroot for that target. Xargo is a wrapper around Cargo that will build the sysroot on demand. So you should just be able to drop your Xargo.toml in your existing Cargo project and just use xargo in place of cargo.

2 Likes

Thanks for answer @parched . What about ".json" file that I got from rustc -Z unstable-options --print target-spec-json --target armv5te-unknown-linux-gnueabi ? My ARM CPU has vfp and linux image was build for arm5te/hardfloat/vfp also I have C/C++ cross compiler for that system, so I need somehow inform xargo to use this cross-compiler (at least linker) to build std lib. Not sure, but I have to modify json file to tweak build of sysroot?

Ok, normally you wouldn't need it. But for hard float you're going to need to create your own custom one. So take that one and rename it to armv5te-unknown-linux-gnueabihf.json then edit it by changing the "llvm-target" to armv5te-unknown-linux-gnueabihf and replace +soft-float with +vfp2 in "features". Then you can just call xargo --target=armv5te-unknown-linux-gnueabihf ....

Yes for linking you will need to edit .cargo/config and add

[target.armv5te-unknown-linux-gnueabihf]
linker = "path/to/cross/gcc"

Thanks again @parched for answer.

Then you can just call xargo --target=armv5te-unknown-linux-gnueabihf ....

Not works for me :frowning: At first it failed in compilation of adddf3vfp.S, I fixed it with:

 export TARGET_CC=arm-angstrom-linux-gnueabi-gcc
 export TARGET_CFLAGS="-march=armv5te -mtune=arm926ej-s -mfpu=vfp -mfloat-abi=hard"

because of it tries to build arm assermbler with host compiler (linux/amd64) - cc.

But after that it fails with

member /tmp/rustc.SHXQA7VOOv9h/liballoc_jemalloc-35c6b12fd8797d52.rlib(jemalloc.pic.o) in archive is not an object

looks like some part of liballoc compiled with host compiler instead of cross compiler?

Hmm, I'm not sure sorry. Maybe @japaric has some ideas?

@davemilter I would suggest using the system allocator instead of jemalloc. jemalloc has problems on several platforms that are not x86, which is why it has been disabled for several official targets. I don't know what's the exact procedure for that these days but I expect that you'll need to drop the jemalloc feature and change the alloc setting in the target specification from jemalloc to alloc (if that setting still exists).

2 Likes

See this thread for how to disable jemalloc and use system allocator instead. The API is currently nightly-only.

2 Likes

armv5te was added in travis builder in https://github.com/rust-lang/rust/pull/46498. This will be available in the next nightly.

1 Like