boringtun icon indicating copy to clipboard operation
boringtun copied to clipboard

error: failed to run custom build command for `ring v0.16.20` while cross compiling

Open fscarmen opened this issue 3 years ago • 5 comments

I cross compiled BoringTun on amd64 linux.

I have run rustup target add x86_64-apple-darwin before.

It was successful to compile "x86_64-unknown-linux-gnu" on AMD64 machine and " x86_64-apple-darwin" on MacBook macOS.

However. It was failed to compile " x86_64-apple-darwin" on AMD64.

It means static compilation is OK on each system. But could not be cross compiled.

image

root@srv17612:~/boringtun# $HOME/.cargo/bin/cargo build --bin boringtun-cli --release --target x86_64-apple-darwin
   Compiling cfg-if v1.0.0
   Compiling lazy_static v1.4.0
   Compiling smallvec v1.8.0
   Compiling autocfg v1.1.0
   Compiling once_cell v1.9.0
   Compiling scopeguard v1.1.0
   Compiling bitflags v1.3.2
   Compiling ansi_term v0.12.1
   Compiling spin v0.5.2
   Compiling pin-project-lite v0.2.8
   Compiling unicode-width v0.1.9
   Compiling ip_network v0.4.1
   Compiling itoa v1.0.1
   Compiling untrusted v0.7.1
   Compiling ip_network_table-deps-treebitmap v0.5.0
   Compiling hex v0.4.3
   Compiling untrusted v0.9.0
   Compiling boxfnonce v0.1.1
   Compiling strsim v0.8.0
   Compiling vec_map v0.8.2
   Compiling base64 v0.13.0
   Compiling libc v0.2.117
   Compiling tracing-core v0.1.22
   Compiling sharded-slab v0.1.4
   Compiling memoffset v0.6.5
   Compiling log v0.4.14
   Compiling crossbeam-utils v0.8.7
   Compiling parking_lot_core v0.9.1
   Compiling thread_local v1.1.4
   Compiling lock_api v0.4.6
   Compiling textwrap v0.11.0
   Compiling ip_network_table v0.2.0
   Compiling ring v0.16.20
error: failed to run custom build command for `ring v0.16.20`

Caused by:
  process didn't exit successfully: `/root/boringtun/target/release/build/ring-660027d888985dc6/build-script-build` (exit status: 101)
  --- stdout
  OPT_LEVEL = Some("3")
  TARGET = Some("x86_64-apple-darwin")
  HOST = Some("x86_64-unknown-linux-gnu")
  CC_x86_64-apple-darwin = None
  CC_x86_64_apple_darwin = None
  TARGET_CC = None
  CC = None
  CROSS_COMPILE = None
  CFLAGS_x86_64-apple-darwin = None
  CFLAGS_x86_64_apple_darwin = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2,sse3,ssse3")

  --- stderr
  running "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "include" "-Wall" "-Wextra" "-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" "-gfull" "-DNDEBUG" "-c" "-o/root/boringtun/target/x86_64-apple-darwin/release/build/ring-1ed844cb9f4b9d8e/out/aesni-x86_64-macosx.o" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesni-x86_64-macosx.S"
  cc: error: x86_64: No such file or directory
  cc: error: unrecognized debug output level ‘full’
  cc: error: unrecognized command line option ‘-arch’
  thread 'main' panicked at 'execution failed', /root/.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

fscarmen avatar Apr 23 '22 02:04 fscarmen

I think culprit is TARGET_CC = None. Try setting TARGET_CC via env variable, something like export TARGET_CC="x86_64-apple-darwin14-clang"

Lainera avatar Jun 02 '22 21:06 Lainera

@fscarmen did that work?

Noah-Kennedy avatar Jun 27 '22 19:06 Noah-Kennedy

@Noah-Kennedy no, having same issue, it doesnt help

spylogsster avatar Aug 16 '22 13:08 spylogsster

@spylogsster take a look at this: https://github.com/briansmith/ring/blob/main/BUILDING.md

Noah-Kennedy avatar Aug 16 '22 15:08 Noah-Kennedy

  CC_x86_64-apple-darwin = None
  CC_x86_64_apple_darwin = None
  TARGET_CC = None
  CC = None
  CROSS_COMPILE = None
  CFLAGS_x86_64-apple-darwin = None
  CFLAGS_x86_64_apple_darwin = None

Set the C compiler either using the env var or the .cargo/config entries. ring compiles C/asm code and needs (so far) a working C compiler. Also when cross compiling you need to set the linker to the target specific linker, again use the .cargo/config entry.

lu-zero avatar Aug 30 '22 07:08 lu-zero