Skip to content

fail to compile on aarch64 linux #803

@bguo068

Description

@bguo068

I was experimenting with cross-platform compilation and encountered the following error. It appears the issue might be due to the hardcoded cast of c_char to i8, where c_char can be either i8 or u8, depending on the architecture.(https://doc.rust-lang.org/std/os/raw/type.c_char.html).

  Compiling tskit v0.15.0-alpha.2
error[E0308]: mismatched types
    --> /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tskit-0.15.0-alpha.2/src/sys/edge_table.rs:67:17
     |
  61 |             Ok(tsk_edge_table_add_row(
     |                ---------------------- arguments to this function are incorrect
...
  67 |                 metadata.as_ptr().cast::<i8>(),
     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
     |
     = note: expected raw pointer `*const u8`
                found raw pointer `*const i8`
note: function defined here
    --> /data/target/aarch64-unknown-linux-gnu/release/build/tskit-d34e5d8a61359e9a/out/auto_bindings.rs:5554:12
     |
5554 |     pub fn tsk_edge_table_add_row(
     |            ^^^^^^^^^^^^^^^^^^^^^^
...
5560 |         metadata: *const ::std::os::raw::c_char,
     |         --------

error[E0308]: mismatched types
    --> /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tskit-0.15.0-alpha.2/src/sys/individual_table.rs:67:17
     |
  60 |             Ok(tsk_individual_table_add_row(
     |                ---------------------------- arguments to this function are incorrect
...
  67 |                 metadata.as_ptr().cast::<i8>(),
     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
     |
     = note: expected raw pointer `*const u8`
                found raw pointer `*const i8`
note: function defined here
    --> /data/target/aarch64-unknown-linux-gnu/release/build/tskit-d34e5d8a61359e9a/out/auto_bindings.rs:5238:12
     |
5238 |     pub fn tsk_individual_table_add_row(
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
5245 |         metadata: *const ::std::os::raw::c_char,
     |         --------

error[E0308]: mismatched types
    --> /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tskit-0.15.0-alpha.2/src/sys/migration_table.rs:74:17
     |
  66 |             Ok(tsk_migration_table_add_row(
     |                --------------------------- arguments to this function are incorrect
...
  74 |                 metadata.as_ptr().cast::<i8>(),
     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
     |
     = note: expected raw pointer `*const u8`
                found raw pointer `*const i8`
note: function defined here
    --> /data/target/aarch64-unknown-linux-gnu/release/build/tskit-d34e5d8a61359e9a/out/auto_bindings.rs:5707:12
     |
5707 |     pub fn tsk_migration_table_add_row(
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
5715 |         metadata: *const ::std::os::raw::c_char,
     |         --------

error[E0308]: mismatched types
  --> /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tskit-0.15.0-alpha.2/src/sys/mutation_table.rs:72:32
   |
72 |                     Some(d) => d.as_ptr() as *const i8,
   |                                ^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`

error[E0308]: mismatched types
    --> /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tskit-0.15.0-alpha.2/src/sys/mutation_table.rs:79:17
     |
  65 |             Ok(tsk_mutation_table_add_row(
     |                -------------------------- arguments to this function are incorrect
...
  79 |                 metadata.as_ptr().cast::<i8>(),
     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
     |
     = note: expected raw pointer `*const u8`
                found raw pointer `*const i8`
note: function defined here
    --> /data/target/aarch64-unknown-linux-gnu/release/build/tskit-d34e5d8a61359e9a/out/auto_bindings.rs:6016:12
     |
6016 |     pub fn tsk_mutation_table_add_row(
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^
...
6024 |         metadata: *const ::std::os::raw::c_char,
     |         --------

error[E0308]: mismatched types
    --> /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tskit-0.15.0-alpha.2/src/sys/node_table.rs:83:17
     |
  77 |             tsk_node_table_add_row(
     |             ---------------------- arguments to this function are incorrect
...
  83 |                 metadata.as_ptr().cast::<i8>(),
     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
     |
     = note: expected raw pointer `*const u8`
                found raw pointer `*const i8`
note: function defined here
    --> /data/target/aarch64-unknown-linux-gnu/release/build/tskit-d34e5d8a61359e9a/out/auto_bindings.rs:5405:12
     |
5405 |     pub fn tsk_node_table_add_row(
     |            ^^^^^^^^^^^^^^^^^^^^^^
...
5411 |         metadata: *const ::std::os::raw::c_char,
     |         --------

error[E0308]: mismatched types
    --> /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tskit-0.15.0-alpha.2/src/sys/population_table.rs:47:17
     |
  45 |             Ok(tsk_population_table_add_row(
     |                ---------------------------- arguments to this function are incorrect
  46 |                 self.as_mut(),
  47 |                 metadata.as_ptr().cast::<i8>(),
     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
     |
     = note: expected raw pointer `*const u8`
                found raw pointer `*const i8`
note: function defined here
    --> /data/target/aarch64-unknown-linux-gnu/release/build/tskit-d34e5d8a61359e9a/out/auto_bindings.rs:6180:12
     |
6180 |     pub fn tsk_population_table_add_row(
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6181 |         self_: *mut tsk_population_table_t,
6182 |         metadata: *const ::std::os::raw::c_char,
     |         --------

error[E0308]: mismatched types
  --> /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tskit-0.15.0-alpha.2/src/sys/site_table.rs:60:32
   |
60 |                     Some(d) => d.as_ptr() as *const i8,
   |                                ^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`

error[E0308]: mismatched types
    --> /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tskit-0.15.0-alpha.2/src/sys/site_table.rs:67:17
     |
  56 |             Ok(tsk_site_table_add_row(
     |                ---------------------- arguments to this function are incorrect
...
  67 |                 metadata.as_ptr().cast::<i8>(),
     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
     |
     = note: expected raw pointer `*const u8`
                found raw pointer `*const i8`
note: function defined here
    --> /data/target/aarch64-unknown-linux-gnu/release/build/tskit-d34e5d8a61359e9a/out/auto_bindings.rs:5864:12
     |
5864 |     pub fn tsk_site_table_add_row(
     |            ^^^^^^^^^^^^^^^^^^^^^^
...
5869 |         metadata: *const ::std::os::raw::c_char,
     |         --------

For more information about this error, try `rustc --explain E0308`.
warning: tskit@0.15.0-alpha.2: zig: error: version '.2.17' in target triple 'aarch64-unknown-linux-gnu.2.17' is invalid
error: could not compile `tskit` (lib) due to 9 previous errors
💥 maturin failed
  Caused by: Failed to build a native library through cargo
  Caused by: Cargo build finished with "exit status: 101": `env -u CARGO AR_aarch64_unknown_linux_gnu="/root/.cache/cargo-zigbuild/0.20.1/ar" CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER="/root/.cache/cargo-zigbuild/0.20.1/zigcc-aarch64-unknown-linux-gnu.2.17-f712.sh" CARGO_ZIGBUILD_RUSTC_VERSION="1.92.0" CC_aarch64_unknown_linux_gnu="/root/.cache/cargo-zigbuild/0.20.1/zigcc-aarch64-unknown-linux-gnu.2.17-f712.sh" CMAKE_TOOLCHAIN_FILE_aarch64_unknown_linux_gnu="/root/.cache/cargo-zigbuild/0.20.1/cmake/aarch64-unknown-linux-gnu-toolchain.cmake" CXX_aarch64_unknown_linux_gnu="/root/.cache/cargo-zigbuild/0.20.1/zigcxx-aarch64-unknown-linux-gnu.2.17-f712.sh" PYO3_BUILD_EXTENSION_MODULE="1" PYO3_CONFIG_FILE="/data/target/maturin/pyo3-config-aarch64-unknown-linux-gnu-3.9.txt" RANLIB_aarch64_unknown_linux_gnu="/root/.cache/cargo-zigbuild/0.20.1/zigranlib.sh" ZIG_COMMAND="/usr/bin/python3 -m ziglang" "cargo" "rustc" "--profile" "release" "--target" "aarch64-unknown-linux-gnu" "--message-format" "json-render-diagnostics" "--manifest-path" "/data/Cargo.toml" "--lib"`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions