2017-07-14 15:41:14 +02:00
|
|
|
QEMU_ARCHES := armv7hf aarch64 ppc64le s390x # require qemu
|
2017-03-15 16:17:21 -07:00
|
|
|
ARCHES := $(QEMU_ARCHES) x86_64
|
2017-03-30 02:34:01 +03:00
|
|
|
TARGETS := $(ARCHES) alpine fedora-asan
|
2017-03-15 16:17:21 -07:00
|
|
|
TARGETS_CLANG := $(addsuffix $(TARGETS),-clang)
|
|
|
|
|
|
|
|
all: $(TARGETS) $(TARGETS_CLANG)
|
|
|
|
.PHONY: all
|
|
|
|
|
|
|
|
# A build for each architecture requires appropriate Dockerfile
|
|
|
|
define ARCH_DEP
|
|
|
|
$(1): Dockerfile.$(1)
|
|
|
|
endef
|
|
|
|
$(foreach arch,$(ARCHES),$(eval $(call ARCH_DEP,$(arch))))
|
2016-02-18 20:41:08 +03:00
|
|
|
|
2016-02-23 05:44:00 +03:00
|
|
|
Dockerfile.%: Dockerfile.%.hdr Dockerfile.tmpl
|
|
|
|
cat $^ > $@
|
2016-02-18 20:41:08 +03:00
|
|
|
|
2016-02-15 15:26:59 +03:00
|
|
|
qemu-user-static:
|
|
|
|
./extract-deb-pkg qemu-user-static
|
|
|
|
|
2016-02-24 12:29:57 -08:00
|
|
|
binfmt_misc:
|
2016-02-18 20:41:06 +03:00
|
|
|
./binfmt_misc
|
2016-02-24 12:29:57 -08:00
|
|
|
.PHONY: binfmt_misc
|
2016-02-15 15:26:59 +03:00
|
|
|
|
2017-03-15 16:17:21 -07:00
|
|
|
$(QEMU_ARCHES): qemu-user-static binfmt_misc
|
|
|
|
|
|
|
|
$(TARGETS):
|
travis: enable ccache for docker/qemu builds
As we compile-test non-x86_64 architectures under qemu emulation,
it works pretty slow.
Dmitry Safonov suggested, and Andrey Vagin initially implemented
supporting ccache for such builds. This patch is based heavily
on Andrey's work -- all the bugs added are purely mine though.
Performance results: in an ideal environment (two builds of the same
code, one with cold (empty) ccache, another with the hot one)
I saw compile time improvements of 4x to 5x, and total test run time
improvement up to 2x to 2.5x. In layman terms, the complete test run
that was taking more than 50 minutes now takes about 25!
Notes on handling .ccache directory:
1. Before running docker build, .ccache directory (saved in between
runs by Travis) is moved to criu source code root, from where it
is copied by docker together with criu sources.
2. In Dockerfile, .ccache gets moved to /tmp, and CCACHE_DIR
is set accordingly.
3. After running docker build, .ccache is copied out from docker
container back to the host (from where it is saved by Travis).
Ccache envorinment notes:
1. CCACHE_NOCOMPRESS is needed because otherwise tons of time is spent
on compression/decompression (big performance hit under qemu).
2. CCACHE_CPP2 is required with clang, see detailed explanation at
http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html
The logic of setting CCACHE_CPP2 in Dockerfile is somewhat fancy;
unfortunately I was not able to come up with a simpler approach.
Misc:
1. Travis runs "ccache -s" after the build is completed. A call to
"ccache -s" is called to Dockerfile before make, so one can
compare before/after numbers.
2. make invocations are surrounded by "date" calls so one can get the
compilation times.
Changes in v2:
- consolidate Dockerfile statements (ENV, RUN)
- single object make test is no longer commented out
- simplify "make mrproper" test
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-16 14:27:36 -07:00
|
|
|
mkdir -p $(HOME)/.ccache
|
|
|
|
mv $(HOME)/.ccache ../../
|
|
|
|
docker build -t criu-$@ -f Dockerfile.$@ $(DB_CC) $(DB_ENV) ../..
|
|
|
|
docker run criu-$@ tar c -C /tmp .ccache | tar x -C $(HOME)
|
2017-03-15 16:17:21 -07:00
|
|
|
.PHONY: $(TARGETS)
|
2016-07-08 02:18:53 +03:00
|
|
|
|
2017-03-15 16:17:21 -07:00
|
|
|
# Clang builds add some Docker build env
|
|
|
|
define CLANG_DEP
|
|
|
|
$(1)-clang: $(1)
|
|
|
|
endef
|
|
|
|
$(foreach t,$(TARGETS),$(eval $(call CLANG_DEP,$(t))))
|
2016-10-25 21:46:40 -07:00
|
|
|
|
2017-10-01 17:34:03 -07:00
|
|
|
%-clang: DB_CC=--build-arg CC=clang
|
travis: enable ccache for docker/qemu builds
As we compile-test non-x86_64 architectures under qemu emulation,
it works pretty slow.
Dmitry Safonov suggested, and Andrey Vagin initially implemented
supporting ccache for such builds. This patch is based heavily
on Andrey's work -- all the bugs added are purely mine though.
Performance results: in an ideal environment (two builds of the same
code, one with cold (empty) ccache, another with the hot one)
I saw compile time improvements of 4x to 5x, and total test run time
improvement up to 2x to 2.5x. In layman terms, the complete test run
that was taking more than 50 minutes now takes about 25!
Notes on handling .ccache directory:
1. Before running docker build, .ccache directory (saved in between
runs by Travis) is moved to criu source code root, from where it
is copied by docker together with criu sources.
2. In Dockerfile, .ccache gets moved to /tmp, and CCACHE_DIR
is set accordingly.
3. After running docker build, .ccache is copied out from docker
container back to the host (from where it is saved by Travis).
Ccache envorinment notes:
1. CCACHE_NOCOMPRESS is needed because otherwise tons of time is spent
on compression/decompression (big performance hit under qemu).
2. CCACHE_CPP2 is required with clang, see detailed explanation at
http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html
The logic of setting CCACHE_CPP2 in Dockerfile is somewhat fancy;
unfortunately I was not able to come up with a simpler approach.
Misc:
1. Travis runs "ccache -s" after the build is completed. A call to
"ccache -s" is called to Dockerfile before make, so one can
compare before/after numbers.
2. make invocations are surrounded by "date" calls so one can get the
compilation times.
Changes in v2:
- consolidate Dockerfile statements (ENV, RUN)
- single object make test is no longer commented out
- simplify "make mrproper" test
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-16 14:27:36 -07:00
|
|
|
%-clang: DB_ENV=--build-arg ENV1=CCACHE_CPP2
|
2017-10-01 17:34:03 -07:00
|
|
|
s390x-clang: DB_CC=--build-arg CC=clang-3.8
|
2017-03-15 16:17:21 -07:00
|
|
|
.PHONY: $(TARGETS_CLANG)
|
2016-02-15 15:26:59 +03:00
|
|
|
|
|
|
|
clean:
|
2016-02-23 05:44:00 +03:00
|
|
|
rm -rf qemu-user-static
|
|
|
|
for ARCH in $(ARCHES); do \
|
|
|
|
FILE=/proc/sys/fs/binfmt_misc/$$ARCH; \
|
|
|
|
test -f $$FILE && echo -1 > $$FILE; \
|
|
|
|
rm -f Dockerfile.$$ARCH; \
|
|
|
|
done
|
2017-03-15 16:17:21 -07:00
|
|
|
.PHONY: clean
|