Missing ar when cross-compiling to linux-musl

I am trying to cross-compile to target x86_64-unknown-linux-musl , however it fails with

   Compiling tree-sitter v0.25.1
error: failed to run custom build command for `tree-sitter-rust v0.23.2`

Caused by:
  process didn't exit successfully: `/home/xxx/analyzer/target/release/build/tree-sitter-rust-e81771346d0450b6/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=src/parser.c
  cargo:rerun-if-changed=src/scanner.c
  OUT_DIR = Some(/home/xxx/analyzer/target/x86_64-unknown-linux-musl/release/build/tree-sitter-rust-a670d8928237239c/out)
  OPT_LEVEL = Some(3)
  TARGET = Some(x86_64-unknown-linux-musl)
  HOST = Some(x86_64-unknown-linux-gnu)
  cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-musl
  CC_x86_64-unknown-linux-musl = None
  cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_musl
  CC_x86_64_unknown_linux_musl = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = Some(x86_64-linux-musl-gcc)
  cargo:rerun-if-env-changed=CC_KNOWN_WRAPPER_CUSTOM
  CC_KNOWN_WRAPPER_CUSTOM = None
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(false)
  CARGO_CFG_TARGET_FEATURE = Some(fxsr,sse,sse2)
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-musl
  CFLAGS_x86_64-unknown-linux-musl = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_musl
  CFLAGS_x86_64_unknown_linux_musl = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  CARGO_ENCODED_RUSTFLAGS = Some()
  cargo:rerun-if-env-changed=AR_x86_64-unknown-linux-musl
  AR_x86_64-unknown-linux-musl = None
  cargo:rerun-if-env-changed=AR_x86_64_unknown_linux_musl
  AR_x86_64_unknown_linux_musl = None
  cargo:rerun-if-env-changed=TARGET_AR
  TARGET_AR = None
  cargo:rerun-if-env-changed=AR
  AR = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  RUSTC_LINKER = Some(x86_64-linux-musl-gcc)
  cargo:rerun-if-env-changed=ARFLAGS_x86_64-unknown-linux-musl
  ARFLAGS_x86_64-unknown-linux-musl = None
  cargo:rerun-if-env-changed=ARFLAGS_x86_64_unknown_linux_musl
  ARFLAGS_x86_64_unknown_linux_musl = None
  cargo:rerun-if-env-changed=TARGET_ARFLAGS
  TARGET_ARFLAGS = None
  cargo:rerun-if-env-changed=ARFLAGS
  ARFLAGS = None

  --- stderr


  error occurred in cc-rs: Command ZERO_AR_DATE="1" "x86_64-linux-musl-ar" "cq" "/home/xxx/analyzer/target/x86_64-unknown-linux-musl/release/build/tree-sitter-rust-a670d8928237239c/out/libtree-sitter-rust.a" "/home/xxx/analyzer/target/x86_64-unknown-linux-musl/release/build/tree-sitter-rust-a670d8928237239c/out/ea708c7824d36062-parser.o" "/home/xxx/analyzer/target/x86_64-unknown-linux-musl/release/build/tree-sitter-rust-a670d8928237239c/out/ea708c7824d36062-scanner.o" with args x86_64-linux-musl-ar did not execute successfully (status code exit status: 127).

I tried to install musl-tools and musl-dev on Ubuntu, however I only have x86_64-linux-musl-gcc , musl-gcc and musl-ldd available. Where can I find musl specific binutils?

1 Like

Can you please post the full error message and what command and configuration you used?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.