ring 0.17.5 doesn't compile for i686-unknown-linux-musl and gnu
Im using ring indirectly through reqwest with rustls feature.
This is the part where the error is when compiling my project:
...Some more warnings...
cargo:warning=crypto/fipsmodule/bn/../../limbs/limbs.inl: In function ‘limb_sub’:
cargo:warning=crypto/fipsmodule/bn/../../limbs/limbs.inl:110:20: warning: right shift count >= width of type [-Wshift-count-overflow]
cargo:warning= 110 | ret = (Carry)((x >> LIMB_BITS) & 1);
cargo:warning= | ^~
cargo:warning=In file included from include/ring-core/base.h:78,
cargo:warning= from crypto/fipsmodule/bn/internal.h:126,
cargo:warning= from crypto/fipsmodule/bn/montgomery.c:109:
cargo:warning=crypto/fipsmodule/bn/montgomery.c: At top level:
cargo:warning=In file included from crypto/fipsmodule/bn/internal.h:135,
cargo:warning= from crypto/fipsmodule/bn/montgomery_inv.c:15:
cargo:warning=crypto/fipsmodule/bn/../../internal.h: In function ‘CRYPTO_bswap8’:
cargo:warning=crypto/fipsmodule/bn/../../internal.h:374:10: warning: conversion from ‘long long unsigned int’ to ‘uint64_t’ {aka ‘long unsigned int’} may change value [-Wconversion]
cargo:warning= 374 | return __builtin_bswap64(x);
cargo:warning= | ^~~~~~~~~~~~~~~~~~~~
cargo:warning=include/ring-core/type_check.h:71:42: error: static assertion failed: "uint64_t is insufficient precision for n0"
cargo:warning= 71 | #define OPENSSL_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
cargo:warning= | ^~~~~~~~~~~~~~
cargo:warning=crypto/fipsmodule/bn/montgomery.c:117:1: note: in expansion of macro ‘OPENSSL_STATIC_ASSERT’
cargo:warning= 117 | OPENSSL_STATIC_ASSERT(
cargo:warning= | ^~~~~~~~~~~~~~~~~~~~~
cargo:warning=In file included from crypto/fipsmodule/bn/montgomery_inv.c:15:
cargo:warning=crypto/fipsmodule/bn/internal.h: In function ‘bn_umult_lohi’:
cargo:warning=crypto/fipsmodule/bn/internal.h:193:33: warning: right shift count >= width of type [-Wshift-count-overflow]
cargo:warning= 193 | *high_out = (BN_ULONG)(result >> BN_BITS2);
cargo:warning= | ^~
cargo:warning=In file included from include/ring-core/base.h:78,
cargo:warning= from crypto/fipsmodule/bn/internal.h:126,
cargo:warning= from crypto/fipsmodule/bn/montgomery_inv.c:15:
cargo:warning=crypto/fipsmodule/bn/montgomery_inv.c: At top level:
cargo:warning=In file included from crypto/fipsmodule/ec/../../limbs/limbs.h:20,
cargo:warning= from crypto/fipsmodule/ec/gfp_p384.c:15:
cargo:warning=crypto/fipsmodule/ec/../../limbs/../internal.h: In function ‘CRYPTO_bswap8’:
...More warnings...
i have same issue
What C compiler (TARGET_CC or equivalent) are you using?
What C compiler (
TARGET_CCor equivalent) are you using?
musl-gcc
Please post the exact command lines you used, and also the version info for the tools.
Note that i686-unknown-linux-gnu and i686-unknown-linux-musl are already tested in CI. However, note that in CI we use clang and the self-contained configuration (from mk/cargo.sh):
i686-unknown-linux-gnu)
export CC_i686_unknown_linux_gnu=clang-$llvm_version
export AR_i686_unknown_linux_gnu=llvm-ar-$llvm_version
export CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=clang-$llvm_version
;;
i686-unknown-linux-musl)
export CC_i686_unknown_linux_musl=clang-$llvm_version
export AR_i686_unknown_linux_musl=llvm-ar-$llvm_version
export CARGO_TARGET_I686_UNKNOWN_LINUX_MUSL_RUSTFLAGS="$rustflags_self_contained"
My guess is that maybe you are using musl-gcc but you don't have the right sysroot or something is messed up with the configuration.
It would be great if you could post a PR that modifies mk/cargo.sh and mk/install-build-tools.sh to match the configuration you are trying to use.
Please post the exact command lines you used, and also the version info for the tools.
Sorry that i didn't respond for so long.
I have created a Dockerfile that gives the same errors when building the image:
FROM rust:1.74.0-buster
WORKDIR /app
# Install dependencies
# Install musl
RUN apt-get update -y; apt-get install build-essential musl-tools musl musl-dev -y
# Run this also if you want gnu 32 bit instead of musl
#RUN apt-get install gcc-multilib -y
# Install nightly and musl target
RUN rustup toolchain install nightly
RUN rustup target add i686-unknown-linux-musl --toolchain nightly
#RUN rustup target add i686-unknown-linux-gnu --toolchain nightly
# Create simple project
RUN cargo init --bin; rustup override set nightly
RUN echo '#[tokio::main] async fn main() { println!("Response: {}", reqwest::get("https:/google.com/").await.unwrap().text().await.unwrap()); }' > src/main.rs
RUN echo "[package]\nname = \"app\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[profile.release]\nopt-level = 3\nlto = true\nstrip = true\ndebug=false\npanic = \"abort\"\n[dependencies]\ntokio = { version = \"*\", features = [\"full\"] }\nreqwest = { version = \"*\", default-features = false, features = [\"rustls-tls\"] }" > Cargo.toml
# Build with i686 musl in release
RUN cargo build --target i686-unknown-linux-musl --release
#RUN cargo build --target i686-unknown-linux-gnu --release
while testing with this i found out it just doesn't work with musl but works with gnu i just forgot to install gcc-multilib on my system and it also doesn't matter if --release is there or not.
also not working for me i need this to be fixed pls @briansmith
If you are having trouble with this, please write the full steps to reproduce, including the steps you used to install the C compiler, and the environment variables you set to tell cargo/cc-rs which C compiler to use.
I'm also having a compilation failure for this target (or rather, a linker error) when using zigbuild. Here are repro steps that only assume you have cargo and rustup installed; run the Zig installation instructions for the platform you are actually using:
mkdir issue-1795
cd issue-1795
# Download Zig (64-bit Linux)
wget 'https://ziglang.org/download/0.11.0/zig-linux-x86_64-0.11.0.tar.xz'
tar -Jxvf zig-linux-x86_64-0.11.0.tar.xz
export PATH="$PATH":$(pwd)/zig-linux-x86_64-0.11.0
# Download Zig (Apple Silicon)
wget 'https://ziglang.org/download/0.11.0/zig-macos-aarch64-0.11.0.tar.xz'
tar -Jxvf zig-macos-aarch64-0.11.0.tar.xz
export PATH="$PATH":$(pwd)/zig-macos-aarch64-0.11.0
# Install zigbuild and the i686 musl target
cargo install cargo-zigbuild
rustup target add i686-unknown-linux-musl
git clone https://github.com/briansmith/ring
cd ring
cargo zigbuild --target i686-unknown-linux-musl
I get the same error on both platforms I've tried (64-bit Linux and Apple Silicon):
The following warnings were emitted during compilation:
warning: [email protected]: error: unsupported linker arg: -melf_i386
It may also be informative to run cross-compilations for 32-bit Linux (non-musl) and 64-bit Linux (musl), which should both succeed:
rustup target add i686-unknown-linux-gnu
cargo zigbuild --target i686-unknown-linux-gnu
rustup target add x86_64-unknown-linux-musl
cargo zigbuild --target x86_64-unknown-linux-musl
workaround: It seems that apk add clang solves this... (ring 0.17.8)
As I said above, ring is tested in CI on both of these targets; see https://github.com/briansmith/ring/issues/1795#issuecomment-1800885945. I don't see any STR here that would help make progress on improving things, so I'm closing this. Please feel free to reopen with more clear STR.
@rschmitt RE: zigbuild, I don't know how to support zigbuild. Presumably it intends to work like our clang-based build. I don't plan to add zigbuild to our CI so it will be hard to help with zigbuild-specific issues.