]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Make copies of cstdlib/cmath and use them [BZ #20314]
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 5 Jul 2016 22:01:33 +0000 (15:01 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 5 Jul 2016 22:01:46 +0000 (15:01 -0700)
If C++ headers <cstdlib> or <cmath> are used, GCC 6 will include
/usr/include/stdlib.h or /usr/include/math.h from "#include_next"
(instead of stdlib/stdlib.h or math/math.h in the glibc source
directory), and this turns up as a make dependency.  An implicit
rule will kick in and make will try to install stdlib/stdlib.h or
math/math.h as /usr/include/stdlib.h or /usr/include/math.h because
the target is out of date.  We make a copy of <cstdlib> and <cmath>
in the glibc build directory so that stdlib/stdlib.h and math/math.h
will be used instead of /usr/include/stdlib.h and /usr/include/math.h.

[BZ #20314]
* Makeconfig (CXXFLAGS): Prepend -I$(common-objpfx).
* Makerules (before-compile): Add $(common-objpfx)cstdlib and
$(common-objpfx)cmath.
($(common-objpfx)cstdlib): New target.
($(common-objpfx)cmath): Likewise.

ChangeLog
Makeconfig
Makerules

index fc313b4307d0c3d536a99b0b4d515185934ceba5..8b1fa85fd70a96095fbb4a0a7f46f85575f5c080 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2016-07-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+       [BZ #20314]
+       * Makeconfig (CXXFLAGS): Prepend -I$(common-objpfx).
+       * Makerules (before-compile): Add $(common-objpfx)cstdlib and
+       $(common-objpfx)cmath.
+       ($(common-objpfx)cstdlib): New target.
+       ($(common-objpfx)cmath): Likewise.
+
 2016-07-05  Chris Metcalf  <cmetcalf@mellanox.com>
 
        * malloc/tst-malloc-thread-fail.c (TIMEOUT): Bump up to 30s.
index 901e253453e769883e65f6118993c7c1fb0b6736..03fd89c13e8cab9364e03d7327db7bd298a4d6a3 100644 (file)
@@ -889,7 +889,8 @@ override CFLAGS     = -std=gnu11 -fgnu89-inline $(config-extra-cflags) \
                  $(CFLAGS-$(@F)) $(tls-model) \
                  $(foreach lib,$(libof-$(basename $(@F))) \
                                $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib)))
-override CXXFLAGS = $(c++-sysincludes) \
+# Use our copies of cstdlib and cmath.
+override CXXFLAGS = -I$(common-objpfx) $(c++-sysincludes) \
                    $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
                    $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
 
index f1ecd4039376328bda1fa4d9e6366c47f54d8bac..7e4077ee505d2f786ce529f5c0b2f5645d8247f8 100644 (file)
--- a/Makerules
+++ b/Makerules
@@ -109,6 +109,30 @@ endif # avoid-generated
 endif # $(build-shared) = yes
 
 ifndef avoid-generated
+ifneq (,$(CXX))
+# If C++ headers <cstdlib> or <cmath> are used, GCC 6 will include
+# /usr/include/stdlib.h or /usr/include/math.h from "#include_next"
+# (instead of stdlib/stdlib.h or math/math.h in the glibc source
+# directory), and this turns up as a make dependency.  An implicit
+# rule will kick in and make will try to install stdlib/stdlib.h or
+# math/math.h as /usr/include/stdlib.h or /usr/include/math.h because
+# the target is out of date.  We make a copy of <cstdlib> and <cmath>
+# in the glibc build directory so that stdlib/stdlib.h and math/math.h
+# 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 <cstdlib>" | $(CXX) -M -MP -x c++ - \
+               | sed -n "/cstdlib:/{s/:$$//;p}")
+$(common-objpfx)cstdlib: $(cstdlib)
+       $(INSTALL_DATA) $< $@T
+       $(move-if-change) $@T $@
+cmath=$(shell echo "\#include <cmath>" | $(CXX) -M -MP -x c++ - \
+               | sed -n "/cmath:/{s/:$$//;p}")
+$(common-objpfx)cmath: $(cmath)
+       $(INSTALL_DATA) $< $@T
+       $(move-if-change) $@T $@
+endif
+
 before-compile := $(common-objpfx)libc-abis.h $(before-compile)
 $(common-objpfx)libc-abis.h: $(common-objpfx)libc-abis.stamp; @:
 $(common-objpfx)libc-abis.stamp: $(..)scripts/gen-libc-abis \