briansmith / ring

Safe, fast, small crypto using Rust
Other
3.7k stars 698 forks source link

Build for target via buildroot picks incorrect target (picks host instead) #1598

Closed flukejones closed 1 year ago

flukejones commented 1 year ago
error: failed to run custom build command for `ring v0.16.20`

Caused by:
  process didn't exit successfully: `/home/luke/Projects/JTE/buildroot/output/build/slint-master/target/release/build/ring-d4ff9e11746ad4cc/build-script-build` (exit status: 101)
  --- stdout
  OPT_LEVEL = Some("0")
  TARGET = Some("x86_64-unknown-linux-gnu")
  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("/home/luke/Projects/JTE/buildroot/output/host/bin/arm-jte-linux-gnueabihf-gcc")
  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 = Some("-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -O3 -g0 -D_FORTIFY_SOURCE=1")
  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")

  --- stderr
  running "/home/luke/Projects/JTE/buildroot/output/host/bin/arm-jte-linux-gnueabihf-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-D_LARGEFILE_SOURCE" "-D_LARGEFILE64_SOURCE" "-D_FILE_OFFSET_BITS=64" "-O3" "-g0" "-D_FORTIFY_SOURCE=1" "-I" "include" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-DNDEBUG" "-c" "-o/home/luke/Projects/JTE/buildroot/output/build/slint-master/target/release/build/ring-96294aa858b90b60/out/aesni-x86_64-elf.o" "/home/luke/Projects/JTE/buildroot/output/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesni-x86_64-elf.S"
  arm-jte-linux-gnueabihf-gcc.br_real: error: unrecognized command-line option ‘-m64’
  thread 'main' panicked at 'execution failed', /home/luke/Projects/JTE/buildroot/output/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/build.rs:656:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
make: *** [package/pkg-generic.mk:293: /home/luke/Projects/JTE/buildroot/output/build/slint-master/.stamp_built] Error 101

I was trying to build the skia rendering backend for slint UI, but it is impossible because a transitive dependency of skia relies on ring and the above happens.

briansmith commented 1 year ago

CC = Some("/home/luke/Projects/JTE/buildroot/output/host/bin/arm-jte-linux-gnueabihf-gcc")

When cross-compiling, use TARGET_CC and similar, not CC and the like. See ring's GitHub Actions configuration and the shell scripts it uses to see examples of working cross-compilation configurations. I hope we make this work easier (automatic) in the future.