-
Notifications
You must be signed in to change notification settings - Fork 17
Description
I am trying to compile some basic clipper functions to WASM, to use as a bridge to Javascript. This is on a Mac M1, which might have something to do with the issue I am seeing.
(FYI, I have compiled various other Rust code and crates to WASM without issue on this same M1 computer, so I think I have the basics down. Just not sure how to address this compiler error.)
When using the default Mac clang compiler, I get this error:
[INFO]: 🌀 Compiling to Wasm...
Compiling clipper-sys v0.7.2
The following warnings were emitted during compilation:warning: In file included from clipper/clipper.cpp:41:
warning: clipper/clipper.hpp:52:10: fatal error: 'vector' file not found
warning: #include
warning: ^~~~~~~~
warning: 1 error generated.error: failed to run custom build command for
clipper-sys v0.7.2Caused by:
process didn't exit successfully:/Users/rhead/git/fvtt-test-ccw/intersections/target/release/build/clipper-sys-6c959c9fe2b70968/build-script-build(exit status: 1)
--- stdout
cargo:rerun-if-changed=clipper
TARGET = Some("wasm32-unknown-unknown")
HOST = Some("aarch64-apple-darwin")
CXX_wasm32-unknown-unknown = None
CXX_wasm32_unknown_unknown = None
TARGET_CXX = None
CXX = None
CXXFLAGS_wasm32-unknown-unknown = None
CXXFLAGS_wasm32_unknown_unknown = None
TARGET_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-o" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/clipper/clipper.o" "-c" "clipper/clipper.cpp"
cargo:warning=In file included from clipper/clipper.cpp:41:
cargo:warning=clipper/clipper.hpp:52:10: fatal error: 'vector' file not found
cargo:warning=#include
cargo:warning= ^~~~~~~~
cargo:warning=1 error generated.
exit status: 1--- stderr
error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-o" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/clipper/clipper.o" "-c" "clipper/clipper.cpp" with args "clang" did not execute successfully (status code exit status: 1).
Error: Compiling your crate to WebAssembly failed
Caused by: failed to executecargo build: exited with exit status: 101
full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
I would guess that clang is trying to compile "clipper/clipper.hpp" as a c file, not a c++ file. But if so, I don't know why, and don't know how to fix it.
I also tried installing gcc in homebrew, and then forced it to use that compiler instead, i.e, by passing environmental variables to the compile script: CC=/opt/homebrew/bin/gcc-11 CXX=/opt/homebrew/bin/g++-11 ./build_wasm.sh
I still get a compile error, albeit a different one:
[INFO]: 🌀 Compiling to Wasm...
Compiling clipper-sys v0.7.2
error: failed to run custom build command forclipper-sys v0.7.2Caused by:
process didn't exit successfully:/Users/rhead/git/fvtt-test-ccw/intersections/target/release/build/clipper-sys-6c959c9fe2b70968/build-script-build(exit status: 101)
--- stdout
cargo:rerun-if-changed=clipper
TARGET = Some("wasm32-unknown-unknown")
HOST = Some("aarch64-apple-darwin")
CXX_wasm32-unknown-unknown = None
CXX_wasm32_unknown_unknown = None
TARGET_CXX = None
CXX = Some("/opt/homebrew/bin/g++-11")
CXXFLAGS_wasm32-unknown-unknown = None
CXXFLAGS_wasm32_unknown_unknown = None
TARGET_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = None
running: "/opt/homebrew/bin/g++-11" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-Wall" "-Wextra" "-o" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/clipper/clipper.o" "-c" "clipper/clipper.cpp"
exit status: 0
running: "/opt/homebrew/bin/g++-11" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-Wall" "-Wextra" "-o" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/clipper/wrapper.o" "-c" "clipper/wrapper.cpp"
exit status: 0
AR_wasm32-unknown-unknown = None
AR_wasm32_unknown_unknown = None
TARGET_AR = None
AR = None
CROSS_COMPILE = None
running: "ar" "cq" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/libclipper.a" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/clipper/clipper.o" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/clipper/wrapper.o"
exit status: 0
running: "ar" "s" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/libclipper.a"
exit status: 0
cargo:rustc-link-lib=static=clipper
cargo:rustc-link-search=native=/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out
CXXSTDLIB_wasm32-unknown-unknown = None
CXXSTDLIB_wasm32_unknown_unknown = None
TARGET_CXXSTDLIB = None
CXXSTDLIB = None
cargo:rustc-link-lib=stdc++--- stderr
thread 'main' panicked at 'not implemented: target_os: unknown, target_env: ', /Users/rhead/.cargo/registry/src/github.com-1ecc6299db9ec823/clipper-sys-0.7.2/build.rs:23:14
note: run withRUST_BACKTRACE=1environment variable to display a backtrace
Error: Compiling your crate to WebAssembly failed
Caused by: failed to executecargo build: exited with exit status: 101
full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
Any insights would be much appreciated! Thanks!