diff options
author | Joel Rosdahl <joel@rosdahl.net> | 2018-04-23 22:04:12 +0200 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2018-04-23 22:04:12 +0200 |
commit | 7951573c28eaf259735ef0e02892512a189af12c (patch) | |
tree | 80eeec47e9c081e2eedd03fcb1188f7df14f90e3 | |
parent | 5dc502eb11fee23a2c87e4e1dac0af72780bdf70 (diff) | |
parent | 359a4078a8adad86bf028cd4d48210379eea0f7b (diff) | |
download | ccache-7951573c28eaf259735ef0e02892512a189af12c.tar.gz |
Merge branch '3.4-maint'
* 3.4-maint:
Use double when calculating cache thresholds
Add a 32-bit build target, using multilib (-m32)
Convert float config to double, add rounding
Upgrade clang to 5.0, for the Travis docker
Make sure to export ASAN_OPTIONS properly
Add small helper to run all Travis tests
Make sure to call configure with right path
Add a travis-build container, for running locally
Look for -fdebug-prefix-map feature explicitly
Improve the Travis build matrix
Fix log printing of before/after cleanup
Remove irrelevant variable assignment in wipe_dir
win32: Fix CCACHE_COMPILERCHECK=mtime test case
-rwxr-xr-x | .travis.sh | 9 | ||||
-rw-r--r-- | .travis.yml | 35 | ||||
-rw-r--r-- | .travis/Dockerfile | 37 | ||||
-rw-r--r-- | dev.mk.in | 9 | ||||
-rw-r--r-- | src/ccache.h | 2 | ||||
-rw-r--r-- | src/cleanup.c | 25 | ||||
-rw-r--r-- | src/execute.c | 1 | ||||
-rw-r--r-- | test/suites/cleanup.bash | 4 | ||||
-rw-r--r-- | test/suites/debug_prefix_map.bash | 3 |
9 files changed, 96 insertions, 29 deletions
diff --git a/.travis.sh b/.travis.sh new file mode 100755 index 00000000..ad646783 --- /dev/null +++ b/.travis.sh @@ -0,0 +1,9 @@ +#!/bin/sh -ex +make clean +make travis CC=gcc +make travis CC=clang +make travis CC=gcc CFLAGS="-m32 -g -O2" HOST="--host=i386-linux-gnu" +make travis CC=i686-w64-mingw32-gcc HOST="--host=i686-w64-mingw32" TEST="unittest/run.exe" +make travis CC=clang CFLAGS="-fsanitize=undefined" ASAN_OPTIONS="detect_leaks=0" +make travis CC=clang CFLAGS="-fsanitize=address -g" ASAN_OPTIONS="detect_leaks=0" +make travis CC=/usr/bin/clang TEST=analyze diff --git a/.travis.yml b/.travis.yml index a4793bb8..31438d6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,37 @@ language: c -sudo: required - addons: apt: packages: - gperf - elfutils - zlib1g-dev - - mingw32 - - mingw32-binutils - - clang # scan-build + - lib32z1-dev os: - linux - osx compiler: - - clang - gcc + - clang matrix: include: -# - os: linux -# compiler: i586-mingw32msvc-gcc -# env: HOST="--host=i586-mingw32msvc" TEST="test/main.exe" + - os: linux + compiler: gcc + env: CFLAGS="-m32 -g -O2" HOST="--host=i386-linux-gnu" + addons: + apt: + packages: + - gcc-multilib + - os: linux + compiler: i686-w64-mingw32-gcc + env: HOST="--host=i686-w64-mingw32" TEST="unittest/run.exe" + addons: + apt: + packages: + - gcc-mingw-w64-i686 - os: linux compiler: clang env: CFLAGS="-fsanitize=undefined" ASAN_OPTIONS="detect_leaks=0" @@ -34,17 +41,21 @@ matrix: - os: linux compiler: clang env: PATH="/usr/bin:$PATH" TEST=analyze + addons: + apt: + packages: + - clang # scan-build - os: linux compiler: gcc env: CUDA=8.0.61-1 + sudo: required + before_install: + - source ./.travis/install_cuda.sh exclude: - os: osx compiler: gcc -before_install: - - source ./.travis/install_cuda.sh - script: - ./autogen.sh - ./configure $HOST diff --git a/.travis/Dockerfile b/.travis/Dockerfile new file mode 100644 index 00000000..5f837b0e --- /dev/null +++ b/.travis/Dockerfile @@ -0,0 +1,37 @@ +# NOTE: This is not the real Docker image used for the Travis builds. +# See: https://docs.travis-ci.com/user/common-build-problems/ + +FROM ubuntu:trusty + +# https://github.com/Yelp/dumb-init +ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64.deb . +RUN dpkg -i dumb-init_*.deb +ENTRYPOINT ["/usr/bin/dumb-init", "--"] + +# generic tools +RUN apt-get -qq update && apt-get install -y --no-install-recommends \ + libc6-dev \ + gcc \ + clang \ + libc6-dev-i386 \ + gcc-multilib \ + gcc-mingw-w64 \ + make \ + autoconf \ + && rm -rf /var/lib/apt/lists/* + +# Travis has upgraded clang, from clang-3.4 to clang-5.0 +# https://github.com/travis-ci/travis-cookbooks/pull/890 +RUN printf "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-5.0 main\ndeb-src http://apt.llvm.org/trusty/ llvm-toolchain-trusty-5.0 main\n# Also add the following for the appropriate libstdc++\ndeb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main\n" > /etc/apt/sources.list.d/llvm-toolchain.list && apt-key adv --fetch-keys http://apt.llvm.org/llvm-snapshot.gpg.key && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F +RUN apt-get -qq update && apt-get install -y --no-install-recommends \ + clang-5.0 \ + && rm -rf /var/lib/apt/lists/* \ + && ln -s /usr/bin/clang-5.0 /usr/local/bin/clang + +# ccache specific +RUN apt-get -qq update && apt-get install -y --no-install-recommends \ + gperf \ + elfutils \ + zlib1g-dev \ + lib32z1-dev \ + && rm -rf /var/lib/apt/lists/* @@ -10,6 +10,7 @@ CPPCHECK_SUPPRESSIONS = misc/cppcheck-suppressions.txt SCAN_BUILD = scan-build DOCKER = docker GPERF = gperf +TEST = test version := \ $(shell (git --git-dir=$(srcdir)/.git describe --dirty || git --git-dir=$(srcdir)/.git describe || echo vunknown) \ @@ -196,11 +197,17 @@ uncrustify: .PHONY: analyze analyze: - $(SCAN_BUILD) --use-cc=$(CC) ./configure + $(SCAN_BUILD) --use-cc=$(CC) $(srcdir)/configure $(SCAN_BUILD) --use-cc=$(CC) --status-bugs $(MAKE) -B .PHONY: docker docker: misc/Dockerfile $(DOCKER) build -f $< $(srcdir) +.PHONY: travis +travis: .travis/Dockerfile + $(DOCKER) inspect travis-build >/dev/null || $(DOCKER) build -t travis-build .travis + $(DOCKER) run --rm --volume $(PWD):/src --tmpfs /dst:rw,exec --env ASAN_OPTIONS='$(ASAN_OPTIONS)' travis-build \ + sh -c "cd /src && ./autogen.sh && cd /dst && CC=$(CC) CFLAGS='$(CFLAGS)' /src/configure $(HOST) && make && make $(TEST)" + -include .deps/*.d diff --git a/src/ccache.h b/src/ccache.h index a4fd28ab..973d42dd 100644 --- a/src/ccache.h +++ b/src/ccache.h @@ -233,7 +233,7 @@ void exitfn_call(void); // ---------------------------------------------------------------------------- // cleanup.c -void clean_up_dir(struct conf *conf, const char *dir, float limit_multiple); +void clean_up_dir(struct conf *conf, const char *dir, double limit_multiple); void clean_up_all(struct conf *conf); void wipe_all(struct conf *conf); diff --git a/src/cleanup.c b/src/cleanup.c index 8c46eac5..969b8d2b 100644 --- a/src/cleanup.c +++ b/src/cleanup.c @@ -17,6 +17,8 @@ #include "ccache.h" +#include <math.h> + static struct files { char *fname; time_t mtime; @@ -155,15 +157,15 @@ sort_and_clean(void) // Clean up one cache subdirectory. void -clean_up_dir(struct conf *conf, const char *dir, float limit_multiple) +clean_up_dir(struct conf *conf, const char *dir, double limit_multiple) { cc_log("Cleaning up cache directory %s", dir); // When "max files" or "max cache size" is reached, one of the 16 cache // subdirectories is cleaned up. When doing so, files are deleted (in LRU // order) until the levels are below limit_multiple. - cache_size_threshold = conf->max_size * limit_multiple / 16; - files_in_cache_threshold = conf->max_files * limit_multiple / 16; + cache_size_threshold = round(conf->max_size * limit_multiple / 16); + files_in_cache_threshold = round(conf->max_files * limit_multiple / 16); num_files = 0; cache_size = 0; @@ -173,13 +175,13 @@ clean_up_dir(struct conf *conf, const char *dir, float limit_multiple) traverse(dir, traverse_fn); // Clean the cache. - cc_log("Before cleanup: %lu KiB, %zu files", - (unsigned long)cache_size / 1024, - files_in_cache); + cc_log("Before cleanup: %.0f KiB, %.0f files", + (double)cache_size / 1024, + (double)files_in_cache); bool cleaned = sort_and_clean(); - cc_log("After cleanup: %lu KiB, %zu files", - (unsigned long)cache_size / 1024, - files_in_cache); + cc_log("After cleanup: %.0f KiB, %.0f files", + (double)cache_size / 1024, + (double)files_in_cache); if (cleaned) { cc_log("Cleaned up cache directory %s", dir); @@ -236,11 +238,10 @@ static void wipe_fn(const char *fname, struct stat *st) // Wipe one cache subdirectory. void -wipe_dir(struct conf *conf, const char *dir) +wipe_dir(const char *dir) { cc_log("Clearing out cache directory %s", dir); - files_in_cache_threshold = conf->max_files * conf->limit_multiple / 16; files_in_cache = 0; traverse(dir, wipe_fn); @@ -258,7 +259,7 @@ void wipe_all(struct conf *conf) { for (int i = 0; i <= 0xF; i++) { char *dname = format("%s/%1x", conf->cache_dir, i); - wipe_dir(conf, dname); + wipe_dir(dname); free(dname); } diff --git a/src/execute.c b/src/execute.c index df8fe5b6..ae305520 100644 --- a/src/execute.c +++ b/src/execute.c @@ -115,6 +115,7 @@ win32getshell(char *path) void add_exe_ext_if_no_to_fullpath(char *full_path_win_ext, size_t max_size, const char *ext, const char *path) { if (!ext || (!str_eq(".exe", ext) + && !str_eq(".sh", ext) && !str_eq(".bat", ext) && !str_eq(".EXE", ext) && !str_eq(".BAT", ext))) { diff --git a/test/suites/cleanup.bash b/test/suites/cleanup.bash index 8eaac4f6..45dccb08 100644 --- a/test/suites/cleanup.bash +++ b/test/suites/cleanup.bash @@ -152,7 +152,7 @@ SUITE_cleanup() { TEST ".o file is removed before .stderr" prepare_cleanup_test_dir $CCACHE_DIR/a - $CCACHE -F 474 -M 0 >/dev/null + $CCACHE -F 464 -M 0 >/dev/null backdate 0 $CCACHE_DIR/a/result9-4017.stderr $CCACHE -c >/dev/null expect_file_missing $CCACHE_DIR/a/result9-4017.stderr @@ -167,7 +167,7 @@ SUITE_cleanup() { TEST ".stderr file is not removed before .o" prepare_cleanup_test_dir $CCACHE_DIR/a - $CCACHE -F 474 -M 0 >/dev/null + $CCACHE -F 464 -M 0 >/dev/null backdate 0 $CCACHE_DIR/a/result9-4017.o $CCACHE -c >/dev/null expect_file_exists $CCACHE_DIR/a/result9-4017.stderr diff --git a/test/suites/debug_prefix_map.bash b/test/suites/debug_prefix_map.bash index 256d4cbc..25cc36ff 100644 --- a/test/suites/debug_prefix_map.bash +++ b/test/suites/debug_prefix_map.bash @@ -1,5 +1,6 @@ SUITE_debug_prefix_map_PROBE() { - if $COMPILER_USES_MINGW; then + touch test.c + if ! $REAL_COMPILER -c -fdebug-prefix-map=old=new test.c 2>/dev/null; then echo "-fdebug-prefix-map not supported by compiler" fi } |