-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undefined reference to 'gnu_get_libc_version' error when using alpine:3.16
as target image
#1582
Comments
Cross works by mounting the host toolchain into the image, that means you don't need rust in the image itself, only cross-compilation tools for other languages. I recognize this error, and had a way to solve it, but I can't remember where I documented it (I think the fix was installing some glibc compat package). Anyway, you should be able to get away from this by using a If you want to use a musl rust toolchain instead, use [target.x86_64-unknown-linux-musl]
image.name = "alpine:3.16"
image.toolchain = ["x86_64-unknown-linux-musl"] |
If I use the following cross configuration: [target.x86_64-unknown-linux-musl]
image.name = "alpine:3.16"
image.toolchain = ["x86_64-unknown-linux-musl"]
pre-build = [
"apk add --no-cache openssl-dev musl-dev build-base perl"
] I get the following error: Error:
0: failed to parse file `"/tmp/test-cross/Cross.toml"` as TOML
1: invalid type: map, expected a string for key `target.x86_64-unknown-linux-musl.image` at line 2 column 14 Is it something that was added since |
oh yeah, sorry thought you were using cross from the main branch. You can install it with |
I've installed
It seems like |
Yes, it will always do that, we dont support using rust installed in the image (although it is possible, but no reason to use the cross cli then) I'm not sure how to fix a nix rustup/rustc setup. Try setting the edit: actually, not needed, the error message suggests it's been loaded, but you can make sure with |
In the end, I was able to configure [target.x86_64-unknown-linux-musl]
image = "alpine:3.16"
pre-build = [
"apk add --no-cache fuse3-dev fuse3-static openssl-dev musl-dev build-base perl rustup gcompat",
# Install our own rustup toolchain since we prefer to not rely on the host provided one
"rustup-init -y --default-toolchain stable --profile minimal",
# Make sure the build user will be able to access the toolchain binaries
"P=/root/.rustup/toolchains/stable-x86_64-unknown-linux-musl/bin; while [ \"$P\" != \"/\" ]; do chmod -v 755 $P; P=$(dirname $P); done"
]
[target.x86_64-unknown-linux-musl.env]
passthrough = [
# Modify the PATH to prefer the rust toolchain of the container over the host one.
"PATH=/root/.rustup/toolchains/stable-x86_64-unknown-linux-musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
] |
Checklist
Describe your issue
I'm trying to compile a CLI that depends on
openssl
andfuse3
.I was able to statically build that CLI directly inside the docker container
alpine:3.16
.Now I would like to use
cross
for that so I've configuredtarget.x86_64-unknown-linux-musl.image
to usealpine:3.16
but when build the project I'm getting errors aboutundefined reference to 'gnu_get_libc_version'
.Another thing that's odd for me is that I've never configured the
target.x86_64-unknown-linux-musl.pre-build
to installrust
butcross
seems to use one anywaySo how
cross
is able to usecargo
if it's not provided by used the image?Is it possible to force
cross
to use what provided by the image and error out if something is missing?What target(s) are you cross-compiling for?
x86_64-unknown-linux-musl
Which operating system is the host (e.g computer cross is on) running?
What architecture is the host?
What container engine is cross using?
cross version
cross 0.2.5
Example
Execute the following commands:
Modify
src/main.rs
to be like the following:Add the following cross configuration file in
Cross.toml
Try to build with
cross build --release --target=x86_64-unknown-linux-musl
Additional information / notes
Output of:
cross b --release --target=x86_64-unknown-linux-musl
The text was updated successfully, but these errors were encountered: