1

cargo contract build works just fine and produces the correct outputs in the /target folder.

Running cargo test however throws the following error:

error: failed to run custom build command for `wasm-opt-sys v0.113.0`

Caused by:
  process didn't exit successfully: `/Users/test_user/Dev/INK/flipper/target/debug/build/wasm-opt-sys-3a19b50779e5ebb2/build-script-build` (exit status: 1)
  --- stdout
  TARGET = Some("x86_64-apple-darwin")
  HOST = Some("x86_64-apple-darwin")
  cargo:rerun-if-env-changed=CXX_x86_64-apple-darwin
  CXX_x86_64-apple-darwin = None
  cargo:rerun-if-env-changed=CXX_x86_64_apple_darwin
  CXX_x86_64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CXX
  HOST_CXX = None
  cargo:rerun-if-env-changed=CXX
  CXX = None
  running: "c++" "--version"
  exit status: 0
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  RUSTC = Some("/Users/test_user/.rustup/toolchains/stable-x86_64-apple-darwin/bin/rustc")
  cargo:rerun-if-env-changed=CXXFLAGS_x86_64-apple-darwin
  CXXFLAGS_x86_64-apple-darwin = None
  cargo:rerun-if-env-changed=CXXFLAGS_x86_64_apple_darwin
  CXXFLAGS_x86_64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CXXFLAGS
  HOST_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  cargo:CXXBRIDGE_PREFIX=wasm-opt-sys
  cargo:CXXBRIDGE_LINKS=binaryen
  cargo:CXXBRIDGE_DIR0=/Users/test_user/Dev/INK/flipper/target/debug/build/wasm-opt-sys-029508906017695d/out/cxxbridge/include
  cargo:CXXBRIDGE_DIR1=/Users/test_user/Dev/INK/flipper/target/debug/build/wasm-opt-sys-029508906017695d/out/cxxbridge/crate
  cargo:CXXBRIDGE_DIR2=/Users/test_user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-opt-sys-0.113.0/binaryen/src
  cargo:CXXBRIDGE_DIR3=/Users/test_user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-opt-sys-0.113.0/binaryen/src/tools
  cargo:CXXBRIDGE_DIR4=/Users/test_user/Dev/INK/flipper/target/debug/build/wasm-opt-sys-029508906017695d/out
  TARGET = Some("x86_64-apple-darwin")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-apple-darwin")
  cargo:rerun-if-env-changed=CXX_x86_64-apple-darwin
  CXX_x86_64-apple-darwin = None
  cargo:rerun-if-env-changed=CXX_x86_64_apple_darwin
  CXX_x86_64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CXX
  HOST_CXX = None
  cargo:rerun-if-env-changed=CXX
  CXX = None
  running: "c++" "--version"
  exit status: 0
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  RUSTC = Some("/Users/test_user/.rustup/toolchains/stable-x86_64-apple-darwin/bin/rustc")
  cargo:rerun-if-env-changed=CXXFLAGS_x86_64-apple-darwin
  CXXFLAGS_x86_64-apple-darwin = None
  cargo:rerun-if-env-changed=CXXFLAGS_x86_64_apple_darwin
  CXXFLAGS_x86_64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CXXFLAGS
  HOST_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "--target=x86_64-apple-darwin" "-mmacosx-version-min=10.7" "-I" "/Users/test_user/Dev/INK/flipper/target/debug/build/wasm-opt-sys-029508906017695d/out/cxxbridge/include" "-I" "/Users/test_user/Dev/INK/flipper/target/debug/build/wasm-opt-sys-029508906017695d/out/cxxbridge/crate" "-I" "/Users/test_user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-opt-sys-0.113.0/binaryen/src" "-I" "/Users/test_user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-opt-sys-0.113.0/binaryen/src/tools" "-I" "/Users/test_user/Dev/INK/flipper/target/debug/build/wasm-opt-sys-029508906017695d/out" "-Wall" "-Wextra" "-std=c++17" "-Wno-unused-parameter" "-DTHROW_ON_FATAL" "-o" "/Users/test_user/Dev/INK/flipper/target/debug/build/wasm-opt-sys-029508906017695d/out/fc3ac4579f2123d0-lib.rs.o" "-c" "/Users/test_user/Dev/INK/flipper/target/debug/build/wasm-opt-sys-029508906017695d/out/cxxbridge/sources/wasm-opt-sys/src/lib.rs.cc"

The error looks like above looks like it's related to the C++ compiler but I've got another older ink! flipper contract on my machine where cargo test works just fine.

Has anyone got any ideas what could be the issue?

cargo contract --version
cargo-contract-contract 3.2.0-unknown-x86_64-apple-darwin

rustc --version
rustc 1.73.0 (cc66ad468 2023-10-03)

1 Answer 1

1

It turns out the issue was that the build scripts that were running during compilation were by default targeting -mmacosx-version-min=10.7 which meant that some features were not available.

The fix was to add the following environment variable:

export MACOSX_DEPLOYMENT_TARGET=10.13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.