-
Notifications
You must be signed in to change notification settings - Fork 20
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
Support compilation to wasm target #15
base: master
Are you sure you want to change the base?
Conversation
Hi, @mdrokz , thank you for your PR! Yet, I do not understand the purpose of those changes: it does not returns actual hostname (due to linkage issue you mentioned) and |
Hi, |
Hey! I'm not sure if that is the approach I want to follow: if some particular target is not supported, I personally would prefer to learn about that fact during the compilation. I can imagine it will be very confusing to figure out in runtime why returned value is very different from the actual system hostname. Even returning some blank error like On the other hand, with compilation failure each of the crate consumers can choose what approach to use: not provide support for this target at all or use some "default" value instead with conditional compilation like in the following pseudo-code (sorry, writing from my head, might have some naive mistakes): #[cfg(any(target_family="unix", target_family="windows"))]
use hostname::get as get_hostname;
#[cfg(not(any(target_family="unix", target_family="windows")))]
fn get_hostname() -> io::Result<OsString> {
"unknown".into()
} Anyway, so far I'm inclined not to accept this PR, but I'm open for further discussion, of course, and having a wasm support would also be great. |
Changes
wasm
mod for supportingget
andset
API forwasi
target.get
method for hostname will always returns static stringwasihost
- gethostname linkage fails, even though present in wasi-libc WebAssembly/wasi-libc#196 (comment)set
method for hostname is emulated