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

Cross compiling to 'aarch64-unknown-linux-musl' doesn't work #1581

Closed
simonsan opened this issue Nov 28, 2024 · 2 comments
Closed

Cross compiling to 'aarch64-unknown-linux-musl' doesn't work #1581

simonsan opened this issue Nov 28, 2024 · 2 comments

Comments

@simonsan
Copy link

simonsan commented Nov 28, 2024

aarch64-linux-musl-gcc is being installed by musl-dev: https://packages.ubuntu.com/search?searchon=contents&keywords=aarch64-linux-musl-gcc&mode=exactfilename&suite=oracular&arch=any

Dependencies are being installed correctly:

sudo apt-get update && sudo apt-get install musl-dev=* musl-tools=* musl-tools
[...]
Get:2 http://azure.archive.ubuntu.com/ubuntu jammy/universe amd64 musl amd64 1.2.2-4 [407 kB]
Get:3 http://azure.archive.ubuntu.com/ubuntu jammy/universe amd64 musl-dev amd64 1.2.2-4 [605 kB]
Get:4 http://azure.archive.ubuntu.com/ubuntu jammy/universe amd64 musl-tools amd64 1.2.2-4 [5520 B]
[...]
Unpacking musl-tools (1.2.2-4) ...
Setting up musl:amd64 (1.2.2-4) ...
Setting up musl-dev:amd64 (1.2.2-4) ...
Setting up musl-tools (1.2.2-4) ...

But it seems, it can not be found during compilation, what am I doing wrong?

Relevant parts of my configuration

# dist-workspace.toml
[dist.github-custom-runners]
aarch64-unknown-linux-gnu = "ubuntu-latest"
aarch64-unknown-linux-musl = "ubuntu-latest"

[dist.dependencies.apt]
gcc-aarch64-linux-gnu = { version = '*', targets = ["aarch64-unknown-linux-gnu"] }
musl-tools = { version = '*', targets = ["aarch64-unknown-linux-musl", "x86_64-unknown-linux-musl"] }
musl-dev = { version = '*', targets = ["aarch64-unknown-linux-musl", "x86_64-unknown-linux-musl"] }

Note: No relevant settings in .cargo/config.toml.

CI run

https://github.com/rustic-rs/rustic_server/actions/runs/12068480871/job/33653701050?pr=72

Relevant error

The following warnings were emitted during compilation:

warning: [email protected]: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `aarch64-linux-musl-gcc` installed?
warning: [email protected]: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `aarch64-linux-musl-gcc` installed?
warning: [email protected]: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `aarch64-linux-musl-gcc` installed?

error: failed to run custom build command for `ring v0.17.8`

Caused by:
  process didn't exit successfully: `/home/runner/work/rustic_server/rustic_server/target/dist/build/ring-90433292786ade4e/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
  cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_8_
  OPT_LEVEL = Some(3)
  OUT_DIR = Some(/home/runner/work/rustic_server/rustic_server/target/aarch64-unknown-linux-musl/dist/build/ring-d95b39e9bc62fc6f/out)
  TARGET = Some(aarch64-unknown-linux-musl)
  HOST = Some(x86_64-unknown-linux-gnu)
  cargo:rerun-if-env-changed=CC_aarch64-unknown-linux-musl
  CC_aarch64-unknown-linux-musl = None
  cargo:rerun-if-env-changed=CC_aarch64_unknown_linux_musl
  CC_aarch64_unknown_linux_musl = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  RUSTC_LINKER = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:warning=Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `aarch64-linux-musl-gcc` installed?
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(false)
  CARGO_CFG_TARGET_FEATURE = Some(crt-static,neon)
  cargo:rerun-if-env-changed=CFLAGS_aarch64-unknown-linux-musl
  CFLAGS_aarch64-unknown-linux-musl = None
  cargo:rerun-if-env-changed=CFLAGS_aarch64_unknown_linux_musl
  CFLAGS_aarch64_unknown_linux_musl = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:warning=Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `aarch64-linux-musl-gcc` installed?
  cargo:warning=Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `aarch64-linux-musl-gcc` installed?

  --- stderr


  error occurred: Failed to find tool. Is `aarch64-linux-musl-gcc` installed?
@simonsan
Copy link
Author

.cargo/config.toml

[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"

[target.armv7-unknown-linux-musleabihf]
linker = "arm-linux-gnueabihf-gcc"

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-gnu-gcc"

[target.i686-unknown-linux-gnu]
linker = "i686-linux-gnu-gcc"

[env]
CC_i686-unknown-linux-gnu = "i686-linux-gnu-gcc"
CC_aarch64_unknown_linux_musl = "aarch64-linux-gnu-gcc"
CC_armv7_unknown_linux_gnueabihf = "arm-linux-gnueabihf-gcc"
CC_armv7_unknown_linux_musleabihf = "arm-linux-gnueabihf-gcc"

dist-workspace.toml

[dist.github-custom-runners]
aarch64-apple-darwin = "macos-latest"
aarch64-unknown-linux-gnu = "ubuntu-latest"
aarch64-unknown-linux-musl = "ubuntu-latest"
armv7-unknown-linux-gnueabihf = "ubuntu-latest"
i686-unknown-linux-gnu = "ubuntu-latest"
x86_64-apple-darwin = "macos-13"
x86_64-pc-windows-gnu = "windows-latest"
x86_64-pc-windows-msvc = "windows-latest"
x86_64-unknown-linux-gnu = "ubuntu-latest"
x86_64-unknown-linux-musl = "ubuntu-latest"

[dist.dependencies.apt]
gcc-aarch64-linux-gnu = { version = '*', targets = ["aarch64-unknown-linux-gnu", "aarch64-unknown-linux-musl"] }
gcc-arm-linux-gnueabihf = { version = '*', targets = ["armv7-unknown-linux-gnueabihf"] }
gcc-i686-linux-gnu = { version = '*', targets = ["i686-unknown-linux-gnu"] }
gcc-multilib-i686-linux-gnu =  { version = '*', targets = ["i686-unknown-linux-gnu"] }
musl-tools = { version = '*', targets = ["aarch64-unknown-linux-musl", "x86_64-unknown-linux-musl"] }
musl-dev = { version = '*', targets = ["aarch64-unknown-linux-musl", "x86_64-unknown-linux-musl"] }

seems to do the trick.

@simonsan
Copy link
Author

simonsan commented Nov 30, 2024

@Gankra Maybe, helpful for future dev regarding cross-compilation. I do think, though, that it would be nice to respect e.g. the Cross.toml and use e.g. clechasseur/rs-cargo action that is maintained and utilizes cross. Maybe it's even worth to fork and maintain a cargo cross-compilation action? I think there is a lack thereof.

Something like:

[dist.targets.aarch64-unknown-linux-gnu]
use_cross = true

Would be helpful and could just forward to cross respecting the Cross.toml.

CC: #74

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

1 participant