zotero / citeproc-rs

CSL processor in Rust.
https://cormacrelf.github.io/citeproc-wasm-demo/
Other
71 stars 12 forks source link

Wasm crate fails to build #18

Closed adomasven closed 4 years ago

adomasven commented 4 years ago

Attached is the build log:

adomas@paprika-laptop:~/zotero/citeproc-rs/crates/wasm
$ wasm-pack build
[...]
   Compiling datatest-derive v0.5.3-alpha.0 (https://github.com/cormacrelf/datatest?branch=test_type#e267a78d)
   Compiling ctor v0.1.10
   Compiling html5ever v0.24.0
   Compiling v_escape_derive v0.5.5
   Compiling strum_macros v0.15.0
   Compiling js-sys v0.3.30
   Compiling salsa v0.13.0
   Compiling v_escape v0.7.4
error[E0432]: unresolved import `crate::rustc_test::TestType`
   --> /home/adomas/.cargo/git/checkouts/datatest-8f1d8ca908a37906/e267a78/src/lib.rs:204:5
    |
204 | use crate::rustc_test::TestType;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `TestType` in the root

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /home/adomas/.cargo/git/checkouts/datatest-8f1d8ca908a37906/e267a78/src/lib.rs:1:1
  |
1 | #![feature(test)]
  | ^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /home/adomas/.cargo/git/checkouts/datatest-8f1d8ca908a37906/e267a78/src/lib.rs:2:1
  |
2 | #![feature(specialization)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /home/adomas/.cargo/git/checkouts/datatest-8f1d8ca908a37906/e267a78/src/lib.rs:3:1
  |
3 | #![feature(termination_trait_lib)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0560]: struct `rustc_test::TestDesc` has no field named `test_type`
   --> /home/adomas/.cargo/git/checkouts/datatest-8f1d8ca908a37906/e267a78/src/runner.rs:179:21
    |
179 |                     test_type: crate::test_type(desc.source_file),
    |                     ^^^^^^^^^ `rustc_test::TestDesc` does not have this field
    |
    = note: available fields are: `name`, `ignore`, `should_panic`, `allow_fail`

error[E0560]: struct `rustc_test::TestDesc` has no field named `test_type`
   --> /home/adomas/.cargo/git/checkouts/datatest-8f1d8ca908a37906/e267a78/src/runner.rs:224:17
    |
224 |                 test_type: crate::test_type(desc.source_file),
    |                 ^^^^^^^^^ `rustc_test::TestDesc` does not have this field
    |
    = note: available fields are: `name`, `ignore`, `should_panic`, `allow_fail`

error[E0560]: struct `rustc_test::TestDesc` has no field named `test_type`
   --> /home/adomas/.cargo/git/checkouts/datatest-8f1d8ca908a37906/e267a78/src/runner.rs:392:21
    |
392 |                     test_type: crate::test_type(desc.source_file),
    |                     ^^^^^^^^^ `rustc_test::TestDesc` does not have this field
    |
    = note: available fields are: `name`, `ignore`, `should_panic`, `allow_fail`

error: aborting due to 7 previous errors

Some errors have detailed explanations: E0432, E0554, E0560.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `datatest`.
warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit code: 101
cormacrelf commented 4 years ago

You need a newer nightly Rust, so rustup update nightly. datatest lives on the edge with the pretty unstable libtest API, which changed about a month ago. I'm running citeproc-rs off my PR branch from https://github.com/commure/datatest/pull/19 which accommodates that change. I really need to update the readme, sorry!

cormacrelf commented 4 years ago

Also it strikes me that it shouldn't be built at all in that configuration, apparently I made it a dependency instead of a dev-dependency.

cormacrelf commented 4 years ago

Actually, once that's fixed, you can even wasm-pack build on stable! As of stable 1.39.0, which was released earlier this month, the async/await syntax and Vec::new being a const fn are stable, so it really does go.

At the moment the demo's webpack config uses the nightly-only -Z config-profile to change opt-level for debug builds without affecting the whole workspace. But if you're only building a package with wasm-pack in release mode, opt-level is already correct and you don't need that. This is great news for reliable CI builds, which I'm looking into with #7 at the moment. However for development you still want datatest and hence nightly.

(Quick note: wasm-pack defies convention and builds in release mode by default. Mostly this is what you want, but it can be confusing.)