From bc0b7bd26e08ba744b8b6009ff0684939f7b34d9 Mon Sep 17 00:00:00 2001 From: Alexey Orlenko Date: Fri, 2 Jun 2023 21:26:27 +0200 Subject: [PATCH] Add experimental ARM cross compile image based on zigbuild Currently it can successfully cross compile and link shared OpenSSL, and cross compile the query engine, but linking fails with: ``` error: linking with `/root/.cache/cargo-zigbuild/0.16.10/zigcc-aarch64-unknown-linux-gnu.2.17.sh` failed: exit status: 1 | = note: LC_ALL="C" PATH="/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/opt/zig-linux-x86_64-0.11.0-dev.3348+3faf376b0:/opt/cross/zig-linux-x86_64-0.11.0-dev.3348+3faf376b0:/root/.cargo/bin:/usr/local/lib/python3.11/dist-packages/ziglang:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "/root/.cache/cargo-zigbuild/0.16.10/zigcc-aarch64-unknown-linux-gnu.2.17.sh" "/tmp/rustcELa8b4/symbols.o" "/engines/target/aarch64-unknown-linux-gnu/release/deps/query_engine-9d1919b2d160d96a.query_engine.d22a280a-cgu.0.rcgu.o" "-Wl,--as-needed" "-L" "/engines/target/aarch64-unknown-linux-gnu/release/deps" "-L" "/engines/target/release/deps" "-L" "/engines/target/aarch64-unknown-linux-gnu/release/build/ring-297fc3656113f209/out" "-L" "/engines/target/aarch64-unknown-linux-gnu/release/build/libsqlite3-sys-af7b3a4558256ab0/out" "-L" "/engines/target/aarch64-unknown-linux-gnu/release/build/libz-sys-27081a34b01142db/out/lib" "-L" "/engines/target/aarch64-unknown-linux-gnu/release/build/libz-sys-27081a34b01142db/out/lib" "-L" "/opt/cross/lib" "-L" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/tmp/rustcELa8b4/libring-634b5236e555c431.rlib" "/tmp/rustcELa8b4/liblibsqlite3_sys-c0f45f8017beeed7.rlib" "/tmp/rustcELa8b4/liblibz_sys-36ff76decbe5dfac.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libcompiler_builtins-25887170a022cc00.rlib" "-Wl,-Bdynamic" "-lssl" "-lcrypto" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-o" "/engines/target/aarch64-unknown-linux-gnu/release/deps/query_engine-9d1919b2d160d96a" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,--strip-all" "-nodefaultlibs" = note: ld.lld: error: undefined symbol: fcntl@GLIBC_2.2.5 >>> referenced by sqlite3.c >>> sqlite3.o:(aSyscall) in archive /tmp/rustcELa8b4/liblibsqlite3_sys-c0f45f8017beeed7.rlib >>> did you mean: fcntl >>> defined in: /root/.cache/zig/o/09512143defbe5a5bbd3426ded948a1a/libpthread.so.0 ``` --- cross/linux-glibc-arm64.Dockerfile | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 cross/linux-glibc-arm64.Dockerfile diff --git a/cross/linux-glibc-arm64.Dockerfile b/cross/linux-glibc-arm64.Dockerfile new file mode 100644 index 0000000..b764b74 --- /dev/null +++ b/cross/linux-glibc-arm64.Dockerfile @@ -0,0 +1,38 @@ +FROM debian:bookworm + +RUN apt-get -y update && apt-get -y upgrade +RUN apt-get -y install curl git + +ARG ZIG_VERSION=0.11.0-dev.3348+3faf376b0 +RUN cd /opt && curl -O https://ziglang.org/builds/zig-linux-x86_64-${ZIG_VERSION}.tar.xz && \ + tar xJf zig-linux-x86_64-${ZIG_VERSION}.tar.xz +ENV PATH=/opt/zig-linux-x86_64-${ZIG_VERSION}:$PATH + +ENV PATH=/root/.cargo/bin:/usr/local/lib/python3.11/dist-packages/ziglang:$PATH +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y +RUN rustup target add aarch64-unknown-linux-gnu + +RUN cargo install cargo-zigbuild + +ENV CC="zig cc -target aarch64-linux-gnu.2.17" +ENV CXX="zig c++ -target aarch64-linux-gnu.2.17" +ENV AS="zig as -target aarch64-linux-gnu.2.17" +ENV AR="zig ar" +ENV RANLIB="zig ranlib" + +ARG OPENSSL_1_1_VERSION=1.1.1u +ARG OPENSSL_3_0_VERSION=3.0.9 + +# Accepts 1.1.x or 3.0.x as a build arg +# ARG OPENSSL_VARIANT=3.0.x + +ENV OPENSSL_VERSION=${OPENSSL_3_0_VERSION} + +RUN curl -fLO https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz && \ + tar xzf openssl-$OPENSSL_VERSION.tar.gz + +RUN cd openssl-$OPENSSL_VERSION && \ + ./Configure shared linux-aarch64 no-tests --prefix=/opt/cross --openssldir=/opt/cross && \ + make -j8 && make install_sw install_ssldirs + +ENV OPENSSL_DIR=/opt/cross