Replies: 1 comment 2 replies
-
No, the sysroot is elsewhere ( I'm not sure what went wrong with zig, as for the attempt to borrow the sysroot from the target, not going to delve into it :3 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have an
armv7-unknown-linux-gnueabihf
target with a rather old glibc 2.20. So the standard way of cross compiling does not work for me, because the glibc versions provided by the ghcr.io/cross-rs/armv7-unknown-linux-gnueabihf images do not match my target system. So my naive idea was, why not link against the target system itself? I have an image of the target system that I have mounted into the docker image so that I can tell the linker to use it as sysroot. I am not an expert when it comes to cross compiling, so maybe this idea does not work at all. It would be nice, if someone can help me.These are my attempts so far:
Sysroot link attempts
I added these lines to
Cross.toml
in order to mount my sysroot and configuring the linker to use it:Unfortunately I cannot use the environment variable
MY_SYSROOT
in the last line, because it would no be expanded. Off-topic question: Is there a simple solution for that?I noticed that the linker does not use the libc from
/path/to/my/sysroot/lib/libc-2.20.so
(it linked without errors, but the resulting executable has GLIBC links greater 2.20 when examining with readelf). So I explicitly tell the linker to use that version by adding this line inbuild.rs
:I asume that the linker uses libc from my sysroot now, but it still uses a different libpthread that is not compatible. For example I get the linker error:
What is the correct way to tell the linker to only look in my sysroot? Apparently it still looks in
/usr/lib/gcc-cross/arm-linux-gnueabihf
.I also tried to specify the search paths in
build.rs
in addition.Then I get:
libpthread_nonshared.a
is not available on my target system. I am not sure why this happens. Can anyone explain this?Creating new image with correct libc version
I tried to create a new docker image that has the correct libc version. I followed the instructions in the cross-toolchains repository and in this discussion. I did manage to create a new image using these commands:
In the end there was one warning. I am not sure if that can be ignored:
I was able to successfully compile a hello world program (without setting a sysroot for now). But it was using a new libc. And looking into the image I found this file:
/usr/lib32/libc-2.31.so
. Shouldn't that be 2.20?Using zig
Now I tried to specifiy the correct libc version with zig. I added the following to my
Cross.toml
:The sysroot was still set. The program compiled and linked successfully. But I get a core dump when running the executable on the target:
Does anyone have an idea what went wrong?
Using musl target
Using the target
armv7-unknown-linux-musleabihf
works out of the box. However, I am curious why my attempts above do not work. Maybe someone has an idea?Beta Was this translation helpful? Give feedback.
All reactions