georust / netcdf

High-level netCDF bindings for Rust
Apache License 2.0
81 stars 28 forks source link

Typing error when compiling on ARM64 Docker container #104

Closed polvalente closed 1 year ago

polvalente commented 1 year ago

I am trying to compile v0.8.0 on a linux docker image running on an M1 processor. There are lots of errors like:

   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/variable.rs:682:15
    |
682 |     unsafe fn from_ptr(ptr: *mut i8) -> Self {

I have tried lots of things, including updating the library to 0.8.0, but there seems to be a separate problem here. Currently, I am setting up the dependencies as follows:

ENV CONDA_DIR=/opt/conda
ENV PATH=${CONDA_DIR}/bin:$PATH
ENV HDF5_DIR=${CONDA_DIR}
ENV NETCDF_DIR=${CONDA_DIR}

RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-$(arch).sh -O ~/miniconda.sh && /bin/bash ~/miniconda.sh -b -p ${CONDA_DIR}

RUN conda install -y -c conda-forge libnetcdf=4.8.1 hdf5=1.12.1

libnetcdf=4.9.2 brings hdf5=1.14.0 which isn't supported, so I am forcing 4.8.1.

On the host machine I just installed dependencies with brew install nco and everything just works. Linux x86_64 also works fine. Cross-compiling on CI also brings in a different set of problems, but I'm not sure if I should open a separate issue on those.

magnusuMET commented 1 year ago

Could you include a more comprehensive log? The log line does not tell me enough to guess at what is wrong

polvalente commented 1 year ago

Sure! Here's the relevant part of the log. The library is being built by Rustler for Elixir interop, but I reckon this should suffice. Let me know if you need more information!

==> netcdf
Compiling 3 files (.ex)
    Updating crates.io index
Compiling lib/netcdf/native.ex (it's taking more than 10s)
 Downloading crates ...
  Downloaded void v1.0.2
  Downloaded cfg-if v1.0.0
  Downloaded thiserror-impl v1.0.40
  Downloaded unreachable v1.0.0
  Downloaded lazy_static v1.4.0
  Downloaded heck v0.4.1
  Downloaded rawpointer v0.2.1
  Downloaded bitflags v1.3.2
  Downloaded autocfg v1.1.0
  Downloaded num-integer v0.1.45
  Downloaded cmake v0.1.50
  Downloaded quote v1.0.26
  Downloaded thiserror v1.0.40
  Downloaded rustler_sys v2.2.0
  Downloaded semver v1.0.17
  Downloaded rustler v0.26.0
  Downloaded pkg-config v0.3.26
  Downloaded num-complex v0.4.3
  Downloaded libloading v0.7.4
  Downloaded rustler_codegen v0.26.0
  Downloaded netcdf-sys v0.4.1
  Downloaded hdf5-sys v0.8.1
  Downloaded unicode-ident v1.0.8
  Downloaded winreg v0.10.1
  Downloaded netcdf v0.8.0
  Downloaded proc-macro2 v1.0.54
  Downloaded serde_derive v1.0.159
  Downloaded memchr v2.5.0
  Downloaded matrixmultiply v0.3.2
  Downloaded num-traits v0.2.15
  Downloaded openssl-sys v0.9.83
  Downloaded cc v1.0.79
  Downloaded serde v1.0.159
  Downloaded aho-corasick v0.7.20
  Downloaded vcpkg v0.2.15
  Downloaded syn v2.0.12
  Downloaded syn v1.0.109
  Downloaded regex v1.7.3
  Downloaded ndarray v0.15.6
  Downloaded regex-syntax v0.6.29
  Downloaded libc v0.2.140
  Downloaded winapi v0.3.9
  Downloaded libz-sys v1.1.8
  Downloaded winapi-i686-pc-windows-gnu v0.4.0
  Downloaded winapi-x86_64-pc-windows-gnu v0.4.0
  Downloaded curl-sys v0.4.61+curl-8.0.1
  Downloaded hdf5-src v0.8.1
  Downloaded openssl-src v111.25.2+1.1.1t
  Downloaded netcdf-src v0.3.0
Compiling crate ex_netcdf in release mode (native/ex_netcdf)
   Compiling memchr v2.5.0
   Compiling cc v1.0.79
   Compiling pkg-config v0.3.26
   Compiling regex-syntax v0.6.29
   Compiling cfg-if v1.0.0
   Compiling libloading v0.7.4
   Compiling proc-macro2 v1.0.54
   Compiling cmake v0.1.50
   Compiling aho-corasick v0.7.20
   Compiling autocfg v1.1.0
   Compiling quote v1.0.26
   Compiling libz-sys v1.1.8
   Compiling hdf5-src v0.8.1
   Compiling libc v0.2.140
   Compiling unicode-ident v1.0.8
   Compiling semver v1.0.17
   Compiling regex v1.7.3
   Compiling num-traits v0.2.15
   Compiling netcdf-src v0.3.0
   Compiling num-integer v0.1.45
   Compiling netcdf-sys v0.4.1
   Compiling syn v1.0.109
   Compiling hdf5-sys v0.8.1
   Compiling rustler_sys v2.2.0
   Compiling void v1.0.2
   Compiling rawpointer v0.2.1
   Compiling matrixmultiply v0.3.2
   Compiling num-complex v0.4.3
   Compiling unreachable v1.0.0
   Compiling syn v2.0.12
   Compiling thiserror v1.0.40
   Compiling lazy_static v1.4.0
   Compiling heck v0.4.1
   Compiling netcdf v0.8.0
   Compiling rustler v0.26.0
   Compiling ndarray v0.15.6
   Compiling bitflags v1.3.2
   Compiling thiserror-impl v1.0.40
   Compiling rustler_codegen v0.26.0
error[E0308]: mismatched types
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/attribute.rs:134:41
    |
134 |                     Ok(AttrValue::Schar(value))
    |                        ---------------- ^^^^^ expected `i8`, found `u8`
    |                        |
    |                        arguments to this enum variant are incorrect
    |
note: tuple variant defined here
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/attribute.rs:510:5
    |
510 |     Schar(i8),
    |     ^^^^^
help: you can convert a `u8` to an `i8` and panic if the converted value doesn't fit
    |
134 |                     Ok(AttrValue::Schar(value.try_into().unwrap()))
    |                                              ++++++++++++++++++++

error[E0308]: mismatched types
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/attribute.rs:148:42
    |
148 |                     Ok(AttrValue::Schars(values))
    |                        ----------------- ^^^^^^ expected `i8`, found `u8`
    |                        |
    |                        arguments to this enum variant are incorrect
    |
    = note: expected struct `Vec<i8>`
               found struct `Vec<u8>`
note: tuple variant defined here
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/attribute.rs:511:5
    |
511 |     Schars(Vec<i8>),
    |     ^^^^^^

error[E0308]: mismatched types
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/attribute.rs:559:86
    |
559 |                     nc_put_att_schar(ncid, varid, cname.as_ptr().cast(), NC_BYTE, 1, &x)
    |                     ---------------- arguments to this function are incorrect        ^^ expected `u8`, found `i8`
    |
    = note: expected raw pointer `*const u8`
                 found reference `&i8`
note: function defined here
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-sys-0.4.1/src/functions.rs:495:12
    |
495 |     pub fn nc_put_att_schar(
    |            ^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/attribute.rs:568:25
    |
562 |                     nc_put_att_schar(
    |                     ---------------- arguments to this function are incorrect
...
568 |                         x.as_ptr(),
    |                         ^^^^^^^^^^ expected `u8`, found `i8`
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`
note: function defined here
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-sys-0.4.1/src/functions.rs:495:12
    |
495 |     pub fn nc_put_att_schar(
    |            ^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/variable.rs:397:25
    |
393 |                       $nc_get_var1_type(
    |                       ----------------- arguments to this function are incorrect
...
397 |                           buff.as_mut_ptr(),
    |                           ^^^^^^^^^^^^^^^^^ expected `u8`, found `i8`
...
550 | / impl_numeric!(
551 | |     i8,
552 | |     NC_BYTE,
553 | |     nc_get_var_schar,
...   |
561 | |     nc_put_varm_schar,
562 | | );
    | |_- in this macro invocation
    |
    = note: expected raw pointer `*mut u8`
               found raw pointer `*mut i8`
note: function defined here
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-sys-0.4.1/src/functions.rs:698:12
    |
698 |     pub fn nc_get_var1_schar(
    |            ^^^^^^^^^^^^^^^^^
    = note: this error originates in the macro `impl_numeric` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/variable.rs:414:25
    |
410 |                       $nc_put_var1_type(
    |                       ----------------- arguments to this function are incorrect
...
414 |                           addr_of!(value),
    |                           ^^^^^^^^^^^^^^^ expected `u8`, found `i8`
...
550 | / impl_numeric!(
551 | |     i8,
552 | |     NC_BYTE,
553 | |     nc_get_var_schar,
...   |
561 | |     nc_put_varm_schar,
562 | | );
    | |_- in this macro invocation
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`
note: function defined here
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-sys-0.4.1/src/functions.rs:692:12
    |
692 |     pub fn nc_put_var1_schar(
    |            ^^^^^^^^^^^^^^^^^
    = note: this error originates in the macro `impl_numeric` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/variable.rs:431:25
    |
426 |                       $nc_get_vara_type(
    |                       ----------------- arguments to this function are incorrect
...
431 |                           values,
    |                           ^^^^^^ expected `u8`, found `i8`
...
550 | / impl_numeric!(
551 | |     i8,
552 | |     NC_BYTE,
553 | |     nc_get_var_schar,
...   |
561 | |     nc_put_varm_schar,
562 | | );
    | |_- in this macro invocation
    |
    = note: expected raw pointer `*mut u8`
               found raw pointer `*mut i8`
note: function defined here
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-sys-0.4.1/src/functions.rs:859:12
    |
859 |     pub fn nc_get_vara_schar(
    |            ^^^^^^^^^^^^^^^^^
    = note: this error originates in the macro `impl_numeric` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/variable.rs:449:25
    |
444 |                       $nc_put_vara_type(
    |                       ----------------- arguments to this function are incorrect
...
449 |                           values.as_ptr(),
    |                           ^^^^^^^^^^^^^^^ expected `u8`, found `i8`
...
550 | / impl_numeric!(
551 | |     i8,
552 | |     NC_BYTE,
553 | |     nc_get_var_schar,
...   |
561 | |     nc_put_varm_schar,
562 | | );
    | |_- in this macro invocation
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`
note: function defined here
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-sys-0.4.1/src/functions.rs:852:12
    |
852 |     pub fn nc_put_vara_schar(
    |            ^^^^^^^^^^^^^^^^^
    = note: this error originates in the macro `impl_numeric` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/variable.rs:468:25
     |
462  |                       $nc_get_vars_type(
     |                       ----------------- arguments to this function are incorrect
...
468  |                           values,
     |                           ^^^^^^ expected `u8`, found `i8`
...
550  | / impl_numeric!(
551  | |     i8,
552  | |     NC_BYTE,
553  | |     nc_get_var_schar,
...    |
561  | |     nc_put_varm_schar,
562  | | );
     | |_- in this macro invocation
     |
     = note: expected raw pointer `*mut u8`
                found raw pointer `*mut i8`
note: function defined here
    --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-sys-0.4.1/src/functions.rs:1046:12
     |
1046 |     pub fn nc_get_vars_schar(
     |            ^^^^^^^^^^^^^^^^^
     = note: this error originates in the macro `impl_numeric` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/variable.rs:487:25
     |
481  |                       $nc_put_vars_type(
     |                       ----------------- arguments to this function are incorrect
...
487  |                           values,
     |                           ^^^^^^ expected `u8`, found `i8`
...
550  | / impl_numeric!(
551  | |     i8,
552  | |     NC_BYTE,
553  | |     nc_get_var_schar,
...    |
561  | |     nc_put_varm_schar,
562  | | );
     | |_- in this macro invocation
     |
     = note: expected raw pointer `*const u8`
                found raw pointer `*const i8`
note: function defined here
    --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-sys-0.4.1/src/functions.rs:1038:12
     |
1038 |     pub fn nc_put_vars_schar(
     |            ^^^^^^^^^^^^^^^^^
     = note: this error originates in the macro `impl_numeric` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/variable.rs:508:25
     |
501  |                       $nc_get_varm_type(
     |                       ----------------- arguments to this function are incorrect
...
508  |                           values,
     |                           ^^^^^^ expected `u8`, found `i8`
...
550  | / impl_numeric!(
551  | |     i8,
552  | |     NC_BYTE,
553  | |     nc_get_var_schar,
...    |
561  | |     nc_put_varm_schar,
562  | | );
     | |_- in this macro invocation
     |
     = note: expected raw pointer `*mut u8`
                found raw pointer `*mut i8`
note: function defined here
    --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-sys-0.4.1/src/functions.rs:1259:12
     |
1259 |     pub fn nc_get_varm_schar(
     |            ^^^^^^^^^^^^^^^^^
     = note: this error originates in the macro `impl_numeric` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/variable.rs:529:25
     |
522  |                       $nc_put_varm_type(
     |                       ----------------- arguments to this function are incorrect
...
529  |                           values,
     |                           ^^^^^^ expected `u8`, found `i8`
...
550  | / impl_numeric!(
551  | |     i8,
552  | |     NC_BYTE,
553  | |     nc_get_var_schar,
...    |
561  | |     nc_put_varm_schar,
562  | | );
     | |_- in this macro invocation
     |
     = note: expected raw pointer `*const u8`
                found raw pointer `*const i8`
note: function defined here
    --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-sys-0.4.1/src/functions.rs:1250:12
     |
1250 |     pub fn nc_put_varm_schar(
     |            ^^^^^^^^^^^^^^^^^
     = note: this error originates in the macro `impl_numeric` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/variable.rs:683:22
    |
683 |         Self { data: ptr }
    |                      ^^^ expected `u8`, found `i8`
    |
    = note: expected raw pointer `*mut u8`
               found raw pointer `*mut i8`

error[E0308]: mismatched types
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/variable.rs:755:50
    |
755 |         let string = unsafe { NcString::from_ptr(s) };
    |                               ------------------ ^ expected `i8`, found `u8`
    |                               |
    |                               arguments to this function are incorrect
    |
    = note: expected raw pointer `*mut i8`
               found raw pointer `*mut u8`
note: associated function defined here
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/netcdf-0.8.0/src/variable.rs:682:15
    |
682 |     unsafe fn from_ptr(ptr: *mut i8) -> Self {
    |               ^^^^^^^^ ------------

For more information about this error, try `rustc --explain E0308`.
error: could not compile `netcdf` due to 14 previous errors

== Compilation error in file lib/netcdf/native.ex ==
** (RuntimeError) Rust NIF compile error (rustc exit code 101)
    (rustler 0.26.0) lib/rustler/compiler.ex:41: Rustler.Compiler.compile_crate/2
    lib/netcdf/native.ex:4: (module)
could not compile dependency :netcdf, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile netcdf", update it with "mix deps.update netcdf" or clean it with "mix deps.clean netcdf"
The command '/bin/sh -c mix deps.compile' returned a non-zero code: 1
magnusuMET commented 1 year ago

Thank you for reporting this issue @polvalente. netcdf v0.8.1 should be available for you to test now.

polvalente commented 1 year ago

Thank you, it worked!