[CRIU] [PATCH 4/4] scripts/build: add clang targets

Kir Kolyshkin kir at openvz.org
Tue Oct 25 21:46:40 PDT 2016


With this, one can do a CRUI build via QEMU+Docker using clang
as a compiler, for example:

	make -C scripts/build alpine-clang
	make -C scripts/build ppc64le-clang

For alpine, default clang version is used. For others, a version has
to be specified explicitly, as there is no package called "clang" in
Ubuntu Trusty (which is used as a base for most arches). Since
clang-3.8 appears to be available from Trusty, and this is the current
stable version of clang, let's use it.

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 scripts/build/Dockerfile.alpine |  6 ++++--
 scripts/build/Dockerfile.tmpl   |  9 ++++++---
 scripts/build/Makefile          | 13 +++++++++++--
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/scripts/build/Dockerfile.alpine b/scripts/build/Dockerfile.alpine
index ad356bc..c8f79dc 100644
--- a/scripts/build/Dockerfile.alpine
+++ b/scripts/build/Dockerfile.alpine
@@ -1,4 +1,5 @@
 FROM alpine:3.4
+ARG CC=gcc
 RUN apk update && apk add \
                 build-base \
                 coreutils \
@@ -9,7 +10,8 @@ RUN apk update && apk add \
                 libaio-dev \
                 libcap-dev \
                 libnl3-dev \
-                pkgconfig
+                pkgconfig \
+                $CC
 COPY . /criu
 WORKDIR /criu
-RUN make mrproper && make -j $(nproc)
+RUN make mrproper && make -j $(nproc) CC=$CC
diff --git a/scripts/build/Dockerfile.tmpl b/scripts/build/Dockerfile.tmpl
index 92518aa..34b4930 100644
--- a/scripts/build/Dockerfile.tmpl
+++ b/scripts/build/Dockerfile.tmpl
@@ -1,3 +1,5 @@
+ARG CC=gcc
+
 RUN apt-get clean
 
 RUN apt-get update
@@ -16,14 +18,15 @@ RUN apt-get install -y \
                 libnl-3-dev \
                 libselinux-dev \
                 pkg-config \
-                git-core
+                git-core \
+                $CC
 
 COPY . /criu
 WORKDIR /criu
 
 RUN make mrproper
-RUN make -j $(nproc) criu/parasite-syscall.o
-RUN make -j $(nproc)
+RUN make -j $(nproc) CC=$CC criu/parasite-syscall.o
+RUN make -j $(nproc) CC=$CC
 RUN make mrproper
 RUN bash -c 'CLEAN="$(git clean -ndx --exclude=scripts/build)"; echo "${CLEAN}"; test -z "${CLEAN}"; exit $?'
 #RUN make test/compel/handle_binary && ./test/compel/handle_binary
diff --git a/scripts/build/Makefile b/scripts/build/Makefile
index 1a3604d..996f655 100644
--- a/scripts/build/Makefile
+++ b/scripts/build/Makefile
@@ -12,10 +12,19 @@ binfmt_misc:
 .PHONY: binfmt_misc
 
 alpine:
-	docker build  -t criu-$@ -f Dockerfile.alpine ../..
+	docker build  -t criu-$@ -f Dockerfile.alpine $(DB_ARGS) ../..
 
 %: Dockerfile.% qemu-user-static binfmt_misc
-	docker build  -t criu-$@ -f $< ../..
+	docker build  -t criu-$@ -f $< $(DB_ARGS) ../..
+
+%-clang: DB_ARGS=--build-arg CC=clang-3.8
+alpine-clang: DB_ARGS=--build-arg CC=clang
+alpine-clang: alpine
+armv7hf-clang: armv7hf
+aarch64-clang: aarch64
+ppc64le-clang: ppc64le
+x86_64-clang: x86_64
+.PHONY: alpine-clang armv7hf-clang aarch64-clang ppc64le-clang x86_64-clang
 
 clean:
 	rm -rf qemu-user-static
-- 
2.7.4



More information about the CRIU mailing list