Skip to content
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

Failing build with html5ever #4

Closed
nuxeh opened this issue Apr 21, 2019 · 6 comments
Closed

Failing build with html5ever #4

nuxeh opened this issue Apr 21, 2019 · 6 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@nuxeh
Copy link

nuxeh commented Apr 21, 2019

Hi,

I'm having issues building with nix for crates with html5ever as a dependency.

https://github.com/nuxeh/crate2nix-test is an example repo with a default.nix generated by crate2nix 0.3.0-beta.0

The build seems to fail due to the missing extern crate, new_debug_unreachable:

error[E0463]: can't find crate for `debug_unreachable`
  --> src/lib.rs:10:1
   |
10 | extern crate debug_unreachable;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

I've done some debugging but haven't been able to track down what the issue is. The build order differs, and besides that, the only difference i can see is that the rustc invocations differ in the output directory, compared with building with cargo:

Running rustc --crate-name futf src/lib.rs --crate-type lib -C opt-level=3 -C codegen-units=4 --edition 2015 -C metadata=7a698c1757 -C extra-filename=-7a698c1757 --out-dir target/lib --emit=dep-info,link -L dependency=target/deps --extern mac=/nix/store/bjcw280v92drg93d89zpkh997xljfl89-rust_mac-0.1.1/lib/libmac-c77a325080.rlib --extern new_debug_unreachable=/nix/store/qz5ffk70ibllz27awjnpp9v7rbcrxnq5-rust_new_debug_unreachable-1.0.3/lib/libnew_debug_unreachable-6437ae92c0.rlib --cap-lints allow --color always

--out-dir target/lib

Running `rustc --crate-name futf /home/ed/.cargo/registry/src/github.com-1ecc6299db9ec823/futf-0.1.4/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=b65310681f505b82 -C extra-filename=-b65310681f505b82 --out-dir /home/ed/git/url-bot-rs/target/debug/deps -L dependency=/home/ed/git/url-bot-rs/target/debug/deps --extern mac=/home/ed/git/url-bot-rs/target/debug/deps/libmac-705013cbc305aca9.rlib --extern debug_unreachable=/home/ed/git/url-bot-rs/target/debug/deps/libdebug_unreachable-6884cd8b03bd695e.rlib --cap-lints allow`

--out-dir /home/ed/git/url-bot-rs/target/debug/deps

Thanks.

@kolloch
Copy link
Collaborator

kolloch commented Apr 22, 2019

Thanks for reporting this including a repo for reproducing the error and your detailed report!

I see a further difference:

--extern new_debug_unreachable=/nix/store/qz5ffk70ibllz27awjnpp9v7rbcrxnq5-rust_new_debug_unreachable-1.0.3/lib/libnew_debug_unreachable-6437ae92c0.rlib

vs

--extern debug_unreachable=/home/ed/git/url-bot-rs/target/debug/deps/libdebug_unreachable-6884cd8b03bd695e.rlib

Which explains why the library is available as debug_unreachable in the second case...

I'll investigate further...

@kolloch kolloch self-assigned this Apr 22, 2019
@kolloch kolloch added the bug Something isn't working label Apr 22, 2019
@kolloch kolloch added this to the 0.3 milestone Apr 22, 2019
@kolloch
Copy link
Collaborator

kolloch commented Apr 22, 2019

I suspect this is down to the fact that the crate is called new_debug_unreachable but the library debug_unreachable: https://github.com/mbrubeck/rust-debug-unreachable/blob/fork/Cargo.toml#L12-L14

[lib]
name = "debug_unreachable"
path = "src/lib.rs"

That is exposed in the cargo metadata output:

