Add wasi-emulated-mman cargo feature#3093
Add wasi-emulated-mman cargo feature#3093GregoryConrad wants to merge 4 commits intorust-lang:masterfrom GregoryConrad:emulated-mman-feat
Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @JohnTitor (or someone else) soon. Please see the contribution instructions for more information. |
|
As mentioned in #3097 (comment), we don't accept any platform-specific feature. |
|
@JohnTitor Ok, then what is the best course of action here? Remove the cargo feature (but keep my additions without the feature check), and if someone uses libc without the proper wasi-libc compilation flags enabled, they will just get linking/build failures? Edit: I just removed the feature and added everything to the global namespace. If someone doesn't explicitly enable wasi-libc's emulated mman, they will just get compile/link build issues. |
|
It should be separated into another crate as it may require additional setup as you said. The libc crate should be minimal to be usable on many hosts/targets. |
Fixes #3091 by adding a
wasi-emulated-mmancargo feature that adds bindings forwasi-libc's emulated mman.I am not sure if I implemented this completely correctly; feedback would be highly appreciated!
Some general comments/questions:
mmap64here, as I was unsure how to handle C's#define mmap64 mmap. I only started learning Rust a couple months ago so I am not sure what would be analogous here._GNU_SOURCEand_BSD_SOURCEconditional includes in the C header, so I included the relevant bindings in the hopes that I could get feedback on that from someone here.The unix/linux-likeI failed to realize theMAP_FAILEDis implemented aspub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;, which confused me. Themman.hinwasi-libcis#define MAP_FAILED ((void *) -1). What is the correct rust binding for this constant?!0is just the bitwise operator; all set here.libc-test/semver/wasi.txt?CC="clang ... --sysroot=..." cargo build --target="...")? Or through some different mechanism?