From patchwork Tue Sep 20 11:19:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 15792 Received: (qmail 59169 invoked by alias); 20 Sep 2016 11:19:17 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 59154 invoked by uid 89); 20 Sep 2016 11:19:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Obtain, 85, installing, T X-HELO: mx1.redhat.com To: GNU C Library Cc: "H.J. Lu" From: Florian Weimer Subject: [PATCH] Avoid running $(CXX) during build to obtain header file paths Message-ID: <0193b73d-2ccb-b92d-e86e-0a2f4bb8d7bd@redhat.com> Date: Tue, 20 Sep 2016 13:19:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 On my machine, this cuts down no-op rebuild time from about 10 seconds to around 8.5 seconds. (If you change the compiler, you better re-run configure anyway.) Thanks, Florian Avoid running $(CXX) during build to obtain header file paths This reduces the build time somewhat and is particularly noticeable during rebuilds with few code changes. 2016-09-20 Florian Weimer Avoid running $(CXX) during build to obtain header file paths. * configure.ac (CXX_SYSINCLUDES, CXX_CMATH_HEADER): Set. * config.make.in (c++-cstdlib-header, c++-cmath-header): Define. * Makerules (cstdlib, cmath): Remove variables. Use $(c++-cstdlib-header), $(c++-cmath-header) instead. * configure: Regenerate. diff --git a/Makerules b/Makerules index 748790b..e865782 100644 --- a/Makerules +++ b/Makerules @@ -121,14 +121,10 @@ ifneq (,$(CXX)) # will be used instead of /usr/include/stdlib.h and /usr/include/math.h. before-compile := $(common-objpfx)cstdlib $(common-objpfx)cmath \ $(before-compile) -cstdlib=$(shell echo "\#include " | $(CXX) -M -MP -x c++ - \ - | sed -n "/cstdlib:/{s/:$$//;p}") -$(common-objpfx)cstdlib: $(cstdlib) +$(common-objpfx)cstdlib: $(c++-cstdlib-header) $(INSTALL_DATA) $< $@T $(move-if-change) $@T $@ -cmath=$(shell echo "\#include " | $(CXX) -M -MP -x c++ - \ - | sed -n "/cmath:/{s/:$$//;p}") -$(common-objpfx)cmath: $(cmath) +$(common-objpfx)cmath: $(c++-cmath-header) $(INSTALL_DATA) $< $@T $(move-if-change) $@T $@ endif diff --git a/config.make.in b/config.make.in index 95c6f36..04a8b3e 100644 --- a/config.make.in +++ b/config.make.in @@ -45,6 +45,8 @@ defines = @DEFINES@ sysheaders = @sysheaders@ sysincludes = @SYSINCLUDES@ c++-sysincludes = @CXX_SYSINCLUDES@ +c++-cstdlib-header = @CXX_CSTDLIB_HEADER@ +c++-cmath-header = @CXX_CMATH_HEADER@ all-warnings = @all_warnings@ enable-werror = @enable_werror@ diff --git a/configure b/configure index 17625e1..6ff2527 100755 --- a/configure +++ b/configure @@ -635,6 +635,8 @@ BISON INSTALL_INFO PERL BASH_SHELL +CXX_CMATH_HEADER +CXX_CSTDLIB_HEADER CXX_SYSINCLUDES SYSINCLUDES AUTOCONF @@ -5054,6 +5056,18 @@ fi +# Obtain some C++ header file paths. This is used to make a local +# copy of those headers in Makerules. +if test -n "$CXX"; then + find_cxx_header () { + echo "#include <$1>" | $CXX -M -MP -x c++ - | sed -n "/$1:/{s/:\$//;p}" + } + CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)" + CXX_CMATH_HEADER="$(find_cxx_header cmath)" +fi + + + # Test if LD_LIBRARY_PATH contains the notation for the current directory # since this would lead to problems installing/building glibc. # LD_LIBRARY_PATH contains the current directory if one of the following diff --git a/configure.ac b/configure.ac index 33bcd62..9938ab0 100644 --- a/configure.ac +++ b/configure.ac @@ -1039,6 +1039,18 @@ fi AC_SUBST(SYSINCLUDES) AC_SUBST(CXX_SYSINCLUDES) +# Obtain some C++ header file paths. This is used to make a local +# copy of those headers in Makerules. +if test -n "$CXX"; then + find_cxx_header () { + echo "#include <$1>" | $CXX -M -MP -x c++ - | sed -n "/$1:/{s/:\$//;p}" + } + CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)" + CXX_CMATH_HEADER="$(find_cxx_header cmath)" +fi +AC_SUBST(CXX_CSTDLIB_HEADER) +AC_SUBST(CXX_CMATH_HEADER) + # Test if LD_LIBRARY_PATH contains the notation for the current directory # since this would lead to problems installing/building glibc. # LD_LIBRARY_PATH contains the current directory if one of the following