{
        "id": "futf 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
        "dependencies": [
          "mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
          "new_debug_unreachable 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)"
        ],
        "deps": [
          {
            "name": "mac",
            "pkg": "mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)"
          },
          {
            "name": "debug_unreachable",
            "pkg": "new_debug_unreachable 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)"
          }
        ],
        "features": []
      },
  {
      "name": "new_debug_unreachable",
      "version": "1.0.3",
      "id": "new_debug_unreachable 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
      "license": "MIT",
      "license_file": null,
      "description": "panic in debug, intrinsics::unreachable() in release (fork of debug_unreachable)",
      "source": "registry+https://github.com/rust-lang/crates.io-index",
      "dependencies": [],
      "targets": [
        {
          "kind": [
            "lib"
          ],
          "crate_types": [
            "lib"
          ],
          "name": "debug_unreachable",
          "src_path": "/home/peter/.cargo/registry/src/github.com-1ecc6299db9ec823/new_debug_unreachable-1.0.3/src/lib.rs",
          "edition": "2015"
        },
        {
          "kind": [
            "example"
          ],
          "crate_types": [
            "bin"
          ],
          "name": "simple",
          "src_path": "/home/peter/.cargo/registry/src/github.com-1ecc6299db9ec823/new_debug_unreachable-1.0.3/examples/simple.rs",
          "edition": "2015"
        },
        {
          "kind": [
            "test"
          ],
          "crate_types": [
            "bin"
          ],
          "name": "check",
          "src_path": "/home/peter/.cargo/registry/src/github.com-1ecc6299db9ec823/new_debug_unreachable-1.0.3/tests/check.rs",
          "edition": "2015"
        }
      ],
// ...

Now I need to investigate on how to make this work with buildRustCrate. Renaming the crate alone does not work but we can additionally provide an explicit source:

diff --git a/default.nix b/default.nix
index de58004..50fb7ea 100644
--- a/default.nix
+++ b/default.nix
@@ -235,10 +235,14 @@ rec {
             };
         "new_debug_unreachable 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)"
             = buildRustCrate {
-                crateName = "new_debug_unreachable";
+                crateName = "debug_unreachable";
                 version = "1.0.3";
                 edition = "2015";
                 sha256 = "1lxbd0n9gwvzg41bxiij0c28g1sp1jhp4h1rh10qisc8viyhsdj0";
+                src = builtins.fetchGit {
+                    url = "https://github.com/mbrubeck/rust-debug-unreachable";
+                    rev = "e374f6990882871d62ddcd1d9964b26ac50c5c7e";
+                };
                 libPath = "src/lib.rs";
                 authors = [
                     "Matt Brubeck <mbrubeck@limpet.net>"

(Obviously, the source should be fetched from crates.io instead, this is just a proof of concept.)

With this fix, I run into a similar problem with the utf_8 crate, though, which exports the utf8 library.

I'll try to fix this today -- if that doesn't work out, you'll probably need to wait until at least next weekend :(

@kolloch
Copy link
Collaborator

kolloch commented Apr 22, 2019

Does this solve your problem?

Please continue to send me such awesome bug reports, @nuxeh!

@nuxeh
Copy link
Author

nuxeh commented Apr 22, 2019

@kolloch it does appear to have solved the problem for the test repo, but for my own project, https://github.com/nuxeh/url-bot-rs, there's still the following error, this time for cssparser:

Building src/lib.rs (cssparser)
Running rustc --crate-name cssparser src/lib.rs --crate-type lib -C opt-level=3 -C codegen-units=4 --edition 2015 -C metadata=15b8375349 -C extra-filename=-15b8375349 --out-dir target/lib --emit=dep-info,link -L dependency=target/deps --extern cssparser_macros=/nix/store/8yl9hhivlcpr1q485d9h9kywwlxiia91-rust_cssparser-macros-0.3.5/lib/libcssparser_macros-57e42b786a.so --extern dtoa_short=/nix/store/4v891ffdrzxa2yv547mn3dcdc7iqvak0-rust_dtoa-short-0.3.2/lib/libdtoa_short-77d68b4a44.rlib --extern itoa=/nix/store/adhj88qqyin8zf9bd10xqv1dsizv3bhr-rust_itoa-0.4.3/lib/libitoa-a6f76c7f27.rlib --extern matches=/nix/store/j3laann65lzck6lyg9bpjk7gjw9ihk2k-rust_matches-0.1.8/lib/libmatches-47ddbc585f.rlib --extern phf=/nix/store/qcvaa9ya6vgcrpmmyiq042a8jpb4niid-rust_phf-0.7.24/lib/libphf-95b8a51ebb.rlib --extern procedural_masquerade=/nix/store/rwzpk2qq99bkvr83hckj8akf6xq84dfy-rust_procedural-masquerade-0.1.6/lib/libprocedural_masquerade-e6f18a276f.rlib --extern smallvec=/nix/store/nh1i2602n3nphcrxmznrjbnvmpn747iq-rust_smallvec-0.6.9/lib/libsmallvec-99bacd0cdd.rlib --cap-lints allow -L /build/cssparser-0.24.1.tar.gz/target/build/cssparser.out --cfg rustc_has_pr45225 --color always
error: extern location for cssparser_macros does not exist: /nix/store/8yl9hhivlcpr1q485d9h9kywwlxiia91-rust_cssparser-macros-0.3.5/lib/libcssparser_macros-57e42b786a.so

error[E0463]: can't find crate for `cssparser_macros`
  --> src/lib.rs:73:14
   |
73 | #[macro_use] extern crate cssparser_macros;
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0463`.
builder for '/nix/store/dj2mwhaqg6yma100xscp0rx0s43h7zi8-rust_cssparser-0.24.1.drv' failed with exit code 1
cannot build derivation '/nix/store/378wm523mf1mscvbqc7vjhvy8n3hmdj8-rust_url-bot-rs-0.2.0.drv': 1 dependencies couldn't be built
error: build of '/nix/store/378wm523mf1mscvbqc7vjhvy8n3hmdj8-rust_url-bot-rs-0.2.0.drv' failed

So as far as i can tell, not out of the woods yet.

Thanks for looking at this, i'll certainly report anything else i find :)

@nuxeh
Copy link
Author

nuxeh commented Apr 22, 2019

Hmm, cssparser-macros seems to be a sub-crate within cssparser, I wonder if that has anything to do with this.

I can't imagine that that's uncommon, but it looks slightly suspicious for a normal Cargo project to me, just lib.rs and Cargo.toml.

https://github.com/servo/rust-cssparser/tree/master/macros

@kolloch
Copy link
Collaborator

kolloch commented Apr 22, 2019

I created #5 for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants