From e9596486d8bb1f904e6c5721f01c81ebeb8632c7 Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:57:41 +0900 Subject: [PATCH] fix: builders (#159) * fix cosmos messages * fix debian build * rollback shared libraries * remove redundant line --- Makefile | 2 +- README.md | 2 +- builders/Dockerfile.centos7 | 91 ------------------------------------- builders/Dockerfile.debian | 66 +++++++++++++++++++++++++++ builders/Makefile | 10 ++-- 5 files changed, 73 insertions(+), 98 deletions(-) delete mode 100644 builders/Dockerfile.centos7 create mode 100644 builders/Dockerfile.debian diff --git a/Makefile b/Makefile index a43891bb..06e6252c 100644 --- a/Makefile +++ b/Makefile @@ -154,7 +154,7 @@ release-build-linux: rm -rf target/release docker run --rm -u $(USER_ID):$(USER_GROUP) \ -v $(shell pwd):/code/ \ - $(BUILDERS_PREFIX)-centos7 + $(BUILDERS_PREFIX)-debian cp artifacts/libmovevm.x86_64.so api cp artifacts/libmovevm.aarch64.so api cp artifacts/libcompiler.x86_64.so api diff --git a/README.md b/README.md index ad4a437f..e7c22701 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Requires **Rust 1.80+ and Go 1.22+.** The Rust implementation of the VM is compiled to a library called libmovevm. This is then linked to the Go code when the final binary is built. For that reason not all systems supported by Go are supported by this project. -Linux (tested on CentOS7 and Alpine) and macOS are supported. +Linux (tested on Ubuntu, Debian, and Alpine) and macOS are supported. ### Builds of libmovevm diff --git a/builders/Dockerfile.centos7 b/builders/Dockerfile.centos7 deleted file mode 100644 index 5b2bb0d7..00000000 --- a/builders/Dockerfile.centos7 +++ /dev/null @@ -1,91 +0,0 @@ -FROM centos:centos7 - -RUN yum -y update \ - && yum -y install clang gcc gcc-c++ make wget \ - # Obtain dependencies for cross compiling - # The only prebuilt glibc was done by third party Computational - && yum -y install epel-release \ - # See https://centos.pkgs.org/7/epel-aarch64/gcc-aarch64-linux-gnu-4.8.5-16.el7.1.aarch64.rpm.html - # and https://centos.pkgs.org/7/epel-aarch64/gcc-c++-aarch64-linux-gnu-4.8.5-16.el7.1.aarch64.rpm.html: - # "Support for cross-building user space programs is not currently provided as that would massively multiply - # the number of packages." - && yum -y install gcc-aarch64-linux-gnu gcc-c++-aarch64-linux-gnu \ - # See https://stackoverflow.com/a/64920961 - && wget http://springdale.princeton.edu/data/springdale/7/x86_64/os/Computational/glibc-aarch64-linux-gnu-2.24-2.sdl7.2.noarch.rpm \ - && sha256sum glibc-aarch64-linux-gnu-2.24-2.sdl7.2.noarch.rpm | grep 8caf8654ba0c15e1792bf0aaa1ac0cd4ad94ac905e97d6ea0f0e56e9ca1f5e78 \ - && wget http://springdale.princeton.edu/data/springdale/7/x86_64/os/Computational/glibc-aarch64-linux-gnu-devel-2.24-2.sdl7.2.noarch.rpm \ - && sha256sum glibc-aarch64-linux-gnu-devel-2.24-2.sdl7.2.noarch.rpm | grep bf050dc2389630f50e90f4cdaf6e4e1d986e89dcd2c8432f72738abe38b3bce2 \ - && yum install -y glibc-aarch64-linux-gnu-2.24-2.sdl7.2.noarch.rpm \ - && yum install -y glibc-aarch64-linux-gnu-devel-2.24-2.sdl7.2.noarch.rpm \ - && rm glibc-aarch64-*.rpm \ - && yum install -y pkg-config perl - -# GET FROM https://github.com/rust-lang/docker-rust-nightly -ENV RUSTUP_HOME=/usr/local/rustup \ - CARGO_HOME=/usr/local/cargo \ - PATH=/usr/local/cargo/bin:$PATH - -RUN wget "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init" \ - && chmod +x rustup-init \ - && ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.80.1 \ - && rm rustup-init \ - && chmod -R a+w $RUSTUP_HOME $CARGO_HOME \ - && rustup --version \ - && cargo --version \ - && rustc --version - -# Add aarch64 as a target of compilation -RUN rustup target add aarch64-unknown-linux-gnu - -# allow non-root user to download more deps later -RUN chmod -R 777 /usr/local/cargo - -## COPY BUILD SCRIPTS - -WORKDIR /code - -COPY guest/*.sh /opt/ -RUN chmod +x /opt/*.sh - -RUN mkdir /.cargo -RUN chmod +rx /.cargo -COPY guest/cargo-config /.cargo/config - -# Copy the missing library libgcc_s.so that gcc does not provide -RUN wget http://mirror.centos.org/altarch/7/os/aarch64/Packages/libgcc-4.8.5-44.el7.aarch64.rpm \ - && sha256sum libgcc-4.8.5-44.el7.aarch64.rpm | grep 4f44c5be70ed9d8d74c2a616cde92a842b15eefaccd766959e5fbd7fbe965d2d \ - && rpm2cpio libgcc-4.8.5-44.el7.aarch64.rpm | cpio -idmv \ - && cp /code/lib64/libgcc_s-4.8.5-20150702.so.1 /usr/lib/gcc/aarch64-linux-gnu/4.8.5/libgcc_s.so \ - && rm libgcc-*.el7.aarch64.rpm - -############# -## OPENSSL ## -############# - -RUN wget "https://www.openssl.org/source/openssl-1.1.1k.tar.gz" - -# Install openssl for x86_64. This is required by Move -RUN tar -zxvf ./openssl-1.1.1k.tar.gz \ - && cd openssl-1.1.1k \ - && INSTALL_DIR="/opt/x86_64-openssl" \ - && ./Configure linux-x86_64 --prefix="$INSTALL_DIR" threads no-shared \ - && make -j$(nproc) \ - && make install_sw \ - && cd .. \ - && rm -rf ./openssl-1.1.1k - -# Install openssl for cross-compilation. This is required by Move -RUN tar -zxvf ./openssl-1.1.1k.tar.gz \ - && cd openssl-1.1.1k \ - && INSTALL_DIR="/opt/aarch64-openssl" \ - && ./Configure linux-aarch64 --cross-compile-prefix=aarch64-linux-gnu- --prefix="$INSTALL_DIR" threads no-shared \ - && make -j$(nproc) \ - && make install_sw \ - && cd .. \ - && rm -rf ./openssl-1.1.1k - -RUN rm ./openssl-1.1.1k.tar.gz - -WORKDIR /code - -CMD ["/opt/build_linux.sh"] diff --git a/builders/Dockerfile.debian b/builders/Dockerfile.debian new file mode 100644 index 00000000..a6c263ba --- /dev/null +++ b/builders/Dockerfile.debian @@ -0,0 +1,66 @@ +# Use a debian version that is old enough to lead to a low +# glibc requirement of builds. +# Debian 11 "Bullseye" has long-term support until August 31st, 2026 +FROM --platform=linux/amd64 debian:11-slim + +RUN apt update -y \ + && apt install -y gcc make gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu wget perl + +# GET FROM https://github.com/rust-lang/docker-rust-nightly +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH + +RUN wget --no-verbose "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init" \ + && chmod +x rustup-init \ + && ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.80.1 \ + && rm rustup-init \ + && chmod -R a+w $RUSTUP_HOME $CARGO_HOME \ + && rustup --version \ + && cargo --version \ + && rustc --version \ + && chmod -R 777 /usr/local/cargo \ + && rustup target add aarch64-unknown-linux-gnu + +## COPY BUILD SCRIPTS + +WORKDIR /code + +COPY guest/*.sh /opt/ +RUN chmod +x /opt/*.sh + +RUN mkdir /.cargo +RUN chmod +rx /.cargo +COPY guest/cargo-config /.cargo/config + +############# +## OPENSSL ## +############# + +RUN wget "https://www.openssl.org/source/openssl-1.1.1k.tar.gz" + +# Install openssl for x86_64. This is required by Move +RUN tar -zxvf ./openssl-1.1.1k.tar.gz \ + && cd openssl-1.1.1k \ + && INSTALL_DIR="/opt/x86_64-openssl" \ + && ./Configure linux-x86_64 --prefix="$INSTALL_DIR" threads no-shared \ + && make -j$(nproc) \ + && make install_sw \ + && cd .. \ + && rm -rf ./openssl-1.1.1k + +# Install openssl for cross-compilation. This is required by Move +RUN tar -zxvf ./openssl-1.1.1k.tar.gz \ + && cd openssl-1.1.1k \ + && INSTALL_DIR="/opt/aarch64-openssl" \ + && ./Configure linux-aarch64 --cross-compile-prefix=aarch64-linux-gnu- --prefix="$INSTALL_DIR" threads no-shared \ + && make -j$(nproc) \ + && make install_sw \ + && cd .. \ + && rm -rf ./openssl-1.1.1k + +RUN rm ./openssl-1.1.1k.tar.gz + +WORKDIR /code + +CMD ["/opt/build_linux.sh"] diff --git a/builders/Makefile b/builders/Makefile index 82b1279c..b692525b 100644 --- a/builders/Makefile +++ b/builders/Makefile @@ -1,8 +1,8 @@ BUILDERS_PREFIX := initia/go-ext-builder:0001 -.PHONY: docker-image-centos7 -docker-image-centos7: - docker build --pull . -t $(BUILDERS_PREFIX)-centos7 -f ./Dockerfile.centos7 +.PHONY: docker-image-debian +docker-image-debian: + docker build --pull . -t $(BUILDERS_PREFIX)-debian -f ./Dockerfile.debian .PHONY: docker-image-cross docker-image-cross: @@ -13,10 +13,10 @@ docker-image-alpine: docker build --pull . -t $(BUILDERS_PREFIX)-alpine -f ./Dockerfile.alpine .PHONY: docker-images -docker-images: docker-image-centos7 docker-image-cross docker-image-alpine +docker-images: docker-image-debian docker-image-cross docker-image-alpine .PHONY: docker-publish docker-publish: docker-images docker push $(BUILDERS_PREFIX)-cross - docker push $(BUILDERS_PREFIX)-centos7 + docker push $(BUILDERS_PREFIX)-debian docker push $(BUILDERS_PREFIX)-alpine