config_host.mk.in | 1 + configure.ac | 19 +++++++++++++++++++ external/liborcus/ExternalProject_liborcus.mk | 3 +-- external/python3/ExternalProject_python3.mk | 2 +- solenv/gbuild/ExternalProject.mk | 2 +- solenv/gbuild/platform/com_GCC_defs.mk | 5 +++-- 6 files changed, 26 insertions(+), 6 deletions(-)
New commits: commit 41ebd4c123d5573bfc56e16cdeb6def1c42d07e8 Author: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> AuthorDate: Mon Jun 23 11:44:46 2025 +0200 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Mon Jun 23 15:15:58 2025 +0200 add --enable-gcov configure flag (instaed of manually setting flags) there was already parts of that in the makefile that would require running "make gb_GCOV=YES" - but that alone was not enough, you were also kinda expected to set LDFLAGS on the commandline (or at least it had bitrotted to this state) - so just make it into a proper configure switch. Building with lto fails at least on baseline with /opt/rh/gcc-toolset-12/root/usr/libexec/gcc/x86_64-redhat-linux/12/ld: /tmp/ccaE1KD4.ltrans31.ltrans.o:(.data.rel.ro.local+0x3befe0) : undefined reference to `.L1' /opt/rh/gcc-toolset-12/root/usr/libexec/gcc/x86_64-redhat-linux/12/ld: /tmp/ccaE1KD4.ltrans31.ltrans.o:(.data.rel.ro.local+0x3befe8) : undefined reference to `.L1' /opt/rh/gcc-toolset-12/root/usr/libexec/gcc/x86_64-redhat-linux/12/ld: /tmp/ccaE1KD4.ltrans31.ltrans.o:(.data.rel.ro.local+0x3bf018) : undefined reference to `.L2' /opt/rh/gcc-toolset-12/root/usr/libexec/gcc/x86_64-redhat-linux/12/ld: /tmp/ccaE1KD4.ltrans31.ltrans.o:(.data.rel.ro.local+0x3bf020) : undefined reference to `.L2' […many more of those with incrementing references…] So for now warn if both are used. Change-Id: I2c3427b48174de77a6894293a5e784df8ee24bd1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186821 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> diff --git a/config_host.mk.in b/config_host.mk.in index 991a7e3a6f1d..9b7a7a747e2d 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -187,6 +187,7 @@ export ENABLE_FIREBIRD_SDBC=@ENABLE_FIREBIRD_SDBC@ export ENABLE_FORMULA_LOGGER=@ENABLE_FORMULA_LOGGER@ export ENABLE_GDB_INDEX=@ENABLE_GDB_INDEX@ export ENABLE_GEN=@ENABLE_GEN@ +ENABLE_GCOV=@ENABLE_GCOV@ export ENABLE_GIO=@ENABLE_GIO@ export ENABLE_GPGMEPP=@ENABLE_GPGMEPP@ export ENABLE_GSTREAMER_1_0=@ENABLE_GSTREAMER_1_0@ diff --git a/configure.ac b/configure.ac index 2a4d9f37bef3..2e00235e0320 100644 --- a/configure.ac +++ b/configure.ac @@ -736,6 +736,20 @@ else fi AC_SUBST(ENABLE_LTO) +AC_MSG_CHECKING([whether to enable gcov]) +if test -n "$enable_gcov" -a "$enable_gcov" != "no"; then + ENABLE_GCOV="TRUE" + AC_MSG_RESULT([yes]) + if test -n "$ENABLE_LTO"; then + AC_MSG_WARN([using --enable-gcov together with --enable-lto will likely fail to link]) + add_warning "using --enable-gcov together with --enable-lto will likely fail to link" + fi +else + ENABLE_GCOV="" + AC_MSG_RESULT([no]) +fi +AC_SUBST(ENABLE_GCOV) + AC_ARG_ENABLE(fuzz-options, AS_HELP_STRING([--enable-fuzz-options], [Randomly enable or disable each of those configurable options @@ -1796,6 +1810,11 @@ AC_ARG_ENABLE(lto, longer but libraries and executables are optimized for speed. For GCC, best to use the 'gold' linker.)])) +AC_ARG_ENABLE(gcov, + AS_HELP_STRING([--enable-gcov], + [Enable compiler/linker flags to enable code coverage analysis via GCC's gcov. + Avoid also using --enable-lto, that'll likely fail to link])) + AC_ARG_ENABLE(python, AS_HELP_STRING([--enable-python=<no/auto/system/internal/fully-internal>], [Enables or disables Python support at run-time. diff --git a/external/liborcus/ExternalProject_liborcus.mk b/external/liborcus/ExternalProject_liborcus.mk index 97d1c54b02d8..a18026c13b6d 100644 --- a/external/liborcus/ExternalProject_liborcus.mk +++ b/external/liborcus/ExternalProject_liborcus.mk @@ -61,9 +61,8 @@ endif liborcus_CPPFLAGS+=$(gb_COMPILERDEFS_STDLIB_DEBUG) liborcus_CXXFLAGS=$(CXXFLAGS) $(gb_VISIBILITY_FLAGS) $(gb_VISIBILITY_FLAGS_CXX) $(CXXFLAGS_CXX11) -DBOOST_SYSTEM_NO_DEPRECATED -liborcus_LDFLAGS=$(LDFLAGS) $(gb_LTOFLAGS) +liborcus_LDFLAGS=$(call gb_ExternalProject_get_link_flags,liborcus) $(gb_LTOFLAGS) liborcus_CXXFLAGS+=$(call gb_ExternalProject_get_build_flags,liborcus) -liborcus_LDFLAGS+=$(call gb_ExternalProject_get_link_flags,liborcus) ifeq ($(COM),MSC) liborcus_CXXFLAGS+=$(BOOST_CXXFLAGS) endif diff --git a/external/python3/ExternalProject_python3.mk b/external/python3/ExternalProject_python3.mk index 68d71462ffc3..bed5ffe71792 100644 --- a/external/python3/ExternalProject_python3.mk +++ b/external/python3/ExternalProject_python3.mk @@ -116,7 +116,7 @@ $(call gb_ExternalProject_get_state_target,python3,build) : )" \ $(if $(python3_cflags),CFLAGS='$(python3_cflags)') \ $(if $(filter -fsanitize=%,$(CC)),LINKCC="$(CXX) -pthread") \ - LDFLAGS="$(strip $(LDFLAGS) \ + LDFLAGS="$(strip $(call gb_ExternalProject_get_link_flags,python3) \ $(if $(filter LINUX,$(OS)),-L$(gb_UnpackedTarball_workdir)/libffi/$(HOST_PLATFORM)/.libs) \ $(if $(SYSTEM_BZIP2),,-L$(gb_UnpackedTarball_workdir)/bzip2) \ $(if $(SYSTEM_EXPAT),,-L$(gb_StaticLibrary_WORKDIR)) \ diff --git a/solenv/gbuild/ExternalProject.mk b/solenv/gbuild/ExternalProject.mk index e9496b87761e..093b99e967dc 100644 --- a/solenv/gbuild/ExternalProject.mk +++ b/solenv/gbuild/ExternalProject.mk @@ -212,7 +212,7 @@ gb_ExternalProject_get_build_flags = $(call gb_LinkTarget__get_debugflags,Extern # Returns flags to include in LDFLAGS to enable optimizations and/or debugging. # gb_ExternalProject_get_link_flags project -gb_ExternalProject_get_link_flags = $(LDFLAGS) $(USE_LD) $(call gb_LinkTarget__get_debugldflags,ExternalProject_$(1)) +gb_ExternalProject_get_link_flags = $(LDFLAGS) $(USE_LD) $(gb_GCOV_LDFLAGS) $(call gb_LinkTarget__get_debugldflags,ExternalProject_$(1)) # Run a target command # diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk index bf0464858729..0e3b52b2f487 100644 --- a/solenv/gbuild/platform/com_GCC_defs.mk +++ b/solenv/gbuild/platform/com_GCC_defs.mk @@ -119,10 +119,11 @@ gb_CXXFLAGS_Wundef = -Wno-undef gb_CXXFLAGS_include := -include$(gb_SPACE) -ifeq ($(strip $(gb_GCOV)),YES) +ifeq ($(ENABLE_GCOV),TRUE) +gb_GCOV_LDFLAGS := -fprofile-arcs -lgcov gb_CFLAGS_COMMON += -fprofile-arcs -ftest-coverage gb_CXXFLAGS_COMMON += -fprofile-arcs -ftest-coverage -gb_LinkTarget_LDFLAGS += -fprofile-arcs -lgcov +gb_LinkTarget_LDFLAGS += $(gb_GCOV_LDFLAGS) gb_COMPILEROPTFLAGS := -O0 endif