-
Notifications
You must be signed in to change notification settings - Fork 392
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
CROSS_CONTAINER_OPTS
does not replace --platform linux/amd64
#1498
Comments
to use a custom image with another platform you need to specify the platforms it can/should run with. See https://github.com/cross-rs/cross/blob/main/docs/config_file.md#targettargetimage [target.aarch64-unknown-linux-gnu]
image.name = "alpine:edge"
image.toolchain = ["x86_64-unknown-linux-musl", "linux/arm64=aarch64-unknown-linux-musl"] so in this case, you want [target.aarch64-unknown-linux-gnu]
image.name = "my-image"
image.toolchain = ["aarch64-unknown-linux-gnu"] |
Thanks for the reply @Emilgardis. I had tried quite a few option and I might not have listed trying this:
and my script does a The problem I am seeing, is that cross-rs is not letting me choose the docker platform to run/build on, even if I try and overload with either of the two env |
You need to tell cross that the image can run on aarch64 platform, we assume x86_64 if nothing is specified. To choose the platform, you need to add it as a valid platform for that image [target.aarch64-unknown-linux-gnu]
image.name = "ubuntu:18.04"
image.toolchain = ["aarch64-unknown-linux-gnu"] There is however no way to tell cross "of all the possible platforms, please use |
Thanks again @Emilgardis , can we not use the env What I was raising is that the docker run command, thou it does add the env to the run but at the end, does not replace what looks like the default of |
What my original expectation was that the docker would be running with local CPU arch, unless overridden or forced, might that be better user expectation? |
To not have cross insert Line 437 in 19be834
I think we can do that, it's consistent with what we do for
That's an interesting insight, it might be worth doing. My only concern is how moby/buildx now attests image provenence with |
That is the issue where I got the idea to try and force the docker platform, when I was able to debug that the arm64 was defaulting to using the x86_64 docker engine. The idea I was raising and really hoping would be easy to fix or even test, would be to stop the defaulting to x86_64 or be able to use the Interestingly, somebody might want to force building with As for the docker images having |
It's unclear to me if you've been able to solve your problem, the way to immediately solve your issue of not being able to specify With that config it's even possible to specify precisely what platform to use [target.aarch64-unknown-linux-gnu]
image.name = "ubuntu:18.04"
# syntax = <platform>=<toolchain>
image.toolchain = ["linux/arm64=aarch64-unknown-linux-gnu"] |
I missed your suggestion on how to possible target the platform, let me test and report back. Thanks @Emilgardis for all the support. |
Thanks @Emilgardis , I was able to come right. I can cross-compile our project on both x86_64 and aarch64 OSX computers to Linux x86_64 and aarch64. I am not sure I would have tried your suggestion from the documentation, thou that might just be me trying to get something do in a very specific kind of way. Still not sure that it is right, but it works. The docker command line might still be a bug, as it does not only issue one set of args as overrides, just duplicates what you have put into the env. |
Adding some info and possible see which way this goes
maybe better for me to open another issue regarding how the Apple Silicon does not seem to use the native platform and need to use the commented out targeting using the toolchain. Using the selection as is, looks like it works on Windows and Linux, but they both x86_64 systems, vs the Apple machine which is native |
The image.toolchain config is an array, you can specify multiple platforms/toolchains It works like that by design, as I've described earlier |
So, you would do
|
When I try this, I get:
|
@KarstenB I should clarify, above only works on the main branch, so, you'll need to install cross as |
Checklist
Describe your issue
I don't think that the
CROSS_CONTAINER_OPTS
env is replacing the--platform linux/amd64
command, at least not on Apple Silicon.What target(s) are you cross-compiling for?
aarch64-unknown-linux-gnu, x86_64-unknown-linux-gnu
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 (19be834 2024-05-17)
Example
Running
then trying run
You might notice
docker buildx build --platform linux/amd64
with--platform linux/arm64
much later in the command, which I think force running x86 images, even thou I would like to use an aarch64/arm64 image.Reason been, that I was looking to run a CPU native docker image as my base to cross-compile, I was expecting/hoping to use
aarch64-unknown-linux-gnu
image (Ubuntu 18.04), but kept running intorosetta
errors.Additional information / notes
No response
The text was updated successfully, but these errors were encountered: