tract icon indicating copy to clipboard operation
tract copied to clipboard

Compilation for `wasm32-unknown-emscripten` fails

Open raphaelmenges opened this issue 1 year ago • 2 comments

Hello 👋,

I am trying to use tract in a project that compiles to the target wasm32-unknown-emscripten. This target seems not to be covered by the CI but I found a pull request that indicates compatibility.

When I try to compile tract, its tar dependency throws following error:

error[E0428]: the name `symlink` is defined multiple times
   --> /Users/raphael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tar-0.4.43/src/entry.rs:607:13
    |
597 |             fn symlink(src: &Path, dst: &Path) -> io::Result<()> {
    |             ---------------------------------------------------- previous definition of the value `symlink` here
...
607 |             fn symlink(src: &Path, dst: &Path) -> io::Result<()> {
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `symlink` redefined here
    |
    = note: `symlink` must be defined only once in the value namespace of this block

error[E0428]: the name `_set_ownerships` is defined multiple times
   --> /Users/raphael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tar-0.4.43/src/entry.rs:774:9
    |
733 | /         fn _set_ownerships(
734 | |             dst: &Path,
735 | |             f: &Option<&mut std::fs::File>,
736 | |             uid: u64,
...   |
769 | |             }
770 | |         }
    | |_________- previous definition of the value `_set_ownerships` here
...
774 | /         fn _set_ownerships(
775 | |             _: &Path,
776 | |             _: &Option<&mut std::fs::File>,
777 | |             _: u64,
...   |
780 | |             Ok(())
781 | |         }
    | |_________^ `_set_ownerships` redefined here
    |
    = note: `_set_ownerships` must be defined only once in the value namespace of this block

error[E0428]: the name `_set_perms` is defined multiple times
   --> /Users/raphael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tar-0.4.43/src/entry.rs:849:9
    |
804 | /         fn _set_perms(
805 | |             dst: &Path,
806 | |             f: Option<&mut std::fs::File>,
807 | |             mode: u32,
...   |
819 | |             }
820 | |         }
    | |_________- previous definition of the value `_set_perms` here
...
849 | /         fn _set_perms(
850 | |             dst: &Path,
851 | |             f: Option<&mut std::fs::File>,
852 | |             mode: u32,
...   |
856 | |             Err(io::Error::new(io::ErrorKind::Other, "Not implemented"))
857 | |         }
    | |_________^ `_set_perms` redefined here
    |
    = note: `_set_perms` must be defined only once in the value namespace of this block

error[E0428]: the name `set_xattrs` is defined multiple times
   --> /Users/raphael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tar-0.4.43/src/entry.rs:898:9
    |
860 | ...   fn set_xattrs(me: &mut EntryFields, dst: &Path) -> io::Result<()> {
    |       ----------------------------------------------------------------- previous definition of the value `set_xattrs` here
...
898 | ...   fn set_xattrs(_: &mut EntryFields, _: &Path) -> io::Result<()> {
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `set_xattrs` redefined here
    |
    = note: `set_xattrs` must be defined only once in the value namespace of this block

error[E0428]: the name `ends_with_slash` is defined multiple times
    --> /Users/raphael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tar-0.4.43/src/header.rs:1602:1
     |
1591 | fn ends_with_slash(p: &Path) -> bool {
     | ------------------------------------ previous definition of the value `ends_with_slash` here
...
1602 | fn ends_with_slash(p: &Path) -> bool {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ends_with_slash` redefined here
     |
     = note: `ends_with_slash` must be defined only once in the value namespace of this module

error[E0428]: the name `path2bytes` is defined multiple times
    --> /Users/raphael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tar-0.4.43/src/header.rs:1630:1
     |
1607 | pub fn path2bytes(p: &Path) -> io::Result<Cow<[u8]>> {
     | ---------------------------------------------------- previous definition of the value `path2bytes` here
...
1630 | pub fn path2bytes(p: &Path) -> io::Result<Cow<[u8]>> {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `path2bytes` redefined here
     |
     = note: `path2bytes` must be defined only once in the value namespace of this module

error[E0428]: the name `bytes2path` is defined multiple times
    --> /Users/raphael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tar-0.4.43/src/header.rs:1669:1
     |
1659 | pub fn bytes2path(bytes: Cow<[u8]>) -> io::Result<Cow<Path>> {
     | ------------------------------------------------------------ previous definition of the value `bytes2path` here
...
1669 | pub fn bytes2path(bytes: Cow<[u8]>) -> io::Result<Cow<Path>> {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `bytes2path` redefined here
     |
     = note: `bytes2path` must be defined only once in the value namespace of this module

error[E0592]: duplicate definitions with name `fill_platform_from`
   --> /Users/raphael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tar-0.4.43/src/header.rs:754:5
    |
749 |     fn fill_platform_from(&mut self, meta: &fs::Metadata, mode: HeaderMode...
    |     ----------------------------------------------------------------------- other definition for `fill_platform_from`
...
754 |     fn fill_platform_from(&mut self, meta: &fs::Metadata, mode: HeaderMode...
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definitions for `fill_platform_from`

   Compiling ug v0.0.2
Some errors have detailed explanations: E0428, E0592.
For more information about an error, try `rustc --explain E0428`.
error: could not compile `tar` (lib) due to 8 previous errors

The people at tar seem to have a related pending pull request. Yet, I am not sure whether tar must be a required dependency for tract at all.

raphaelmenges avatar Jan 15 '25 08:01 raphaelmenges

tar is required for the NNEF format, which I don't feel like putting behind conditional compilation as it is the primary format for tract.

Hopefully thetar crew crate will make it work soon, it does not sound like something that should be too hard, right?

kali avatar Jan 20 '25 08:01 kali

The issue in tar seems to be fixed by now: https://github.com/alexcrichton/tar-rs/pull/397

raphaelmenges avatar Feb 18 '25 09:02 raphaelmenges