cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.59k stars 365 forks source link

Ability to override base image? #1471

Closed fuzzypixelz closed 5 months ago

fuzzypixelz commented 5 months ago

Checklist

Describe your request

Is it reasonable to make the Docker images accept a $BASE_IMAGE argument that a user can override to something like ubuntu-16.04 (e.g. for compatibility with systems that require older versions of glibc).

Describe why this would be a good inclusion for cross

No response

Emilgardis commented 5 months ago

How would you use this? E.g what is the mechanism that switches base image? Does this only apply to our build-docker-image

We already have https://github.com/cross-rs/cross/blob/main/docs/custom_images.md#custom-image

fuzzypixelz commented 5 months ago

How would you use this? E.g what is the mechanism that switches base image? Does this only apply to our build-docker-image

We already have https://github.com/cross-rs/cross/blob/main/docs/custom_images.md#custom-image

I meant exposing the base image as a build argument:

ARG BASE=ubuntu-20.04
FROM ${BASE}

# ...

Alas this wouldn't work if I try to override it when using cross images themselves as a base image.

My goal is getting cross images based on Ubuntu 16.04 (to support older versions of glibc). I tried to simply change it in the Dockerfiles and run cargo xtask build-docker-image x86_64-unknown-linux-gnu but that expectedly failed with Unable to locate package libgcc-s1:amd64. Who knows what other things will go wrong there.

Emilgardis commented 5 months ago

I see, I don't think we'd be able to support this without many small fixes in many places, and 16.04 is not really maintained anymore. We will (eventually, far future) be merging all the pre-setup stuff into one base image, which would maybe help with your effort. See https://github.com/cross-rs/cross/pull/953

I'll close this issue as it's not something we want to do, if you want to have older glibc I'd recommend you to look into crosstool-ng, which we can use to support older libraries. There's no documentation about how to do it but see cargo xtask configure-crosstool and one of the targets which uses that

fuzzypixelz commented 5 months ago

I see, I don't think we'd be able to support this without many small fixes in many places, and 16.04 is not really maintained anymore. We will (eventually, far future) be merging all the pre-setup stuff into one base image, which would maybe help with your effort. See #953

I'll close this issue as it's not something we want to do, if you want to have older glibc I'd recommend you to look into crosstool-ng, which we can use to support older libraries. There's no documentation about how to do it but see cargo xtask configure-crosstool and one of the targets which uses that

Thanks a lot! I'll look into the crosstool-ng option once I have the time and report my findings.

Emilgardis commented 5 months ago

Oh yeah! I forgot about zig also which is the obvious way to do it :)

https://github.com/cross-rs/cross/blob/main/docs/config_file.md#targettargetzig