rust-mbedtls / mbedtls

Apache License 2.0
1 stars 3 forks source link

mbedtls 0.11.0 crate fails on i686 cross-rs builds #15

Open cruxpot opened 1 year ago

cruxpot commented 1 year ago

Hi there,

I am doing a simple cross compile test with cross-rs on various platforms. I can't get i686 targets to work with this crate at all.

cargo new test-mbedtls

My Cargo.toml file:

[package]
  name = "test-mbedtls"
  version = "0.1.0"
  edition = "2021"

  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

  [dependencies]
  mbedtls = "0.11.0"

I'm using the cross-rs dockerfiles that I built located at since they are newer than the ones they have hosted on the internet at ghcr.io/cross-rs: https://github.com/cross-rs/cross/blob/main/docker/Dockerfile.i686-unknown-linux-gnu https://github.com/cross-rs/cross/blob/main/docker/Dockerfile.i686-unknown-linux-musl

Build with a command like this after cloning https://github.com/cross-rs repo:

cd cross-rs/docker
docker build -f Dockerfile.i686-unknown-linux-gnu -t i686-unknown-gnu-test .
docker build -f Dockerfile.i686-unknown-linux-musl -t i686-unknown-musl-test .

My Cross.toml file to give it the packages it needs to build:

[target.i686-unknown-linux-musl]
image = "i686-unknown-musl-test"
pre-build = [ "apt-get install -y clang python3-pip && pip3 install jsonschema jinja2" ]

[target.i686-unknown-linux-gnu]
image = "i686-unknown-gnu-test"
pre-build = [ "apt-get install -y clang python3-pip && pip3 install jsonschema jinja2" ]

Both musl and gnu i686 targets give me the same error. Does this crate not support i686? Any plans for that? Errors below:

$ cross build --target i686-unknown-linux-gnu
[+] Building 29.3s (6/6) FINISHED
 => [internal] load build definition from Dockerfile.i686-unknown-linux-gnu-custom                                                                            0.0s
 => => transferring dockerfile: 224B                                                                                                                          0.0s
 => [internal] load .dockerignore                                                                                                                             0.0s
 => => transferring context: 2B                                                                                                                               0.0s
 => [internal] load metadata for docker.io/library/i868-unknown-gnu-test:latest                                                                               0.0s
 => [1/2] FROM docker.io/library/i868-unknown-gnu-test                                                                                                        0.0s
 => [2/2] RUN eval "apt-get install -y clang python3-pip && pip3 install jsonschema jinja2"                                                                  27.7s
 => exporting to image                                                                                                                                        1.5s
 => => exporting layers                                                                                                                                       1.5s
 => => writing image sha256:6ab307067a9aee0a0e5d3ef280c74e1e561b0db3661091591f83958c8abfe092                                                                  0.0s
 => => naming to docker.io/library/cross-custom-test-mbedtls-rs:i686-unknown-linux-gnu-afa10-pre-build                                                        0.0s
   Compiling cfg-if v1.0.0
   Compiling once_cell v1.17.1
   Compiling bit-vec v0.5.1
   Compiling bitflags v1.3.2
   Compiling byteorder v1.4.3
   Compiling libc v0.2.144
   Compiling serde v1.0.163
   Compiling num-traits v0.2.15
   Compiling mbedtls-sys-auto v3.5.0-alpha.2+0b3de6f
   Compiling num-integer v0.1.45
   Compiling num-bigint v0.2.6
   Compiling yasna v0.2.2
   Compiling mbedtls-platform-support v0.3.0
   Compiling mbedtls v0.11.0
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
   --> /cargo/registry/src/github.com-1ecc6299db9ec823/mbedtls-0.11.0/src/cipher/raw/serde.rs:390:85
    |
390 | unsafe fn _check_gcm_context_size(ctx: gcm_context) -> [u8; _SIZE_OF_GCM_CONTEXT] { ::core::mem::transmute(ctx) }
    |                                                                                     ^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: source type: `mbedtls_sys::gcm_context` (3136 bits)
    = note: target type: `[u8; 400]` (3200 bits)

For more information about this error, try `rustc --explain E0512`.
error: could not compile `mbedtls` due to previous error