Hi All, because I am using a old arm-unknown-linux-gnueabihf platform, and it only support the glibc_2.5, so I want to compile rust (and rust std library) with specific glibc version for this platform, but I can't find the place I need to modify(script file or configure file). Anyone have this similar requirement or can give some help? Thanks in advance.
You should be able to just build rustc against an appropriately configured toolchain; I don't think you need to configure with any special option for glibc 2.5 in particular. See https://github.com/japaric/rust-cross#advanced-topics for general cross-compilation instructions.
I want to compile rust (and rust std library) with specific glibc version
TL;DR It's up to the toolchain you use to build them.
The glibc version requirement is determined by the (cross) toolchain you use to build rustc/libstd. If you use a cross toolchain that contains e.g. a cross compiled glibc-2.14 then the std/rustc produced with that toolchain (and the binaries produced with that std/rustc) will likely contain symbols introduced in glibc-2.14 and that will impose a requirement of >=glibc-2.14 on the host system.
BTW, the official releases of std/rustc for arm(v7)-unknown-linux-gnueabi(hf)
are built against glibc-2.14
Thank you very much for your answer.
For your tips " the official releases of std/rustc for arm(v7)-unknown-linux-gnueabi(hf) are built against glibc-2.14", Actually, at first I build successfully my demo app with the official nightly release and with the target "arm-unknown-linux-gnueabihf", but when I push it into the device and run it, it gives me the error:
"/data/test2: /lib/libc.so.6: version `GLIBC_2.18' not found (required by /data/test2)",
my device only support the glibc-2.15, so I start trying to build the rust std lib with a specific glibc version.
rustc verion:
rustc 1.12.0-nightly (27e766d7b 2016-07-19)
host OS:
Ubuntu 16.04 x86_64
BTW, as your answer I will try to find a suitable toolchains to re-compile the rust. Thank you very much.
Actually, at first I build successfully my demo app with the official nightly release and with the target "arm-unknown-linux-gnueabihf", but when I push it into the device and run it, it gives me the error:
This is via cross compilation, right? Building a Rust binary involves linking to a cross compiled glibc and the version of that glibc is up to the cross toolchain you have installed. In this case it seems you are cross compiling on Ubuntu 16.04. The gcc-arm-linux-gnueabi(hf)
package in that Ubuntu version ships with glibc-2.23. You have to use a cross toolchain with an older glibc.
BTW, as your answer I will try to find a suitable toolchains to re-compile the rust.
You can this Docker image it contains an ARM cross toolchain that ships with glibc-2.14. The official binary releases are built using that toolchain.
my device only support the glibc-2.15
I thought it used glibc-2.5 as you mentioned in your opening post. That changes things. First, you don't build std yourself; you can use one of the official releases -- I recommend using rustup to install them. Second, you don't need to cross compile, you can install rustc on the ARM device and compile natively over there -- this eliminates all these problems related to glibc symbols.
Thanks for your very detailed answer~~
Yes, the Ubuntu 16.04 shipped with glibc-2.23. I naively think if I use an old enough toolchain(arm-linux-gnueabihf-gcc-4.7 for me), which would call the old glibc, but this is not true.
Right now, follow your suggest, I install rustc on my device, build and run my demo, it works! Thank you again!
The next step, I will also try the docker image.
with this docker image, I also build a rust cross-toolchain with old glibc version successfully~~.