rpmalloc-rs icon indicating copy to clipboard operation
rpmalloc-rs copied to clipboard

rpmalloc-sys fails to build for wasm target on Windows: fatal error: 'unistd.h' file not found

Open Boscop opened this issue 5 years ago • 1 comments

Not sure if this allocator is intended to also work for wasm, but in my frontend I need speed more than size (it's a UI for a desktop application), so I thought I'd try it.. But it fails to build for wasm:

error: failed to run custom build command for `rpmalloc-sys v0.1.3`

--- stdout
TARGET = Some("wasm32-unknown-unknown")
HOST = Some("x86_64-pc-windows-msvc")
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
running: "clang" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-DENABLE_PRELOAD=1" "-o" "D:\\project\\target\\wasm32-unknown-unknown\\debug\\build\\rpmalloc-sys-21068dcc5b7ecde5\\out\\rpmalloc.o" "-c" "C:\\Users\\me\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\rpmalloc-sys-0.1.3\\rpmalloc\\rpmalloc\\rpmalloc.c"
cargo:warning=C:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\rpmalloc-sys-0.1.3\rpmalloc\rpmalloc\rpmalloc.c:122:12: fatal error: 'unistd.h' file not found
cargo:warning=#  include <unistd.h>
cargo:warning=           ^~~~~~~~~~
cargo:warning=1 error generated.
exit code: 1

--- stderr


error occurred: Command "clang" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-DENABLE_PRELOAD=1" "-o" "D:\\project\\target\\wasm32-unknown-unknown\\debug\\build\\rpmalloc-sys-21068dcc5b7ecde5\\out\\rpmalloc.o" "-c" "C:\\Users\\me\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\rpmalloc-sys-0.1.3\\rpmalloc\\rpmalloc\\rpmalloc.c" with args "clang" did not execute successfully (status code exit code: 1).

Boscop avatar Feb 10 '20 18:02 Boscop

Currently this crate is not supporting WASM, would be nice to have support for it though and probably is possible to configure the underlying rpmalloc C library to work, with limited functionality, on WASM. PR welcome!

Though a bunch of functionality such as the thread memory pools wouldn't be needed, so nicest would be to have a good general single-threaded Rust-native allocator for WASM

repi avatar Feb 10 '20 18:02 repi