-
Notifications
You must be signed in to change notification settings - Fork 533
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
basic wasm support #331
basic wasm support #331
Conversation
While likely providing only incomplete support for WebAssembly, this commit opens up chrono for use on the wasm32 architecture.
Nice! Thank you, I especially appreciate how tiny this commit is and that it has real tests. The rustwasm community seems like they're doing amazing work to make this so readable. I haven't been following that community super closely, though, by accepting this will I be accidentally ruling out stdweb, or are they compatible now? If they're not compatible, could you put the constructors behind a |
I'll verify but I believe it is compatible with Finally got CI to pass, I have to admit I was a bit confused so let me know if there's a better way to get it running on the right matrix jobs. |
Okay after testing with
We can easily fix 3. by conditioning on I believe 4. is actually not actually a I'll confirm by ensuring the stdweb |
Thanks! Do you have the code/steps you used to verify that just so that I understand? I'm mostly confused about how using |
Sorry to be clear - situation 1. is broken by this PR presently (as shown in situation 3.) however it is easily fixed by changing all our conditional compilation to check for Current master:
This branch:
As the remaining panic seems to be due to cargo web I am wondering whether we want to keep the runtime panic or detect cargo web + |
As far as my testing methodology, for In |
koute/cargo-web#92 appears to be the cargo-web issue for |
The other option is that it's possible to trigger a compile time warning through a bit of hackery - https://internals.rust-lang.org/t/pre-rfc-add-compile-warning-macro/9370/7
Perhaps that is better as once the |
@quodlibetor any thoughts on keeping existing panic at runtime vs warning or error at compile time? |
Ah, yeah that seems like a bug in the ecosystem that should just be fixed upstream, similar to if some other library replaced an allocator or something, I don't think that we should add a warning or compile-time error to chrono, despite the fact that I'd rather not include code that I know can break. So I guess:
|
Thanks! I got emscripten working for myself and verified for my own sanity that this doesn't regress that. I'll release this over the weekend! Thanks for pushing this through! |
Perfect! I had issues getting |
@quodlibetor ooof sorry about the commit spam after being merged into master - had I known you were going to merge as is I would have squashed all the commits where I was trying to get travis to pass :) |
haha no worries! If I had realized you would be interested in doing that I would have waited :-) |
|
Are you running with wasm-bindgen? I do not know why it is happening, it seems to work for me. |
I have now also followed this setup using wasm-pack and wasm-bindgen, and as soon as I add
|
The problem is that the time crate does not yet implement get_time() for target_arch="wasm32", as you can see here: https://docs.rs/time/0.1.42/src/time/sys.rs.html#102 I am now using stdweb to get the time from javascript
|
previous PRs toward wasm support appear stuck ( #287 and #286 - the refactor it depended on ).
I built on the essentials of the work by @jjpe, fixing the local timezone support and adding tests.