nagisa / rust_libloading

Bindings around the platform's dynamic library loading primitives with greatly improved memory safety.

Home Page:https://docs.rs/libloading

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problems during cross-compilation

piertoni opened this issue · comments

Hi,
I have a problem trying to cross-compile a project to arm, in fact there is an option -m64 tha is passed to arm-linux-gnueabihf-gcc that is not supported:

cargo build output:

   Compiling libloading v0.5.2
   Compiling crossbeam-utils v0.7.2
   Compiling serde v1.0.195
The following warnings were emitted during compilation:

warning: arm-linux-gnueabihf-gcc: error: unrecognized command-line option ‘-m64’

error: failed to run custom build command for `libloading v0.5.2`

Caused by:
  process didn't exit successfully: `/home/pp/projects/xgate-greengrass-rust/target/debug/build/libloading-09b69f6415ab871a/build-script-build` (exit status: 1)
  --- stdout
  cargo:rustc-link-lib=dl
  TARGET = Some("x86_64-unknown-linux-gnu")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
  CC_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
  CC_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = Some("/usr/bin/arm-linux-gnueabihf-gcc")
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  running: "/usr/bin/arm-linux-gnueabihf-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-o" "/home/pp/projects/xgate-greengrass-rust/target/debug/build/libloading-66b6f9ef42389167/out/src/os/unix/global_static.o" "-c" "src/os/unix/global_static.c"
  cargo:warning=arm-linux-gnueabihf-gcc: error: unrecognized command-line option ‘-m64’

  exit status: 1

  --- stderr


  error occurred: Command "/usr/bin/arm-linux-gnueabihf-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-o" "/home/pp/projects/xgate-greengrass-rust/target/debug/build/libloading-66b6f9ef42389167/out/src/os/unix/global_static.o" "-c" "src/os/unix/global_static.c" with args "arm-linux-gnueabihf-gcc" did not execute successfully (status code exit status: 1).


warning: build failed, waiting for other jobs to finish...

My .cargo/config.toml contains the following:

[build]
target = "armv7-unknown-linux-gnueabihf"

[target.armv7-unknown-linux-gnueabihf]
linker = "rust-lld"

Operating system is Linux Mint

uname -r
5.15.0-67-generic

Cargo.toml file contains:

[package]
name = "test-greengrass-rust"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
aws_greengrass_core_rust = "0.1.37"
log = "0.4.20"

Any help would be appreciated, thanks!

Not-a-bug. You set up your environment in a way that results in:

TARGET = Some("x86_64-unknown-linux-gnu")
CC = Some("/usr/bin/arm-linux-gnueabihf-gcc")

which inherently makes little sense as a combination within a single build of a crate. If you read the list of the environment variables in the error message carefully you should be able to figure out a correct way to set up an environment such that the build succeeds.

Please keep in mind that v0.5.2 is 4 years old. Consider upgrading or having your dependencies upgrade their dependencies.