Skip to content
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

Darwin+Podman: Unable to cross-compile #1583

Open
4 of 11 tasks
skittishdev opened this issue Nov 1, 2024 · 4 comments
Open
4 of 11 tasks

Darwin+Podman: Unable to cross-compile #1583

skittishdev opened this issue Nov 1, 2024 · 4 comments

Comments

@skittishdev
Copy link

skittishdev commented Nov 1, 2024

Checklist

Describe your issue

cross doesn't work when I try to use it with podman (even if I set the CROSS_CONTAINER_ENGINE=podman env variable) on my Mac/M2. But the same project cross compiles successfully with docker.

What target(s) are you cross-compiling for?

aarch64-unknown-linux-gnu

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.5 (4090bec 2024-10-15)

Example

I have both docker and podman installed on my Mac. My Docker Desktop application is not running.

ps -ef | grep docker
  503 68715 69102   0  5:05PM ttys007    0:00.00 grep docker
podman machine init --cpus=8 --disk-size=64 --memory=24576 foo
podman machine start foo
CROSS_CONTAINER_ENGINE=podman cross build --target aarch64-unknown-linux-gnu --release

This results in an error like so:

Error: 
   0: /proc/self/mountinfo is unavailable when target_os != linux

Location:
   src/docker/shared.rs:1354

Additional information / notes

Cross works just fine with Docker. The command below results in a successful build when my Docker Desktop application is running in the background.

cross build --target aarch64-unknown-linux-gnu --release

I installed cross as specified in the docs: https://github.com/cross-rs/cross/blob/main/docs/getting-started.md#installing-cross-1

@skittishdev
Copy link
Author

Podman info (if needed)

$ podman version
Client:       Podman Engine
Version:      5.2.5
API Version:  5.2.5
Go Version:   go1.23.2
Git Commit:   10c5aa720d59480bc7edad347c1f5d5b75d4424f
Built:        Fri Oct 18 07:51:48 2024
OS/Arch:      darwin/arm64

Server:       Podman Engine
Version:      5.2.5
API Version:  5.2.5
Go Version:   go1.22.7
Built:        Thu Oct 17 17:00:00 2024
OS/Arch:      linux/arm64

@Emilgardis
Copy link
Member

This was changed in #1485 and there some assumption done there that is incorrect for podman in the rest of the application logic. Should be an easy fix once located why it happens

@skittishdev
Copy link
Author

skittishdev commented Nov 29, 2024

This was changed in #1485 and there some assumption done there that is incorrect for podman in the rest of the application logic. Should be an easy fix once located why it happens

I looked at the code in this linked commit, and realized that MacOS doesn't set a $HOSTNAME environment variable. In order to test a potential fix I did an export HOSTNAME=$(hostname), and then executed this command: CROSS_CONTAINER_ENGINE=podman cross build --target aarch64-unknown-linux-gnu --release. But now I see errors like so (a different error each time):

Error: statfs /Users/skittishdev/.xargo: no such file or directory
Error: statfs /Users/skittishdev/.cargo: no such file or directory
Error: statfs /Users/skittishdev/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu: no such file or directory

@skittishdev
Copy link
Author

skittishdev commented Nov 29, 2024

rustup toolchain that is being complained about is present, though it is not native to my platform.

# rustup toolchain list
stable-aarch64-apple-darwin (default)
nightly-aarch64-apple-darwin (override)
nightly-x86_64-unknown-linux-gnu

When I run rustup update I see this:

      stable-aarch64-apple-darwin unchanged - rustc 1.83.0 (90b35a623 2024-11-26)
      nightly-aarch64-apple-darwin unchanged - rustc 1.85.0-nightly (a2545fd6f 2024-11-28)
      nightly-x86_64-unknown-linux-gnu unchanged - (error reading rustc version)

I don't understand why the x86_64 target is needed when the target is specify is aarch64, but I'll assume that's the platform that cross uses to cross-compile. I also ran rustup install nightly-aarch64-unknown-linux-gnu --force-non-host, but there is no change is the errors.

If I use docker though, the cross compilation continues to work just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants