configure: add --disable-fix-includes

Message ID d59fa9a4-262a-11c8-5290-4f6a138cdfee@suse.cz
State New
Headers
Series configure: add --disable-fix-includes |

Commit Message

Martin Liška May 9, 2022, 9:03 a.m. UTC
  Right now, fixinclude takes about 11 seconds on my machine, where
it reads 130MB of header files.

The number of fixed headers is negligible without any significant
change.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

fixincludes/ChangeLog:

	* fixinc.in: Add early exit.

gcc/ChangeLog:

	* Makefile.in: Support disable_fix_includes.
	* configure.ac: Add --disable-fix-includes.
	* configure: Regenerate.
---
 fixincludes/fixinc.in |  6 ++++++
 gcc/Makefile.in       |  6 ++++--
 gcc/configure         | 21 +++++++++++++++++++--
 gcc/configure.ac      |  6 ++++++
 4 files changed, 35 insertions(+), 4 deletions(-)
  

Comments

Andreas Schwab May 9, 2022, 9:31 a.m. UTC | #1
On Mai 09 2022, Martin Liška wrote:

> +cat >>confdefs.h <<_ACEOF
> +#define FIX_INCLUDES $disable_fix_includes
> +_ACEOF

Where does this come from?  Also, nothing uses it.

> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 1171c946e6e..6015e403aa9 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -842,6 +842,12 @@ gather_stats=`if test $enable_gather_detailed_mem_stats != no; then echo 1; else
>  AC_DEFINE_UNQUOTED(GATHER_STATISTICS, $gather_stats,
>  [Define to enable detailed memory allocation stats gathering.])
>  
> +AC_ARG_ENABLE(disable-fix-includes,
> +[AS_HELP_STRING([--disable-fix-includes],
> +		[skip fixing of includes])], [],
> +[disable_fix_includes=yes])

That creates the (non-working) options --enable-disable-fix-includes and
--disable-disable-fix-includes, but not --disable-fix-includes.  It also
disables fixincludes by default, which doesn't look intended.
  
Joseph Myers May 9, 2022, 9:14 p.m. UTC | #2
If you add a new configure option, it should be documented in 
install.texi.
  
Martin Liška May 11, 2022, 10:55 a.m. UTC | #3
On 5/9/22 23:14, Joseph Myers wrote:
> If you add a new configure option, it should be documented in 
> install.texi.
> 

Both comments fixed in the v2.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin
  
Rainer Orth May 11, 2022, 11 a.m. UTC | #4
Hi Martin,

> On 5/9/22 23:14, Joseph Myers wrote:
>> If you add a new configure option, it should be documented in 
>> install.texi.
>> 
>
> Both comments fixed in the v2.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> From 58d431568d6b6163dd9cdc920239f173689a769c Mon Sep 17 00:00:00 2001
> From: Martin Liska <mliska@suse.cz>
> Date: Fri, 4 Feb 2022 13:42:14 +0100
> Subject: [PATCH] configure: add --disable-fix-includes

As I've mentioned before, I believe, the command is called fixincludes
in current gcc docs, and the option should reflect that, not introduce a
name used nowhere else.

> Right now, fixinclude takes about 11 seconds on my machine, where
> it reads 130MB of header files.
>
> The number of fixed headers is negligible without any significant
> change.

Please speak for Linux, but not for other targets ;-)

	Rainer
  
Martin Liška May 11, 2022, 11:15 a.m. UTC | #5
On 5/11/22 13:00, Rainer Orth wrote:
> Hi Martin,
> 
>> On 5/9/22 23:14, Joseph Myers wrote:
>>> If you add a new configure option, it should be documented in 
>>> install.texi.
>>>
>>
>> Both comments fixed in the v2.
>>
>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>> From 58d431568d6b6163dd9cdc920239f173689a769c Mon Sep 17 00:00:00 2001
>> From: Martin Liska <mliska@suse.cz>
>> Date: Fri, 4 Feb 2022 13:42:14 +0100
>> Subject: [PATCH] configure: add --disable-fix-includes
> 
> As I've mentioned before, I believe, the command is called fixincludes
> in current gcc docs, and the option should reflect that, not introduce a
> name used nowhere else.

No, I can't use it, because even with current master using --disable-fixincludes
means the tool is not built at all. It results with:

g++   -g       -DIN_GCC -fPIC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common  -DHAVE_CONFIG_H  -DGENERATOR_FILE -static-libstdc++ -static-libgcc   -o build/genchecksum \
    build/genchecksum.o ../build-x86_64-pc-linux-gnu/libiberty/pic/libiberty.a
make: *** No rule to make target '../build-x86_64-pc-linux-gnu/fixincludes/fixinc.sh', needed by 'stmp-fixinc'.  Stop.
make: *** Waiting for unfinished jobs....

Martin

> 
>> Right now, fixinclude takes about 11 seconds on my machine, where
>> it reads 130MB of header files.
>>
>> The number of fixed headers is negligible without any significant
>> change.
> 
> Please speak for Linux, but not for other targets ;-)
> 
> 	Rainer
>
  
Rainer Orth May 11, 2022, 11:31 a.m. UTC | #6
Hi Martin,

>>> Subject: [PATCH] configure: add --disable-fix-includes
>> 
>> As I've mentioned before, I believe, the command is called fixincludes
>> in current gcc docs, and the option should reflect that, not introduce a
>> name used nowhere else.
>
> No, I can't use it, because even with current master using --disable-fixincludes
> means the tool is not built at all. It results with:
>
> g++ -g -DIN_GCC -fPIC -fno-exceptions -fno-rtti
> -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
> -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic
> -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common
> -DHAVE_CONFIG_H -DGENERATOR_FILE -static-libstdc++ -static-libgcc -o
> build/genchecksum \
>     build/genchecksum.o ../build-x86_64-pc-linux-gnu/libiberty/pic/libiberty.a
> make: *** No rule to make target
> '../build-x86_64-pc-linux-gnu/fixincludes/fixinc.sh', needed by
> 'stmp-fixinc'.  Stop.
> make: *** Waiting for unfinished jobs....

and why not just fix that, rather than introducing yet another option?
This error suggests current --disable-fixincludes is useless on it's
own.

	Rainer
  
Martin Liška May 11, 2022, 11:58 a.m. UTC | #7
On 5/11/22 13:31, Rainer Orth wrote:
> Hi Martin,
> 
>>>> Subject: [PATCH] configure: add --disable-fix-includes
>>>
>>> As I've mentioned before, I believe, the command is called fixincludes
>>> in current gcc docs, and the option should reflect that, not introduce a
>>> name used nowhere else.
>>
>> No, I can't use it, because even with current master using --disable-fixincludes
>> means the tool is not built at all. It results with:
>>
>> g++ -g -DIN_GCC -fPIC -fno-exceptions -fno-rtti
>> -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
>> -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic
>> -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common
>> -DHAVE_CONFIG_H -DGENERATOR_FILE -static-libstdc++ -static-libgcc -o
>> build/genchecksum \
>>     build/genchecksum.o ../build-x86_64-pc-linux-gnu/libiberty/pic/libiberty.a
>> make: *** No rule to make target
>> '../build-x86_64-pc-linux-gnu/fixincludes/fixinc.sh', needed by
>> 'stmp-fixinc'.  Stop.
>> make: *** Waiting for unfinished jobs....
> 
> and why not just fix that, rather than introducing yet another option?

I would like to, but I don't understant autoconf much :/

@Joseph: Can you please help me why --disable-$foo disables building $foo
folder during the build?

Thanks,
Martin

> This error suggests current --disable-fixincludes is useless on it's
> own.
> 
> 	Rainer
>
  
Andreas Schwab May 11, 2022, 12:48 p.m. UTC | #8
On Mai 11 2022, Martin Liška wrote:

> @Joseph: Can you please help me why --disable-$foo disables building $foo
> folder during the build?

# Handle --disable-<component> generically.
for dir in $configdirs $build_configdirs $target_configdirs ; do
  dirname=`echo $dir | sed -e s/target-//g -e s/build-//g -e s/-/_/g`
  varname=`echo $dirname | sed -e s/+/_/g`
  if eval test x\${enable_${varname}} "=" xno ; then
    noconfigdirs="$noconfigdirs $dir"
  fi
done
  
Martin Liška May 11, 2022, 2:50 p.m. UTC | #9
On 5/11/22 14:48, Andreas Schwab wrote:
> On Mai 11 2022, Martin Liška wrote:
> 
>> @Joseph: Can you please help me why --disable-$foo disables building $foo
>> folder during the build?
> 
> # Handle --disable-<component> generically.
> for dir in $configdirs $build_configdirs $target_configdirs ; do
>   dirname=`echo $dir | sed -e s/target-//g -e s/build-//g -e s/-/_/g`
>   varname=`echo $dirname | sed -e s/+/_/g`
>   if eval test x\${enable_${varname}} "=" xno ; then
>     noconfigdirs="$noconfigdirs $dir"
>   fi
> done
> 

Great, thanks!

Using that I provide v3 where I renamed the option to --{enable,disable}-fixincludes.

Ready to be installed?
Thanks,
Martin
  
Alexandre Oliva May 20, 2022, 12:42 p.m. UTC | #10
On May 11, 2022, Martin Liška <mliska@suse.cz> wrote:

> Ready to be installed?

Hmm...  I don't like that --disable-fixincludes would still configure,
build and even install fixincludes.  This would be surprising, given
that the semantics of disabling a component is to not even configure it.

How about leaving the top-level alone, and changing gcc/configure.ac to
clear STMP_FIXINC when --disable-fixincludes is given?
  

Patch

diff --git a/fixincludes/fixinc.in b/fixincludes/fixinc.in
index 0c3066452c6..3ebcd346d41 100755
--- a/fixincludes/fixinc.in
+++ b/fixincludes/fixinc.in
@@ -63,6 +63,12 @@  else
   esac
 fi
 
+if test "x$DISABLE_FIX_INCLUDES" = "xyes"
+then
+  echo "Skipping fixincludes"
+  exit 0
+fi
+
 # Define what target system we're fixing.
 #
 if test -r ./Makefile; then
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 31ff95500c9..c77f1cc644d 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -401,6 +401,8 @@  PLUGINLIBS = @pluginlibs@
 
 enable_plugin = @enable_plugin@
 
+disable_fix_includes = @disable_fix_includes@
+
 # On MinGW plugin installation involves installing import libraries.
 ifeq ($(enable_plugin),yes)
   plugin_implib := $(if $(strip $(filter mingw%,$(host_os))),yes,no)
@@ -3248,8 +3250,8 @@  stmp-fixinc: gsyslimits.h macro_list fixinc_list \
 	    chmod a+rx $${fix_dir} || true; \
 	    (TARGET_MACHINE='$(target)'; srcdir=`cd $(srcdir); ${PWD_COMMAND}`; \
 	      SHELL='$(SHELL)'; MACRO_LIST=`${PWD_COMMAND}`/macro_list ; \
-	      gcc_dir=`${PWD_COMMAND}` ; \
-	      export TARGET_MACHINE srcdir SHELL MACRO_LIST && \
+	      gcc_dir=`${PWD_COMMAND}` ; DISABLE_FIX_INCLUDES=${disable_fix_includes} \
+	      export TARGET_MACHINE srcdir SHELL MACRO_LIST DISABLE_FIX_INCLUDES && \
 	      cd $(build_objdir)/fixincludes && \
 	      $(SHELL) ./fixinc.sh "$${gcc_dir}/$${fix_dir}" \
 	        $(BUILD_SYSTEM_HEADER_DIR) $(OTHER_FIXINCLUDES_DIRS) ); \
diff --git a/gcc/configure b/gcc/configure
index bd4d4721868..843ab02bfa3 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -839,6 +839,7 @@  with_float
 with_cpu
 enable_multiarch
 enable_multilib
+disable_fix_includes
 coverage_flags
 valgrind_command
 valgrind_path_defines
@@ -958,6 +959,7 @@  enable_werror_always
 enable_checking
 enable_coverage
 enable_gather_detailed_mem_stats
+enable_disable_fix_includes
 enable_valgrind_annotations
 enable_multilib
 enable_multiarch
@@ -1688,6 +1690,7 @@  Optional Features:
                           Values are opt, noopt, default is noopt
   --enable-gather-detailed-mem-stats
                           enable detailed memory allocation stats gathering
+  --disable-fix-includes  skip fixing of includes
   --enable-valgrind-annotations
                           enable valgrind runtime interaction
   --enable-multilib       enable library support for multiple ABIs
@@ -7780,6 +7783,20 @@  cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+# Check whether --enable-disable-fix-includes was given.
+if test "${enable_disable_fix_includes+set}" = set; then :
+  enableval=$enable_disable_fix_includes;
+else
+  disable_fix_includes=yes
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define FIX_INCLUDES $disable_fix_includes
+_ACEOF
+
+
+
 # Check whether --enable-valgrind-annotations was given.
 if test "${enable_valgrind_annotations+set}" = set; then :
   enableval=$enable_valgrind_annotations;
@@ -19659,7 +19676,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19662 "configure"
+#line 19679 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19765,7 +19782,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19768 "configure"
+#line 19785 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 1171c946e6e..6015e403aa9 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -842,6 +842,12 @@  gather_stats=`if test $enable_gather_detailed_mem_stats != no; then echo 1; else
 AC_DEFINE_UNQUOTED(GATHER_STATISTICS, $gather_stats,
 [Define to enable detailed memory allocation stats gathering.])
 
+AC_ARG_ENABLE(disable-fix-includes,
+[AS_HELP_STRING([--disable-fix-includes],
+		[skip fixing of includes])], [],
+[disable_fix_includes=yes])
+AC_SUBST(disable_fix_includes)
+
 AC_ARG_ENABLE(valgrind-annotations,
 [AS_HELP_STRING([--enable-valgrind-annotations],
 		[enable valgrind runtime interaction])], [],