cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.21k stars 354 forks source link

Unable to compile project #1470

Closed nix-enthusiast closed 2 months ago

nix-enthusiast commented 3 months ago

Checklist

Describe your issue

I moved to Linux Mint 21.3 to Fedora 39 and installed cross inside a distrobox container (docker inside of distrobox is working without problems).

Project used to be cross-compiled to given platforms but now none of my cross-compilation attempts were successful despite Cargo.toml and source files are same.

Project can be compiled in host target (x86_64-unknown-linux-gnu, i686-unknown-linux-gnu)

What target(s) are you cross-compiling for?

aarch64-linux-android, aarch64-unknown-linux-gnu, aarch64-unknown-linux-musl, aarch64-unknown-freebsd, i686-linux-android, i686-pc-windows-gnu, i686-unknown-freebsd, x86_64-linux-android, x86_64-pc-windows-gnu, x86_64-unknown-freebsd, x86_64-unknown-linux-musl, x86_64-unknown-netbsd

Which operating system is the host (e.g computer cross is on) running?

What architecture is the host?

What container engine is cross using?

cross version

cross 0.2.5 (35be2a9 2024-04-06)

Example

Output

$ cargo build --release --target=x86_64-unknown-linux-gnu
    Finished release [optimized] target(s) in 0.17s

$ cargo build --release --target=i686-unknown-linux-gnu
    Finished release [optimized] target(s) in 0.12s

$ cross build --release --target=x86_64-pc-windows-gnu   
   Compiling windows_x86_64_gnu v0.52.4
   Compiling scroll v0.12.0
   Compiling phf v0.11.2
   Compiling windows-targets v0.52.4
error[E0463]: can't find crate for `phf_macros`
   --> /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/phf-0.11.2/src/lib.rs:104:9
    |
104 | pub use phf_macros::phf_map;
    |         ^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `phf_macros`
   --> /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/phf-0.11.2/src/lib.rs:110:9
    |
110 | pub use phf_macros::phf_ordered_map;
    |         ^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `phf_macros`
   --> /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/phf-0.11.2/src/lib.rs:131:9
    |
131 | pub use phf_macros::phf_set;
    |         ^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `phf_macros`
   --> /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/phf-0.11.2/src/lib.rs:137:9
    |
137 | pub use phf_macros::phf_ordered_set;
    |         ^^^^^^^^^^ can't find crate

   Compiling windows-sys v0.52.0
error[E0463]: can't find crate for `scroll_derive`
   --> /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scroll-0.12.0/src/lib.rs:230:9
    |
230 | pub use scroll_derive::{IOread, IOwrite, Pread, Pwrite, SizeWith};
    |         ^^^^^^^^^^^^^ can't find crate

error: cannot determine resolution for the import
   --> /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scroll-0.12.0/src/ctx.rs:190:20
    |
190 | use crate::{error, Pread, Pwrite};
    |                    ^^^^^

error: cannot determine resolution for the import
   --> /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scroll-0.12.0/src/ctx.rs:190:27
    |
190 | use crate::{error, Pread, Pwrite};
    |                           ^^^^^^

error: cannot determine resolution for the import
 --> /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scroll-0.12.0/src/leb128.rs:5:20
  |
5 | use crate::{error, Pread};
  |                    ^^^^^

error[E0432]: unresolved imports `crate::Pread`, `crate::Pwrite`, `crate::Pread`
   --> /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scroll-0.12.0/src/ctx.rs:190:20
    |
190 | use crate::{error, Pread, Pwrite};
    |                    ^^^^^  ^^^^^^
    |
   ::: /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scroll-0.12.0/src/leb128.rs:5:20
    |
5   | use crate::{error, Pread};
    |                    ^^^^^

For more information about this error, try `rustc --explain E0463`.
error: could not compile `phf` (lib) due to 4 previous errors
warning: build failed, waiting for other jobs to finish...
error[E0599]: no method named `gread_with` found for reference `&'a [u8]` in the current scope
   --> /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scroll-0.12.0/src/ctx.rs:795:23
    |
795 |             match src.gread_with::<T>(&mut offset, ctx) {
    |                       ^^^^^^^^^^ method not found in `&'a [u8]`
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
183 + use crate::pread::Pread;
    |

error[E0599]: no method named `gwrite_with` found for mutable reference `&mut [u8]` in the current scope
   --> /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scroll-0.12.0/src/ctx.rs:828:17
    |
828 |             buf.gwrite_with(element, &mut offset, ctx)?;
    |                 ^^^^^^^^^^^ method not found in `&mut [u8]`
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
183 + use crate::pwrite::Pwrite;
    |

error[E0599]: no method named `pread` found for reference `&[u8]` in the current scope
  --> /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scroll-0.12.0/src/leb128.rs:23:25
   |
23 |         let tmp = bytes.pread::<Uleb128>(*offset)?;
   |                         ^^^^^ method not found in `&[u8]`
   |
   = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
   |
1  + use crate::pread::Pread;
   |

error[E0599]: no method named `pread` found for reference `&[u8]` in the current scope
  --> /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scroll-0.12.0/src/leb128.rs:58:25
   |
58 |         let tmp = bytes.pread::<Sleb128>(*offset)?;
   |                         ^^^^^ method not found in `&[u8]`
   |
   = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
   |
1  + use crate::pread::Pread;
   |

error[E0599]: no method named `pread` found for reference `&'a [u8]` in the current scope
   --> /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scroll-0.12.0/src/leb128.rs:100:32
    |
100 |             let byte: u8 = src.pread(count)?;
    |                                ^^^^^ method not found in `&'a [u8]`
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
1   + use crate::pread::Pread;
    |

error[E0599]: no method named `gread` found for reference `&'a [u8]` in the current scope
   --> /home/spy/.local/arch-dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scroll-0.12.0/src/leb128.rs:139:24
    |
139 |             byte = src.gread(offset)?;
    |                        ^^^^^ method not found in `&'a [u8]`
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
1   + use crate::pread::Pread;
    |

Some errors have detailed explanations: E0432, E0463, E0599.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `scroll` (lib) due to 11 previous errors
$

Cargo.toml

[package]
name = "linkread"
version = "0.1.0"
edition = "2021"

[dependencies]
goblin = "0.8.0"
home = "0.5.9"
phf = { version = "0.11.2", features = ["macros"] }

[target.i586-rust9x-windows-msvc.dependencies]
windows-sys = { git = "https://github.com/rust9x/windows-rs.git", branch = "rust9x-windows-0.52.0-nt" }
#windows-sys = { git = "https://github.com/rust9x/windows-rs.git", branch = "rust9x-windows-0.52.0-9xme" }

[profile.release]
strip = true

Additional information / notes

I didn't provide results of all targets I tried because they throw as same error as the error I give it in example.

nix-enthusiast commented 3 months ago

Apologies for I couldn't provide the project code. It's too complex to send.

Emilgardis commented 3 months ago

can you try a cargo clean and then rebuild, this looks like something was corrupted or a file was not read correctly.

nix-enthusiast commented 2 months ago

can you try a cargo clean and then rebuild, this looks like something was corrupted or a file was not read correctly.

Now cross command doesn't do anything, seems frozen. Both crates.io and git version behaves same.

Docker seems running and journalctl doesn't report anything.

nix-enthusiast commented 2 months ago

I moved my source code to a new project folder and it works as intended.

Problem solved.