From 0ca36c95eebbdacb918723a7655c11acd5ab330b Mon Sep 17 00:00:00 2001 From: Adrian Reber Date: Mon, 5 Jul 2021 08:10:12 +0000 Subject: [PATCH] ci: combine cross compile container definitions The cross compile container definitions for each architecture were almost the same files except for the architecture. This moves the architecture to variables so that all cross compile setups can use the same container definition. Signed-off-by: Adrian Reber --- .gitignore | 1 - scripts/build/Dockerfile.aarch64-cross | 47 -------------------- scripts/build/Dockerfile.aarch64-cross.hdr | 5 +++ scripts/build/Dockerfile.aarch64-cross.tmpl | 1 + scripts/build/Dockerfile.armv7-cross | 46 ------------------- scripts/build/Dockerfile.armv7-cross.hdr | 6 +++ scripts/build/Dockerfile.armv7-cross.tmpl | 1 + scripts/build/Dockerfile.cross.tmpl | 43 ++++++++++++++++++ scripts/build/Dockerfile.mips64el-cross | 46 ------------------- scripts/build/Dockerfile.mips64el-cross.hdr | 6 +++ scripts/build/Dockerfile.mips64el-cross.tmpl | 1 + scripts/build/Dockerfile.ppc64-cross | 47 -------------------- scripts/build/Dockerfile.ppc64-cross.hdr | 5 +++ scripts/build/Dockerfile.ppc64-cross.tmpl | 1 + scripts/build/Makefile | 16 +++---- 15 files changed, 77 insertions(+), 195 deletions(-) delete mode 100644 scripts/build/Dockerfile.aarch64-cross create mode 100644 scripts/build/Dockerfile.aarch64-cross.hdr create mode 120000 scripts/build/Dockerfile.aarch64-cross.tmpl delete mode 100644 scripts/build/Dockerfile.armv7-cross create mode 100644 scripts/build/Dockerfile.armv7-cross.hdr create mode 120000 scripts/build/Dockerfile.armv7-cross.tmpl create mode 100644 scripts/build/Dockerfile.cross.tmpl delete mode 100644 scripts/build/Dockerfile.mips64el-cross create mode 100644 scripts/build/Dockerfile.mips64el-cross.hdr create mode 120000 scripts/build/Dockerfile.mips64el-cross.tmpl delete mode 100644 scripts/build/Dockerfile.ppc64-cross create mode 100644 scripts/build/Dockerfile.ppc64-cross.hdr create mode 120000 scripts/build/Dockerfile.ppc64-cross.tmpl diff --git a/.gitignore b/.gitignore index d5135f5f8..b9cd7cdc7 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,3 @@ lib/.crit-setup.files compel/include/asm include/common/asm include/common/config.h -build/ diff --git a/scripts/build/Dockerfile.aarch64-cross b/scripts/build/Dockerfile.aarch64-cross deleted file mode 100644 index d372b2c91..000000000 --- a/scripts/build/Dockerfile.aarch64-cross +++ /dev/null @@ -1,47 +0,0 @@ -FROM dockcross/base:latest - -COPY scripts/ci/apt-install /bin/apt-install - -# Add the cross compiler sources -RUN echo "deb http://ftp.us.debian.org/debian/ buster main" >> /etc/apt/sources.list && \ - dpkg --add-architecture arm64 && \ - apt-install emdebian-archive-keyring - -RUN apt-install \ - crossbuild-essential-arm64 \ - libc6-dev-arm64-cross \ - libc6-arm64-cross \ - libbz2-dev:arm64 \ - libexpat1-dev:arm64 \ - ncurses-dev:arm64 \ - libssl-dev:arm64 \ - protobuf-c-compiler \ - protobuf-compiler \ - python3-protobuf \ - libnl-3-dev:arm64 \ - libprotobuf-dev:arm64 \ - libnet-dev:arm64 \ - libprotobuf-c-dev:arm64 \ - libcap-dev:arm64 \ - libaio-dev:arm64 \ - libnl-route-3-dev:arm64 - -ENV CROSS_TRIPLE=aarch64-linux-gnu -ENV CROSS_COMPILE=${CROSS_TRIPLE}- \ - CROSS_ROOT=/usr/${CROSS_TRIPLE} \ - AS=/usr/bin/${CROSS_TRIPLE}-as \ - AR=/usr/bin/${CROSS_TRIPLE}-ar \ - CC=/usr/bin/${CROSS_TRIPLE}-gcc \ - CPP=/usr/bin/${CROSS_TRIPLE}-cpp \ - CXX=/usr/bin/${CROSS_TRIPLE}-g++ \ - LD=/usr/bin/${CROSS_TRIPLE}-ld \ - FC=/usr/bin/${CROSS_TRIPLE}-gfortran - -ENV PATH="${PATH}:${CROSS_ROOT}/bin" \ - PKG_CONFIG_PATH=/usr/lib/${CROSS_TRIPLE}/pkgconfig \ - ARCH=aarch64 - -COPY . /criu -WORKDIR /criu - -RUN make mrproper && date && make -j $(nproc) zdtm && date diff --git a/scripts/build/Dockerfile.aarch64-cross.hdr b/scripts/build/Dockerfile.aarch64-cross.hdr new file mode 100644 index 000000000..c61d2af27 --- /dev/null +++ b/scripts/build/Dockerfile.aarch64-cross.hdr @@ -0,0 +1,5 @@ +FROM docker.io/dockcross/base:latest + +ENV ARCH=aarch64 +ENV DEBIAN_ARCH=arm64 +ENV CROSS_TRIPLET=aarch64-linux-gnu diff --git a/scripts/build/Dockerfile.aarch64-cross.tmpl b/scripts/build/Dockerfile.aarch64-cross.tmpl new file mode 120000 index 000000000..50eff9213 --- /dev/null +++ b/scripts/build/Dockerfile.aarch64-cross.tmpl @@ -0,0 +1 @@ +Dockerfile.cross.tmpl \ No newline at end of file diff --git a/scripts/build/Dockerfile.armv7-cross b/scripts/build/Dockerfile.armv7-cross deleted file mode 100644 index b3a18d0ec..000000000 --- a/scripts/build/Dockerfile.armv7-cross +++ /dev/null @@ -1,46 +0,0 @@ -FROM dockcross/base:latest - -COPY scripts/ci/apt-install /bin/apt-install - -# Add the cross compiler sources -RUN echo "deb http://ftp.us.debian.org/debian/ buster main" >> /etc/apt/sources.list && \ - dpkg --add-architecture armhf && \ - apt-install emdebian-archive-keyring - -RUN apt-install \ - crossbuild-essential-armhf \ - libbz2-dev:armhf \ - libexpat1-dev:armhf \ - ncurses-dev:armhf \ - libssl-dev:armhf \ - protobuf-c-compiler \ - protobuf-compiler \ - python3-protobuf \ - libnl-3-dev:armhf \ - libprotobuf-dev:armhf \ - libnet-dev:armhf \ - libprotobuf-c-dev:armhf \ - libcap-dev:armhf \ - libaio-dev:armhf \ - libnl-route-3-dev:armhf - -ENV CROSS_TRIPLE=arm-linux-gnueabihf -ENV CROSS_COMPILE=${CROSS_TRIPLE}- \ - CROSS_ROOT=/usr/${CROSS_TRIPLE} \ - AS=/usr/bin/${CROSS_TRIPLE}-as \ - AR=/usr/bin/${CROSS_TRIPLE}-ar \ - CC=/usr/bin/${CROSS_TRIPLE}-gcc \ - CPP=/usr/bin/${CROSS_TRIPLE}-cpp \ - CXX=/usr/bin/${CROSS_TRIPLE}-g++ \ - LD=/usr/bin/${CROSS_TRIPLE}-ld \ - FC=/usr/bin/${CROSS_TRIPLE}-gfortran - -ENV PATH="${PATH}:${CROSS_ROOT}/bin" \ - PKG_CONFIG_PATH=/usr/lib/${CROSS_TRIPLE}/pkgconfig \ - ARCH=arm \ - SUBARCH=armv7 - -COPY . /criu -WORKDIR /criu - -RUN make mrproper && date && make -j $(nproc) zdtm && date diff --git a/scripts/build/Dockerfile.armv7-cross.hdr b/scripts/build/Dockerfile.armv7-cross.hdr new file mode 100644 index 000000000..f96dc51f7 --- /dev/null +++ b/scripts/build/Dockerfile.armv7-cross.hdr @@ -0,0 +1,6 @@ +FROM docker.io/dockcross/base:latest + +ENV ARCH=arm +ENV SUBARCH=armv7 +ENV DEBIAN_ARCH=armhf +ENV CROSS_TRIPLET=arm-linux-gnueabihf diff --git a/scripts/build/Dockerfile.armv7-cross.tmpl b/scripts/build/Dockerfile.armv7-cross.tmpl new file mode 120000 index 000000000..50eff9213 --- /dev/null +++ b/scripts/build/Dockerfile.armv7-cross.tmpl @@ -0,0 +1 @@ +Dockerfile.cross.tmpl \ No newline at end of file diff --git a/scripts/build/Dockerfile.cross.tmpl b/scripts/build/Dockerfile.cross.tmpl new file mode 100644 index 000000000..8b95fbb1c --- /dev/null +++ b/scripts/build/Dockerfile.cross.tmpl @@ -0,0 +1,43 @@ +COPY scripts/ci/apt-install /bin/apt-install + +# Add the cross compiler sources +RUN echo "deb http://deb.debian.org/debian/ buster main" >> /etc/apt/sources.list && \ + dpkg --add-architecture ${DEBIAN_ARCH} && \ + apt-install emdebian-archive-keyring + +RUN apt-install \ + crossbuild-essential-${DEBIAN_ARCH} \ + libc6-dev-${DEBIAN_ARCH}-cross \ + libc6-${DEBIAN_ARCH}-cross \ + libbz2-dev:${DEBIAN_ARCH} \ + libexpat1-dev:${DEBIAN_ARCH} \ + ncurses-dev:${DEBIAN_ARCH} \ + libssl-dev:${DEBIAN_ARCH} \ + protobuf-c-compiler \ + protobuf-compiler \ + python3-protobuf \ + libnl-3-dev:${DEBIAN_ARCH} \ + libprotobuf-dev:${DEBIAN_ARCH} \ + libnet-dev:${DEBIAN_ARCH} \ + libprotobuf-c-dev:${DEBIAN_ARCH} \ + libcap-dev:${DEBIAN_ARCH} \ + libaio-dev:${DEBIAN_ARCH} \ + libnl-route-3-dev:${DEBIAN_ARCH} + +ENV CROSS_COMPILE=${CROSS_TRIPLET}- \ + CROSS_ROOT=/usr/${CROSS_TRIPLET} \ + AS=/usr/bin/${CROSS_TRIPLET}-as \ + AR=/usr/bin/${CROSS_TRIPLET}-ar \ + CC=/usr/bin/${CROSS_TRIPLET}-gcc \ + CPP=/usr/bin/${CROSS_TRIPLET}-cpp \ + CXX=/usr/bin/${CROSS_TRIPLET}-g++ \ + LD=/usr/bin/${CROSS_TRIPLET}-ld \ + FC=/usr/bin/${CROSS_TRIPLET}-gfortran + +ENV PATH="${PATH}:${CROSS_ROOT}/bin" \ + PKG_CONFIG_PATH=/usr/lib/${CROSS_TRIPLET}/pkgconfig + +COPY . /criu +WORKDIR /criu + +RUN make mrproper && date && make -j $(nproc) zdtm && date diff --git a/scripts/build/Dockerfile.mips64el-cross b/scripts/build/Dockerfile.mips64el-cross deleted file mode 100644 index 6f0f32820..000000000 --- a/scripts/build/Dockerfile.mips64el-cross +++ /dev/null @@ -1,46 +0,0 @@ -FROM dockcross/base:latest - -COPY scripts/ci/apt-install /bin/apt-install - -# Add the cross compiler sources -RUN echo "deb http://ftp.us.debian.org/debian/ buster main" >> /etc/apt/sources.list && \ - dpkg --add-architecture mips64el && \ - apt-install emdebian-archive-keyring - -RUN apt-install \ - crossbuild-essential-mips64el \ - libbz2-dev:mips64el \ - libexpat1-dev:mips64el \ - ncurses-dev:mips64el \ - libssl-dev:mips64el \ - protobuf-c-compiler \ - protobuf-compiler \ - python3-protobuf \ - libnl-3-dev:mips64el \ - libprotobuf-dev:mips64el \ - libnet-dev:mips64el \ - libprotobuf-c-dev:mips64el \ - libcap-dev:mips64el \ - libaio-dev:mips64el \ - libnl-route-3-dev:mips64el - -ENV CROSS_TRIPLE=mips64el-linux-gnuabi64 -ENV CROSS_COMPILE=${CROSS_TRIPLE}- \ - CROSS_ROOT=/usr/${CROSS_TRIPLE} \ - AS=/usr/bin/${CROSS_TRIPLE}-as \ - AR=/usr/bin/${CROSS_TRIPLE}-ar \ - CC=/usr/bin/${CROSS_TRIPLE}-gcc \ - CPP=/usr/bin/${CROSS_TRIPLE}-cpp \ - CXX=/usr/bin/${CROSS_TRIPLE}-g++ \ - LD=/usr/bin/${CROSS_TRIPLE}-ld \ - FC=/usr/bin/${CROSS_TRIPLE}-gfortran - -ENV PATH="${PATH}:${CROSS_ROOT}/bin" \ - PKG_CONFIG_PATH=/usr/lib/${CROSS_TRIPLE}/pkgconfig \ - ARCH=mips \ - SUBARCH=mips - -COPY . /criu -WORKDIR /criu - -RUN make mrproper && date && make -j $(nproc) zdtm && date diff --git a/scripts/build/Dockerfile.mips64el-cross.hdr b/scripts/build/Dockerfile.mips64el-cross.hdr new file mode 100644 index 000000000..e78c94aa5 --- /dev/null +++ b/scripts/build/Dockerfile.mips64el-cross.hdr @@ -0,0 +1,6 @@ +FROM dockcross/base:latest + +ENV ARCH=mips +ENV SUBARCH=mips +ENV DEBIAN_ARCH=mips64el +ENV CROSS_TRIPLET=mips64el-linux-gnuabi64 diff --git a/scripts/build/Dockerfile.mips64el-cross.tmpl b/scripts/build/Dockerfile.mips64el-cross.tmpl new file mode 120000 index 000000000..50eff9213 --- /dev/null +++ b/scripts/build/Dockerfile.mips64el-cross.tmpl @@ -0,0 +1 @@ +Dockerfile.cross.tmpl \ No newline at end of file diff --git a/scripts/build/Dockerfile.ppc64-cross b/scripts/build/Dockerfile.ppc64-cross deleted file mode 100644 index eaa4e4ea2..000000000 --- a/scripts/build/Dockerfile.ppc64-cross +++ /dev/null @@ -1,47 +0,0 @@ -FROM dockcross/base:latest - -COPY scripts/ci/apt-install /bin/apt-install - -# Add the cross compiler sources -RUN echo "deb http://ftp.us.debian.org/debian/ buster main" >> /etc/apt/sources.list && \ - dpkg --add-architecture ppc64el && \ - apt-install emdebian-archive-keyring - -RUN apt-install \ - crossbuild-essential-ppc64el \ - libc6-dev-ppc64el-cross \ - libc6-ppc64el-cross \ - libbz2-dev:ppc64el \ - libexpat1-dev:ppc64el \ - ncurses-dev:ppc64el \ - libssl-dev:ppc64el \ - protobuf-c-compiler \ - protobuf-compiler \ - python3-protobuf \ - libnl-3-dev:ppc64el \ - libprotobuf-dev:ppc64el \ - libnet-dev:ppc64el \ - libprotobuf-c-dev:ppc64el \ - libcap-dev:ppc64el \ - libaio-dev:ppc64el \ - libnl-route-3-dev:ppc64el - -ENV CROSS_TRIPLE=powerpc64le-linux-gnu -ENV CROSS_COMPILE=${CROSS_TRIPLE}- \ - CROSS_ROOT=/usr/${CROSS_TRIPLE} \ - AS=/usr/bin/${CROSS_TRIPLE}-as \ - AR=/usr/bin/${CROSS_TRIPLE}-ar \ - CC=/usr/bin/${CROSS_TRIPLE}-gcc \ - CPP=/usr/bin/${CROSS_TRIPLE}-cpp \ - CXX=/usr/bin/${CROSS_TRIPLE}-g++ \ - LD=/usr/bin/${CROSS_TRIPLE}-ld \ - FC=/usr/bin/${CROSS_TRIPLE}-gfortran - -ENV PATH="${PATH}:${CROSS_ROOT}/bin" \ - PKG_CONFIG_PATH=/usr/lib/${CROSS_TRIPLE}/pkgconfig \ - ARCH=ppc64 - -COPY . /criu -WORKDIR /criu - -RUN make mrproper && date && make -j $(nproc) zdtm && date diff --git a/scripts/build/Dockerfile.ppc64-cross.hdr b/scripts/build/Dockerfile.ppc64-cross.hdr new file mode 100644 index 000000000..38547ac55 --- /dev/null +++ b/scripts/build/Dockerfile.ppc64-cross.hdr @@ -0,0 +1,5 @@ +FROM dockcross/base:latest + +ENV ARCH=ppc64 +ENV DEBIAN_ARCH=ppc64el +ENV CROSS_TRIPLET=powerpc64le-linux-gnu diff --git a/scripts/build/Dockerfile.ppc64-cross.tmpl b/scripts/build/Dockerfile.ppc64-cross.tmpl new file mode 120000 index 000000000..50eff9213 --- /dev/null +++ b/scripts/build/Dockerfile.ppc64-cross.tmpl @@ -0,0 +1 @@ +Dockerfile.cross.tmpl \ No newline at end of file diff --git a/scripts/build/Makefile b/scripts/build/Makefile index b6c6477f3..8e6e3c27c 100644 --- a/scripts/build/Makefile +++ b/scripts/build/Makefile @@ -1,26 +1,26 @@ ARCHES := x86_64 fedora-asan fedora-rawhide centos7 armv7hf centos8 +NON_CLANG := armv7-cross aarch64-cross ppc64-cross mips64el-cross +CREATE_DOCKERFILES := $(ARCHES) $(NON_CLANG) TARGETS := $(ARCHES) alpine TARGETS_CLANG := $(addsuffix $(TARGETS),-clang) CONTAINER_RUNTIME := docker +CONTAINER_TARGETS := $(TARGETS) $(NON_CLANG) -TARGETS += armv7-cross aarch64-cross ppc64-cross mips64el-cross - - -all: $(TARGETS) $(TARGETS_CLANG) +all: $(CONTAINER_TARGETS) $(TARGETS_CLANG) .PHONY: all # A build for each architecture requires appropriate Dockerfile -define ARCH_DEP +define FILE_DEP $(1): Dockerfile.$(1) endef -$(foreach arch,$(ARCHES),$(eval $(call ARCH_DEP,$(arch)))) +$(foreach file,$(CREATE_DOCKERFILES),$(eval $(call FILE_DEP,$(file)))) Dockerfile.%: Dockerfile.%.hdr Dockerfile.%.tmpl cat $^ > $@ -$(TARGETS): +$(CONTAINER_TARGETS): $(CONTAINER_RUNTIME) build -t criu-$@ -f Dockerfile.$@ $(DB_CC) ../.. -.PHONY: $(TARGETS) +.PHONY: $(CONTAINER_TARGETS) # Clang builds add some Docker build env define CLANG_DEP