-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustbuild: Enable WebAssembly backend by default #46115
Conversation
This is the successor of #45905 where now that everything's in tree it's time to add some tests! This PR will ensure that the wasm32-unknown-unknown target does not regress (keeps building) and also enables all of our distributed compilers to build for wasm32 architectures by default. This PR also adds a rustup target, so after this lands it will be possible to do:
and then you're ready to experiment! After this PR I'll work on adding a builder that starts running some tests so we can get some regression testing there. |
r? @kennytm |
LGTM. @bors r+ |
📌 Commit 2e54755 has been approved by |
Doesn't this need LLVM 5.0? Or was that requirement dropped? |
Hmm I guess it never was a hard requirement really, but there was just no testing on it... |
2e54755
to
969c9ac
Compare
re-r? @kennytm The support added for documenting all platforms when documenting the standard library was broken with wasm b/c it didn't share enough in common to compile the unix/windows "tiny shims". I ended up using |
r=me after tidy fix.
|
969c9ac
to
dae3bb3
Compare
@bors: r=kennytm |
📌 Commit dae3bb3 has been approved by |
⌛ Testing commit dae3bb3de9602cf5d5cc8cfe61cd1059c33777dd with merge 4d6744e7de8a198b177f6f7b5d4c251cd6a730ad... |
💔 Test failed - status-travis |
Cannot document libstd for
|
src/libstd/sys/mod.rs
Outdated
|
||
#[cfg(dox)] | ||
cfg_if! { | ||
if #[cfg(unix)] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be #[cfg(any(unix, target_os = "redox"))]
I guess.
But it also needs #[cfg(target_os = "redox")] use os::linux as platform;
.
This commit alters how we compile LLVM by default enabling the WebAssembly backend. This then also adds the wasm32-unknown-unknown target to get compiled on the `cross` builder and distributed through rustup. Tests are not yet enabled for this target but that should hopefully be coming soon!
dae3bb3
to
48996f9
Compare
@bors: r=kennytm |
📌 Commit 48996f9 has been approved by |
rustbuild: Enable WebAssembly backend by default This commit alters how we compile LLVM by default enabling the WebAssembly backend. This then also adds the wasm32-unknown-unknown target to get compiled on the `cross` builder and distributed through rustup. Tests are not yet enabled for this target but that should hopefully be coming soon!
☀️ Test successful - status-appveyor, status-travis |
I found that function with return type
front-end caller let wasmInstance = "";
let addRust = "";
fetchAndInstantiate('small-add.wasm', {}).then(instance => {
wasmInstance = instance;
console.log("wasmInstance instantiated in line 11");
sayHello = wasmInstance.exports.say_hello;
console.log("function sayHello instantiated in line 17");
console.log(sayHello());
}); back-end callee: #[no_mangle]
pub fn say_hello() -> &'static str {
"hello, world! hello, rust wasm!"
} |
@huangjj27 That's on purpose and is simply the way Rust works. Strings, Vec, slices, etc. are returned by writing a pointer and additional data to a caller-allocated memory buffer, from which the caller has to read it after calling the function. Wasm has no idea about the layout of Strings. @killercup and I are working on a bit of JS boilerplate to handle those cases easily in wasm-experiments |
Rustdoc has for some time now used the "everybody loops" pass in the compiler to avoid typechecking and otherwise avoid looking at implementation details. In rust-lang#46115 the placement of this pass was pushed back in the compiler to after macro expansion to ensure that it works with macro-expanded code as well. This in turn caused the regression in rust-lang#46271. The bug here was that the resolver was producing `def_id` instances for "possibly unused extern crates" which would then later get processed during typeck to actually issue lint warnings. The problem was that *after* resolution these `def_id` nodes were actually removed from the AST by the "everybody loops" pass. This later, when we tried to take a look at `def_id`, caused the compiler to panic. The fix applied here is a bit of a heavy hammer which is to just, in this one case, ignore the `extern crate` lints if the `def_id` looks "bogus" in any way (basically if it looks like the node was removed after resolution). The real underlying bug here is probably that the "everybody loops" AST pass is being stressed to much beyond what it was originally intended to do, but this should at least fix the ICE for now... Closes rust-lang#46271
rustc: Filter out bogus extern crate warnings Rustdoc has for some time now used the "everybody loops" pass in the compiler to avoid typechecking and otherwise avoid looking at implementation details. In rust-lang#46115 the placement of this pass was pushed back in the compiler to after macro expansion to ensure that it works with macro-expanded code as well. This in turn caused the regression in rust-lang#46271. The bug here was that the resolver was producing `def_id` instances for "possibly unused extern crates" which would then later get processed during typeck to actually issue lint warnings. The problem was that *after* resolution these `def_id` nodes were actually removed from the AST by the "everybody loops" pass. This later, when we tried to take a look at `def_id`, caused the compiler to panic. The fix applied here is a bit of a heavy hammer which is to just, in this one case, ignore the `extern crate` lints if the `def_id` looks "bogus" in any way (basically if it looks like the node was removed after resolution). The real underlying bug here is probably that the "everybody loops" AST pass is being stressed to much beyond what it was originally intended to do, but this should at least fix the ICE for now... Closes rust-lang#46271
This commit alters how we compile LLVM by default enabling the WebAssembly
backend. This then also adds the wasm32-unknown-unknown target to get compiled
on the
cross
builder and distributed through rustup. Tests are not yet enabledfor this target but that should hopefully be coming soon!