From 0527dd3ddec3ad75ecb296ecdb55fbe4c2ad4418 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Thu, 5 Oct 2017 16:55:41 +0200 Subject: Use clang on travis-ci (#23) --- .travis.yml | 18 ++++++++++++------ Makefile | 8 ++++++++ src/config.m4 | 6 +++--- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 833ed97..b9b7c87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,10 @@ php: before_install: - pip install --user cpp-coveralls +env: + - CC=clang + - CC=gcc + script: - cd src - phpize @@ -17,12 +21,14 @@ script: - TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make test after_success: - - git clone https://github.com/linux-test-project/lcov.git --depth 1 - - rm -rf ./lcov/examples/ ./lcov/test/ - - ./lcov/bin/lcov -c -o ./COV.info --rc lcov_branch_coverage=1 --base-directory . --directory . - - ./lcov/bin/lcov --remove ./COV.info '/usr/*' --remove ./COV.info '*tweetnacl.c' -o ./COV.info --rc lcov_branch_coverage=1 - - ./lcov/bin/genhtml -o ./COV.html ./COV.info --branch-coverage - - coveralls --exclude 'tweetnacl.c' + - 'if [ ${CC} = "gcc" ]; then + git clone https://github.com/linux-test-project/lcov.git --depth 1 ; + rm -rf ./lcov/examples/ ./lcov/test/ ; + ./lcov/bin/lcov -c -o ./COV.info --rc lcov_branch_coverage=1 --base-directory . --directory . ; + ./lcov/bin/lcov --remove ./COV.info "/usr/*" --remove ./COV.info "*tweetnacl.c" -o ./COV.info --rc lcov_branch_coverage=1 ; + ./lcov/bin/genhtml -o ./COV.html ./COV.info --branch-coverage ; + coveralls --exclude "tweetnacl.c" ; + fi' - cd .. - make joomla diff --git a/Makefile b/Makefile index 441c2f1..2a99cf6 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,13 @@ debug: ## compile a debug build coverage: ## compile snuffleugpaus, and run the testsuite with coverage cd src; phpize +ifeq ($(CC),clang) + cd src; CFLAGS="-fprofile-instr-generate -fcoverage-mapping" ./configure --enable-snuffleupagus + make -C src + LLVM_PROFILE_FILE="sp_%p_%m.profraw" TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make -C src test + llvm-profdata-4.0 merge ./src/*.profraw -o ./src/sp.profdata + llvm-cov report -instr-profile=./src/sp.profdata ./src/modules/snuffleupagus.so +else cd src; ./configure --enable-snuffleupagus --enable-coverage make -C src rm -Rf src/COV.html @@ -28,6 +35,7 @@ coverage: ## compile snuffleugpaus, and run the testsuite with coverage lcov --base-directory ./src --directory ./src -c -o ./src/COV.info --rc lcov_branch_coverage=1 lcov --remove src/COV.info '/usr/*' --remove src/COV.info '*tweetnacl.c' -o src/COV.info --rc lcov_branch_coverage=1 genhtml -o src/COV.html ./src/COV.info --branch-coverage +endif bench: joomla ## run the benchmark diff --git a/src/config.m4 b/src/config.m4 index 04eefa2..a0409de 100644 --- a/src/config.m4 +++ b/src/config.m4 @@ -11,10 +11,10 @@ PHP_ARG_ENABLE(snuffleupagus, whether to enable snuffleupagus support, [ --enable-snuffleupagus Enable snuffleupagus support]) PHP_ARG_ENABLE(coverage, whether to enable coverage support, -[ --enable-coverage Enable coverage support]) +[ --enable-coverage Enable coverage support], no, no) PHP_ARG_ENABLE(debug, whether to enable debug messages, -[ --enable-debug Enable debug messages]) +[ --enable-debug Enable debug messages], no, no) CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -D_DEFAULT_SOURCE=1 -std=c99" @@ -33,7 +33,7 @@ AC_CHECK_LIB(pcre, pcre_compile, AC_DEFINE(HAVE_PCRE, 1, [have pcre])) if test "$PHP_SNUFFLEUPAGUS" = "yes"; then if test "$PHP_COVERAGE" = "yes"; then - CFLAGS="$CFLAGS --coverage -lgcov -O1 -g" + CFLAGS="$CFLAGS --coverage -O0 -g" fi PHP_NEW_EXTENSION(snuffleupagus, $sources, $ext_shared,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) fi -- cgit v1.3