rust-bindgen icon indicating copy to clipboard operation
rust-bindgen copied to clipboard

cannot use <stdint.h> for wasm on macos

Open slmjkdbtl opened this issue 5 years ago • 2 comments

Input C/C++ Header

// test.h
#include <stdint.h>

Bindgen Invocation

// build.rs
bindgen::builder()
	.header("test.h")
	.generate()
	.expect("failed to bindgen");
cargo build --target wasm32-unknown-unknown
cargo build --target wasm32-unknown-emscripten

Actual Results

error: failed to run custom build command for `bindgen_test v0.1.0 (/Users/tga/Things/test/bindgen_test)`

Caused by:
  process didn't exit successfully: `/Users/tga/Things/test/bindgen_test/target/debug/build/bindgen_test-bd3ce1693b9e8628/build-script-build` (exit code: 101)
--- stderr
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/cdefs.h:784:2: error: Unsupported architecture
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:55:9: error: unknown type name '__int64_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:56:9: error: unknown type name '__int32_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:57:9: error: unknown type name '__int32_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:60:9: error: unknown type name '__uint32_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:61:9: error: unknown type name '__uint32_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:62:9: error: unknown type name '__uint64_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:68:9: error: unknown type name '__darwin_natural_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:70:9: error: unknown type name '__uint16_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:71:9: error: unknown type name '__int64_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:72:9: error: unknown type name '__int32_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:73:9: error: unknown type name '__uint32_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:74:9: error: unknown type name '__int32_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:75:9: error: unknown type name '__uint32_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:76:9: error: unknown type name '__uint32_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/machine/types.h:37:2: error: architecture not supported
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types/_intptr_t.h:32:9: error: unknown type name '__darwin_intptr_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/cdefs.h:784:2: error: Unsupported architecture, err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported, err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:55:9: error: unknown type name '__int64_t', err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:56:9: error: unknown type name '__int32_t', err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:57:9: error: unknown type name '__int32_t', err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:60:9: error: unknown type name '__uint32_t', err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:61:9: error: unknown type name '__uint32_t', err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:62:9: error: unknown type name '__uint64_t', err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:68:9: error: unknown type name '__darwin_natural_t', err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:70:9: error: unknown type name '__uint16_t', err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:71:9: error: unknown type name '__int64_t', err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:72:9: error: unknown type name '__int32_t', err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:73:9: error: unknown type name '__uint32_t', err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:74:9: error: unknown type name '__int32_t', err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:75:9: error: unknown type name '__uint32_t', err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types.h:76:9: error: unknown type name '__uint32_t', err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/machine/types.h:37:2: error: architecture not supported, err: true
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types/_intptr_t.h:32:9: error: unknown type name '__darwin_intptr_t', err: true
thread 'main' panicked at 'failed to bindgen: ()', build.rs:9:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected Results

no error

had the same error when trying to compile to aarch64-apple-ios, fixed by -arch arm64 and -isysroot {ios_sdk_location}, but not sure how to fix this for wasm

slmjkdbtl avatar Jul 07 '20 19:07 slmjkdbtl

It seems you may be missing some compiler flags that whatever wasm thing uses has, like -isystem /path/to/toolchain/include or such...

emilio avatar Jul 10 '20 16:07 emilio

@slmjkdbtl any updates?

pvdrz avatar Sep 21 '22 21:09 pvdrz

Closing due to lack of updates.

pvdrz avatar Oct 12 '22 00:10 pvdrz