Rustup RISC-V Install Error

In the midst of installing rustup 1.25.2-3 (Sat 31 Aug 2024 16:41:52) via makedeb, which is locally built, I’m seeing the following error.

The following warnings were emitted during compilation:

warning: cc: error: ‘-march=x86-64’: ISA string must begin with rv32 or rv64

error: failed to run custom build command for `sys-info v0.9.1`

Caused by:
  process didn't exit successfully: `/home/debian/rustup/src/rustup-1.25.2/target/release/build/sys-info-1a75f39fa2e70555/build-script-build` (exit status: 1)
  --- stdout
  TARGET = Some("riscv64gc-unknown-linux-gnu")
  OPT_LEVEL = Some("3")
  HOST = Some("riscv64gc-unknown-linux-gnu")
  CC_riscv64gc-unknown-linux-gnu = None
  CC_riscv64gc_unknown_linux_gnu = None
  HOST_CC = None
  CC = None
  CFLAGS_riscv64gc-unknown-linux-gnu = None
  CFLAGS_riscv64gc_unknown_linux_gnu = None
  HOST_CFLAGS = None
  CFLAGS = Some("-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection")
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = None
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-march=rv64gc" "-mabi=lp64d" "-mcmodel=medany" "-march=x86-64" "-mtune=generic" "-O2" "-pipe" "-fno-plt" "-fexceptions" "-Wp,-D_FORTIFY_SOURCE=2" "-Wformat" "-Werror=format-security" "-fstack-clash-protection" "-fcf-protection" "-o" "/home/debian/rustup/src/rustup-1.25.2/target/release/build/sys-info-73bd6f2e2f8646f5/out/c/linux.o" "-c" "c/linux.c"
  cargo:warning=cc: error: ‘-march=x86-64’: ISA string must begin with rv32 or rv64
  exit status: 1

  --- stderr


  error occurred: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-march=rv64gc" "-mabi=lp64d" "-mcmodel=medany" "-march=x86-64" "-mtune=generic" "-O2" "-pipe" "-fno-plt" "-fexceptions" "-Wp,-D_FORTIFY_SOURCE=2" "-Wformat" "-Werror=format-security" "-fstack-clash-protection" "-fcf-protection" "-o" "/home/debian/rustup/src/rustup-1.25.2/target/release/build/sys-info-73bd6f2e2f8646f5/out/c/linux.o" "-c" "c/linux.c" with args "cc" did not execute successfully (status code exit status: 1).

So it looks like x86-64 is hard coded for some reason?
Unfortunately I’m not familiar with the build system for rust, so I’m pretty clueless to what is actually causing this, which library and where. I’ve spent about an hour on and off looking at sys-info and rustup, but I don’t see where extra march and mtune are coming from.

You need to set both CC_RISCV64G_UNKNOWN_LINUX_GNU and CARGO_TARGET_RISCV64G_UNKNOWN_LINUX_GNU_LINKER to a C compiler capable of building for riscv. The former for building C code for riscv64 and the latter for linking the final executable. Neither rustc nor the cc crate attempt to automatically detect a cross-compilation toolchain.

Oh I didn't even clock that it's trying to cross compile, despite it having CC everywhere.

Funny thing is, I'm not cross compiling, I'm building for RISC-V on RISC-V hardware. So the question still remains, what is putting in the x86 arguments?
There's two other packages it's trying to build with the same error. So I'm assuming that it's an issue with those, but I look at the source and I don't see anything that would cause this issue.

I missed that your host is riscv too. Is it possible that you have CFLAGS set or that makedeb sets it? The build script says that it is set to -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection, which hard codes x86_64.

1 Like

Don't use makedev.

From the output it appears to be incorrectly setting an environment variable

CFLAGS = Some("-march=x86-64

Quick look gives bug makedeb will not build packages on arm. Can only expect worse for risc-v.

Alternative is to delve into makedev's bash source and fix it.


Note also I'm not sure rustup is right/intended (but not one of the devs) for being installed as root (the system. In "/root" should be fine.)

Dang. My ambition with this endeavour was to actually use makedeb for obtaining some software that isn't found in apt.

Thanks for the heads up about the issues with arm. I'll have dig around see if it's an easy fix or not, now that I know what's causing the issue.

Thanks all.

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.