[v2] libgcc: Add support for --disable-libgcov

Message ID 20180525213432.1125-1-rasmus.villemoes@prevas.dk
State New
Headers show
  • [v2] libgcc: Add support for --disable-libgcov
Related show

Commit Message

Rasmus Villemoes May 25, 2018, 9:34 p.m.
When trying to build gcc 6.4.0 targeting VxWorks 5.5, I ran into libgcov
not building against the VxWorks system headers - there are multiple
issues such as

gcc-src/libgcc/../gcc/gcov-io.c:78:3: warning: implicit declaration of function 'getpid' [-Wimplicit-function-declaration]
   s_flock.l_pid = getpid ();

gcc-src/libgcc/libgcov.c:139:9: warning: implicit declaration of function 'access' [-Wimplicit-function-declaration]
         if (access (filename, F_OK) == -1
gcc-src/libgcc/libgcov.c:139:31: error: 'F_OK' undeclared (first use in this function)
         if (access (filename, F_OK) == -1
Moreover, from the gcov documentation, it would seem to be cumbersome at
best to actually use it on VxWorks. So add an option for disabling build
and install of libgcov.

It would probably be most user-friendly if the resulting compiler would
reject --coverage and -fprofile-arcs, but I couldn't find an easy way to
do that. Also, the similar --disable-libsanitizer does not make the
compiler complain about use of -fsanitize=xyz.

2018-05-25  Rasmus Villemoes  <rasmus.villemoes@prevas.dk>

	* install.texi: Document --disable-libgcov.

        * Makefile.in: Honour @enable_libgcov@.
        * configure.ac: Add --disable-libgcov option.
        * configure: Regenerate.
 gcc/doc/install.texi | 4 ++++
 libgcc/Makefile.in   | 8 +++++++-
 libgcc/configure.ac  | 5 +++++
 3 files changed, 16 insertions(+), 1 deletion(-)



Rasmus Villemoes June 1, 2018, 12:10 p.m. | #1
On 2018-05-25 23:34, Rasmus Villemoes wrote:

> add an option for disabling build and install of libgcov.



> 2018-05-25  Rasmus Villemoes  <rasmus.villemoes@prevas.dk>


> gcc/doc/

> 	* install.texi: Document --disable-libgcov.

I see I messed up that Changelog fragment, is should have been "gcc/"
and "* doc/install.texi".

Anyway, thinking a bit more about this, it might be better to use
--disable-gcov and have that also disable building the gcov tools.
There's actually already comments like

  # Install gcov if it was compiled.

and associated logic in gcc/Makefile, but I don't see how gcov could not
be compiled: This is in the install-common target, which depends on
native, which depends on $(LANGUAGES), which unconditionally contains
gcov$(exeext) and friends.




diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 7c5cdc762d3..cf3496d37c6 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1673,6 +1673,10 @@  should not be built.
 Specify that the run-time libraries used by vtable verification
 should not be built.
+@item --disable-libgcov
+Specify that the run-time library used for coverage analysis
+should not be built.
 @item --with-dwarf2
 Specify that the compiler should
 use DWARF 2 debugging information as the default.
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index dd8cee99fd3..22acc15e236 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -36,6 +36,7 @@  SHELL = @SHELL@
 cpu_type = @cpu_type@
 enable_shared = @enable_shared@
+enable_libgcov = @enable_libgcov@
 double_type_size = @double_type_size@
 long_double_type_size = @long_double_type_size@
 decimal_float = @decimal_float@
@@ -941,7 +942,10 @@  libgcc.a libgcov.a libunwind.a libgcc_eh.a:
 	$(RANLIB) $@
-all: libgcc.a libgcov.a
+all: libgcc.a
+ifeq ($(enable_libgcov),yes)
+all: libgcov.a
 ifneq ($(LIBUNWIND),)
 all: libunwind.a
@@ -1164,9 +1168,11 @@  install-leaf: $(install-shared) $(install-libunwind)
 	$(INSTALL_DATA) libgcc.a $(DESTDIR)$(inst_libdir)/
 	chmod 644 $(DESTDIR)$(inst_libdir)/libgcc.a
 	$(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc.a
+ifeq ($(enable_libgcov),yes)
 	$(INSTALL_DATA) libgcov.a $(DESTDIR)$(inst_libdir)/
 	chmod 644 $(DESTDIR)$(inst_libdir)/libgcov.a
 	$(RANLIB) $(DESTDIR)$(inst_libdir)/libgcov.a
 	parts="$(INSTALL_PARTS)";				\
 	for file in $$parts; do					\
diff --git a/libgcc/configure.ac b/libgcc/configure.ac
index b59aa746afc..a878c473f3d 100644
--- a/libgcc/configure.ac
+++ b/libgcc/configure.ac
@@ -68,6 +68,11 @@  AC_ARG_ENABLE(shared,
 ], [enable_shared=yes])
+[  --disable-libgcov       don't provide libgcov],
+[], [enable_libgcov=yes])
 [  --enable-vtable-verify    Enable vtable verification feature ],
 [case "$enableval" in