Commit 27b5b4d9f31f60d1269e446d4a4cc1062e61fbe7

Thomas de Grivel 2023-08-21T11:00:54

wip gcovr

diff --git a/Makefile b/Makefile
index 7401f4c..4eec995 100644
--- a/Makefile
+++ b/Makefile
@@ -36,8 +36,8 @@ asan:
 	${MAKE} -C c3s asan
 	${MAKE} -C test asan
 
-cov:
-	${GMAKE} -C libffi cov
+cov: gen
+	${GMAKE} -C libffi all
 	${MAKE} -C libtommath cov
 	${MAKE} -C libc3 cov
 	${MAKE} -C ic3 cov
@@ -54,7 +54,6 @@ clean:
 	${MAKE} -C test clean
 
 clean_cov:
-	${GMAKE} -C libffi clean_cov
 	${MAKE} -C libtommath clean_cov
 	${MAKE} -C libc3 clean_cov
 	${MAKE} -C ic3 clean_cov
@@ -122,6 +121,9 @@ libc3_gcovr:
 libc3_test_cov: cov
 	${MAKE} -C test libc3_test_cov
 
+libffi:
+	${GMAKE} -C libffi all
+
 licence:
 	update_header config.subr ${C3_CONFIGURES}
 	update_header Makefile ${C3_MAKEFILES}
@@ -161,7 +163,7 @@ test_ic3_debug: debug
 test_libc3: build
 	${MAKE} -C test test_libc3
 
-.PHONY: all asan c3s cov clean clean_cov debug gcovr ic3 install libc3 libtommath license test test_asan test_cov test_debug test_gcovr test_ic3
+.PHONY: all asan c3s cov clean clean_cov debug gcovr ic3 install libc3 libtommath libffi license test test_asan test_cov test_debug test_gcovr test_ic3
 
 include config.mk
 include sources.mk
diff --git a/config.subr b/config.subr
index 6134807..454e94c 100644
--- a/config.subr
+++ b/config.subr
@@ -99,7 +99,7 @@ config_lib() {
     echo "/* generated by configure */" > "$OUT"
     echo "int main () { return 0; }" >> "$OUT"
     LIBS="${LIBS} $@"
-    if ${CC} ${CPPFLAGS} ${CFLAGS} "$OUT" ${LIBS} -o /dev/null; then
+    if ${CC} ${CPPFLAGS} ${CFLAGS} "$OUT" ${LIBS} -o /dev/null 2>/dev/null; then
         :
     else
         LIBS="${LIBS_SAVE}"
diff --git a/ic3/configure b/ic3/configure
index a6eaa64..975caf1 100755
--- a/ic3/configure
+++ b/ic3/configure
@@ -43,9 +43,6 @@ CPPFLAGS="${CPPFLAGS:=}"
 ENV_CFLAGS="${CFLAGS:=}"
 DEFAULT_CFLAGS="-O2 -pipe -fPIC"
 LDFLAGS="${LDFLAGS}"
-if [ "x$CC" != "xtcc" ]; then
-    LDFLAGS="-Wl,--allow-shlib-undefined ${LDFLAGS}"
-fi
 LIBS="${LIBS:=-lm}"
 
 # Common config for all targets
@@ -68,10 +65,10 @@ LIBS_ASAN="$LOCAL_LIBS_ASAN $LIBS"
 
 # Coverage config
 CFLAGS_COV="$CFLAGS -ftest-coverage -fprofile-arcs"
-LDFLAGS_COV="$LDFLAGS"
+LDFLAGS_COV="$LDFLAGS --coverage"
 LIBC3_COV=../libc3/libc3_cov.la
 LOCAL_LIBS_COV="$LIBC3_COV"
-LIBS_COV="$LOCAL_LIBS_COV $LIBS"
+LIBS_COV="$LOCAL_LIBS_COV $LIBS -lgcov"
 
 # Debug config
 CFLAGS_DEBUG="$CFLAGS -DDEBUG -O0 -ggdb"
diff --git a/libc3/configure b/libc3/configure
index 007e4e1..bceb88d 100755
--- a/libc3/configure
+++ b/libc3/configure
@@ -34,7 +34,7 @@ OBJECTS_DEBUG="$(c2ext .debug.lo "$LO_SOURCES")"
 CPPFLAGS="${CPPFLAGS:=}"
 ENV_CFLAGS="${CFLAGS:=}"
 DEFAULT_CFLAGS="-O2 -pipe"
-LDFLAGS="-shared -Wl,--allow-shlib-undefined ${LDFLAGS:-}"
+LDFLAGS="-shared ${LDFLAGS:-}"
 LIBS="${LIBS} -lm -pthread -rpath ${PREFIX}/lib"
 
 # Common config for all targets
@@ -57,14 +57,14 @@ if ! [ -f ../ucd2c/ucd.c ]; then
 fi
 
 # Address Sanitizer config
-CFLAGS_ASAN="$CFLAGS -fsanitize=address -O1 -fno-omit-frame-pointer -g"
+CFLAGS_ASAN="$CFLAGS -O1 -fsanitize=address -fno-omit-frame-pointer -g"
 LDFLAGS_ASAN="$LDFLAGS"
 LIBS_ASAN="$LIBS"
 
 # Coverage config
 CFLAGS_COV="$CFLAGS -ftest-coverage -fprofile-arcs"
-LDFLAGS_COV="$LDFLAGS"
-LIBS_COV="$LIBS"
+LDFLAGS_COV="$LDFLAGS --coverage"
+LIBS_COV="$LIBS -lgcov"
 
 # Debug config
 CFLAGS_DEBUG="$CFLAGS -DDEBUG -O0 -ggdb"
diff --git a/test/Makefile b/test/Makefile
index 2b898b6..386a11d 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -53,7 +53,7 @@ clean:
 clean_cov:
 	rm -rf ${CLEANFILES_COV}
 
-cov:   libc3_test_cov
+cov: libc3_test_cov
 
 debug: libc3_test_debug
 
@@ -69,9 +69,6 @@ gdb_test: debug
 ic3_test_cov:
 	IC3=${SRC_TOP}/ic3/ic3_cov time ./ic3_test
 
-libc3_test_cov: libc3_test_cov
-	time ./libc3_test_cov
-
 lldb_test: debug
 	if [ -f libc3_test_debug.core ]; then lldb .libs/libc3_test_debug libc3_test_debug.core; else lldb .libs/libc3_test_debug; fi
 
@@ -98,6 +95,9 @@ test_ic3_debug:
 test_libc3: libc3_test
 	time ./libc3_test
 
+test_libc3_cov: libc3_test_cov
+	time ./libc3_test_cov
+
 test_valgrind: libc3_test
 	valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./libc3_test