rust-num / num-integer

Integer trait and functions for Rust
Apache License 2.0
180 stars 48 forks source link

Build error building in docker ekidd/rust-musl-builder --target x86_64-unknown-linux-musl #49

Closed JoshuaNitschke closed 2 years ago

JoshuaNitschke commented 2 years ago

Hi, one of my dependencies has a dependency on num-integer.

This code compiles fine on mac, ubuntu, and windows when I run cargo build --release but I have been trying to build inside docker image ekidd/rust-musl-builder with cargo build --release --target x86_64-unknown-linux-musl and I get the following error:

Any ideas on how to fix this?

rust@ae0894d6a5f2:~/src$ cargo build --release --target x86_64-unknown-linux-musl
   Compiling num-integer v0.1.44
   Compiling num-traits v0.1.43
   Compiling serde_derive v1.0.136
   Compiling tokio-macros v1.7.0
   Compiling futures-macro v0.3.21
   Compiling proc-macro2-diagnostics v0.9.1
   Compiling time-macros-impl v0.1.2
   Compiling tracing-attributes v0.1.19
error[E0277]: the trait bound `i128: traits::Num` is not satisfied
   --> /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/num-integer-0.1.44/src/roots.rs:136:14
    |
136 |         impl Roots for $T {
    |              ^^^^^ the trait `traits::Num` is not implemented for `i128`
...
170 | signed_roots!(i128, u128);
    | ------------------------- in this macro invocation
    |
note: required by a bound in `Roots`
   --> /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/num-integer-0.1.44/src/roots.rs:9:18
    |
9   | pub trait Roots: Integer {
    |                  ^^^^^^^ required by this bound in `Roots`
    = note: this error originates in the macro `signed_roots` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `u128: traits::Num` is not satisfied
   --> /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/num-integer-0.1.44/src/roots.rs:204:14
    |
204 |         impl Roots for $T {
    |              ^^^^^ the trait `traits::Num` is not implemented for `u128`
...
390 | unsigned_roots!(u128);
    | --------------------- in this macro invocation
    |
note: required by a bound in `Roots`
   --> /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/num-integer-0.1.44/src/roots.rs:9:18
    |
9   | pub trait Roots: Integer {
    |                  ^^^^^^^ required by this bound in `Roots`
    = note: this error originates in the macro `unsigned_roots` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `i128: traits::Num` is not satisfied
   --> /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/num-integer-0.1.44/src/lib.rs:409:14
    |
409 |         impl Integer for $T {
    |              ^^^^^^^ the trait `traits::Num` is not implemented for `i128`
...
797 | impl_integer_for_isize!(i128, test_integer_i128);
    | ------------------------------------------------ in this macro invocation
    |
note: required by a bound in `Integer`
   --> /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/num-integer-0.1.44/src/lib.rs:37:28
    |
37  | pub trait Integer: Sized + Num + PartialOrd + Ord + Eq {
    |                            ^^^ required by this bound in `Integer`
    = note: this error originates in the macro `impl_integer_for_isize` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `u128: traits::Num` is not satisfied
    --> /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/num-integer-0.1.44/src/lib.rs:801:14
     |
801  |         impl Integer for $T {
     |              ^^^^^^^ the trait `traits::Num` is not implemented for `u128`
...
1014 | impl_integer_for_usize!(u128, test_integer_u128);
     | ------------------------------------------------ in this macro invocation
     |
note: required by a bound in `Integer`
    --> /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/num-integer-0.1.44/src/lib.rs:37:28
     |
37   | pub trait Integer: Sized + Num + PartialOrd + Ord + Eq {
     |                            ^^^ required by this bound in `Integer`
     = note: this error originates in the macro `impl_integer_for_usize` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.
error: could not compile `num-integer` due to 4 previous errors
cuviper commented 2 years ago

The error seems to indicate that the i128 feature was either enabled or autodetected for num-integer, but not for num-traits, which seems weird. There are sometimes problems with autocfg detection in cross-compilation, but that should be the same between num-integer and num-traits. I can build a hello-world in that container just fine with num-integer as a dependency.

Can you share the output of this command?

cargo tree --format "{p} : {f}"
JoshuaNitschke commented 2 years ago

@cuviper thanks for the response! Today, I was trying to get a small example of the issue going here https://github.com/JoshuaNitschke/rust-musl-builder_num-integer_example, but it builds as expected. Here is the cargo-tree output:

removed
cuviper commented 2 years ago

I guess you should add --target x86_64-unknown-linux-musl to that tree command, in case the target changes any dependencies. Please see if that's any different.

Another thing to look for are the build script outputs from num-integer and num-traits. There should be output and stderr files in a path like ./target/x86_64-unknown-linux-musl/release/build/num-integer-35c680a05bc94443/. The exact hash at the end of that path will vary depending on a lot of factors.

You can also build verbosely, cargo build -v -v ..., and look for lines like:

[num-traits 0.2.14] cargo:rustc-cfg=has_i128
[num-integer 0.1.44] cargo:rustc-cfg=has_i128

Or there may be visible errors if it didn't detect i128 support.

JoshuaNitschke commented 2 years ago

I reran with target and it was the same.

Interestingly, I have two folders: num_build_artifacts.zip

rust@9f69ab59e2b0:~/src$ ls ./target/x86_64-unknown-linux-musl/release/build/
num-integer-0694b7c89ce1bf38/
num-integer-35c680a05bc94443/
num-traits-0bb7be9c44b56e00/
num-traits-e0a4fa070967a9b6/  

I think we might be getting somewhere:

error: could not copy "/home/rust/src/target/x86_64-unknown-linux-musl/release/build/num-integer-35c680a05bc94443/out/probe0.probe0.990c8f4d-cgu.0.rcgu.ll" to "/home/rust/src/target/x86_64-unknown-linux-musl/release/build/num-integer-35c680a05bc94443/out/probe0.ll": Operation not permitted (os error 1)

error: aborting due to previous error

error: could not copy "/home/rust/src/target/x86_64-unknown-linux-musl/release/build/num-integer-35c680a05bc94443/out/probe1.probe1.84fcdf3f-cgu.0.rcgu.ll" to "/home/rust/src/target/x86_64-unknown-linux-musl/release/build/num-integer-35c680a05bc94443/out/probe1.ll": Operation not permitted (os error 1)

error: aborting due to previous error

warning: autocfg could not probe for `std`

and

error: could not copy "/home/rust/src/target/x86_64-unknown-linux-musl/release/build/num-traits-e0a4fa070967a9b6/out/probe0.probe0.990c8f4d-cgu.0.rcgu.ll" to "/home/rust/src/target/x86_64-unknown-linux-musl/release/build/num-traits-e0a4fa070967a9b6/out/probe0.ll": Operation not permitted (os error 1)

error: aborting due to previous error

error: could not copy "/home/rust/src/target/x86_64-unknown-linux-musl/release/build/num-traits-e0a4fa070967a9b6/out/probe1.probe1.84fcdf3f-cgu.0.rcgu.ll" to "/home/rust/src/target/x86_64-unknown-linux-musl/release/build/num-traits-e0a4fa070967a9b6/out/probe1.ll": Operation not permitted (os error 1)

error: aborting due to previous error

warning: autocfg could not probe for `std`
error: could not copy "/home/rust/src/target/x86_64-unknown-linux-musl/release/build/num-traits
-e0a4fa070967a9b6/out/probe2.probe2.c1d38c83-cgu.0.rcgu.ll" to "/home/rust/src/target/x86_64-unknown-linux-musl/release/build/num-traits-e0a4fa070967a9b6/out/probe2.ll": Operation not permitted (os error 1)

error: aborting due to previous error

I don't understand the could not copy errors.

I will try building verbosely now.

JoshuaNitschke commented 2 years ago

I think i have resolved this by entering the container and chmoding the target folder... will confirm later today

JoshuaNitschke commented 2 years ago

Yep, sorry to bother, but your troubleshooting note about how to find the error was very helpful! I did not know about that output.