Patchwork Use explicit -I for libstdc++-v3 header files to build libsanitizer

login
register
mail settings
Submitter H.J. Lu
Date Nov. 19, 2012, 5:07 a.m.
Message ID <20121119050707.GA31910@gmail.com>
Download mbox | patch
Permalink /patch/199924/
State New
Headers show

Comments

H.J. Lu - Nov. 19, 2012, 5:07 a.m.
Hi,

This patch adds explicit -I for libstdc++-v3 header files when building
libsanitizer so that it can be used for bootstrapping GCC.  Othewise,
-funconfigured-libstcd++-v3 will be used to compile multilib
libsanitizer.  OK to install?

Thanks.


H.J.
---
2012-11-18  H.J. Lu  <hongjiu.lu@intel.com>

	* Makefile.am (AM_MAKEFLAGS): Remove CC and CXX.
	* configure.ac (ACX_NONCANONICAL_TARGET): New.
	* asan/Makefile.am (AM_CXXFLAGS): Add -I for libstdc++-v3 header
	files.
	(AM_MAKEFLAGS): Remove CC and CXX.
	* interception/Makefile.am: Likewise.
	* sanitizer_common/Makefile.am: Likewise.
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.
	* asan/Makefile.in: Likewise.
	* interception/Makefile.in: Likewise.
	* sanitizer_common/Makefile.in: Likewise.
Jakub Jelinek - Nov. 19, 2012, 8:09 a.m.
On Sun, Nov 18, 2012 at 09:07:07PM -0800, H.J. Lu wrote:
> This patch adds explicit -I for libstdc++-v3 header files when building
> libsanitizer so that it can be used for bootstrapping GCC.  Othewise,
> -funconfigured-libstcd++-v3 will be used to compile multilib
> libsanitizer.  OK to install?

Ugh, this is wrong.  libstdc++ has scripts/testsuite_flags --build-includes
and similar for a reason.  You should use that script, instead of hardcoding
it.

	Jakub
H.J. Lu - Nov. 19, 2012, 2:20 p.m.
On Mon, Nov 19, 2012 at 12:09 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Sun, Nov 18, 2012 at 09:07:07PM -0800, H.J. Lu wrote:
>> This patch adds explicit -I for libstdc++-v3 header files when building
>> libsanitizer so that it can be used for bootstrapping GCC.  Othewise,
>> -funconfigured-libstcd++-v3 will be used to compile multilib
>> libsanitizer.  OK to install?
>
> Ugh, this is wrong.  libstdc++ has scripts/testsuite_flags --build-includes
> and similar for a reason.  You should use that script, instead of hardcoding
> it.
>

It doesn't work with bootstrap=true for libsanitizer due to
-funconfigured-libstcd++-v3 is used to compile multilib
libsanitizer:

# CXX_FOR_TARGET is tricky to get right for target libs that require a
# functional C++ compiler.  When we recurse, if we expand
# CXX_FOR_TARGET before configuring libstdc++-v3, we won't get
# libstdc++ include flags from the script.  Instead, we get an
# -funconfigured-* word, so that we'll get errors if this invalid C++
# command line is used for anything, but also so that we can use the
# word to decide whether or not to pass on this CXX_FOR_TARGET.  If we
# don't pass it on, sub-make will use the default definition, that
# re-expands it at the time of use, so we'll get it right when we need
# it.  One potential exception is the expansion of CXX_FOR_TARGET
# passed down as part of CXX within TARGET_FLAGS, but this wouldn't
# really work, for C++ host programs can't depend on the current-stage
# C++ target library.

RAW_CXX_TARGET_EXPORTS is used to work around it:

target_modules = { module= libsanitizer;
                   bootstrap=true;
                   lib_path=.libs;
                   raw_cxx=true; };

That is why I need to explicit -I for libstdc++-v3 header files.

Patch

diff --git a/libsanitizer/Makefile.am b/libsanitizer/Makefile.am
index 91e3434..aa8021a 100644
--- a/libsanitizer/Makefile.am
+++ b/libsanitizer/Makefile.am
@@ -33,8 +33,6 @@  AM_MAKEFLAGS = \
 	"includedir=$(includedir)" \
 	"AR=$(AR)" \
 	"AS=$(AS)" \
-	"CC=$(CC)" \
-	"CXX=$(CXX)" \
 	"LD=$(LD)" \
 	"LIBCFLAGS=$(LIBCFLAGS)" \
 	"NM=$(NM)" \
diff --git a/libsanitizer/Makefile.in b/libsanitizer/Makefile.in
index 8d685fd..4bb8ff2 100644
--- a/libsanitizer/Makefile.in
+++ b/libsanitizer/Makefile.in
@@ -41,7 +41,8 @@  DIST_COMMON = $(am__configure_deps) $(srcdir)/../config.guess \
 	$(srcdir)/../mkinstalldirs $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(top_srcdir)/configure ChangeLog
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+	$(top_srcdir)/../config/depstand.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
@@ -236,6 +237,7 @@  sysconfdir = @sysconfdir@
 target = @target@
 target_alias = @target_alias@
 target_cpu = @target_cpu@
+target_noncanonical = @target_noncanonical@
 target_os = @target_os@
 target_vendor = @target_vendor@
 toolexecdir = @toolexecdir@
@@ -277,8 +279,6 @@  AM_MAKEFLAGS = \
 	"includedir=$(includedir)" \
 	"AR=$(AR)" \
 	"AS=$(AS)" \
-	"CC=$(CC)" \
-	"CXX=$(CXX)" \
 	"LD=$(LD)" \
 	"LIBCFLAGS=$(LIBCFLAGS)" \
 	"NM=$(NM)" \
diff --git a/libsanitizer/aclocal.m4 b/libsanitizer/aclocal.m4
index a52bc30..d6782f8 100644
--- a/libsanitizer/aclocal.m4
+++ b/libsanitizer/aclocal.m4
@@ -990,6 +990,7 @@  AC_SUBST([am__tar])
 AC_SUBST([am__untar])
 ]) # _AM_PROG_TAR
 
+m4_include([../config/acx.m4])
 m4_include([../config/depstand.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/multi.m4])
diff --git a/libsanitizer/asan/Makefile.am b/libsanitizer/asan/Makefile.am
index 3da1db3..45fb3b3 100644
--- a/libsanitizer/asan/Makefile.am
+++ b/libsanitizer/asan/Makefile.am
@@ -5,6 +5,10 @@  gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
 
 DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DASAN_HAS_EXCEPTIONS=1 -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0 -DASAN_NEEDS_SEGV=1
 AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros -Wno-c99-extensions 
+## We require libstdc++-v3 to be in the same build tree.
+AM_CXXFLAGS += -I../../libstdc++-v3/include \
+	       -I../../libstdc++-v3/include/$(target_noncanonical) \
+	       -I$(srcdir)/../../libstdc++-v3/libsupc++
 ACLOCAL_AMFLAGS = -I $(top_srcdir) -I $(top_srcdir)/config
 
 toolexeclib_LTLIBRARIES = libasan.la
@@ -64,8 +68,6 @@  AM_MAKEFLAGS = \
 	"includedir=$(includedir)" \
 	"AR=$(AR)" \
 	"AS=$(AS)" \
-	"CC=$(CC)" \
-	"CXX=$(CXX)" \
 	"LD=$(LD)" \
 	"LIBCFLAGS=$(LIBCFLAGS)" \
 	"NM=$(NM)" \
diff --git a/libsanitizer/asan/Makefile.in b/libsanitizer/asan/Makefile.in
index e5e8d40..681fe5e 100644
--- a/libsanitizer/asan/Makefile.in
+++ b/libsanitizer/asan/Makefile.in
@@ -38,7 +38,8 @@  target_triplet = @target@
 subdir = asan
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+	$(top_srcdir)/../config/depstand.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
@@ -228,6 +229,7 @@  sysconfdir = @sysconfdir@
 target = @target@
 target_alias = @target_alias@
 target_cpu = @target_cpu@
+target_noncanonical = @target_noncanonical@
 target_os = @target_os@
 target_vendor = @target_vendor@
 toolexecdir = @toolexecdir@
@@ -239,7 +241,13 @@  AM_CPPFLAGS = -I $(top_srcdir)/include -I $(top_srcdir)
 
 # May be used by toolexeclibdir.
 gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
-AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros -Wno-c99-extensions 
+AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \
+	-Wno-long-long -fPIC -fno-builtin -fno-exceptions \
+	-fomit-frame-pointer -funwind-tables -fvisibility=hidden \
+	-Wno-variadic-macros -Wno-c99-extensions \
+	-I../../libstdc++-v3/include \
+	-I../../libstdc++-v3/include/$(target_noncanonical) \
+	-I$(srcdir)/../../libstdc++-v3/libsupc++
 ACLOCAL_AMFLAGS = -I $(top_srcdir) -I $(top_srcdir)/config
 toolexeclib_LTLIBRARIES = libasan.la
 asan_files = \
@@ -297,8 +305,6 @@  AM_MAKEFLAGS = \
 	"includedir=$(includedir)" \
 	"AR=$(AR)" \
 	"AS=$(AS)" \
-	"CC=$(CC)" \
-	"CXX=$(CXX)" \
 	"LD=$(LD)" \
 	"LIBCFLAGS=$(LIBCFLAGS)" \
 	"NM=$(NM)" \
diff --git a/libsanitizer/configure b/libsanitizer/configure
index e3b3928..9907ad1 100755
--- a/libsanitizer/configure
+++ b/libsanitizer/configure
@@ -682,6 +682,7 @@  am__isrc
 INSTALL_DATA
 INSTALL_SCRIPT
 INSTALL_PROGRAM
+target_noncanonical
 target_os
 target_vendor
 target_cpu
@@ -2384,6 +2385,23 @@  test -n "$target_alias" &&
     NONENONEs,x,x, &&
   program_prefix=${target_alias}-
 
+ case ${build_alias} in
+  "") build_noncanonical=${build} ;;
+  *) build_noncanonical=${build_alias} ;;
+esac
+
+ case ${host_alias} in
+  "") host_noncanonical=${build_noncanonical} ;;
+  *) host_noncanonical=${host_alias} ;;
+esac
+
+ case ${target_alias} in
+  "") target_noncanonical=${host_noncanonical} ;;
+  *) target_noncanonical=${target_alias} ;;
+esac
+
+
+
 target_alias=${target_alias-$host_alias}
 
 
@@ -10898,7 +10916,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10901 "configure"
+#line 10919 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11004,7 +11022,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11007 "configure"
+#line 11025 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac
index 4fb576f..996f44d 100644
--- a/libsanitizer/configure.ac
+++ b/libsanitizer/configure.ac
@@ -19,6 +19,7 @@  AC_MSG_RESULT($version_specific_libs)
 # Do not delete or change the following two lines.  For why, see
 # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
 AC_CANONICAL_SYSTEM
+ACX_NONCANONICAL_TARGET
 target_alias=${target_alias-$host_alias}
 AC_SUBST(target_alias)
 
diff --git a/libsanitizer/interception/Makefile.am b/libsanitizer/interception/Makefile.am
index b92a180..7b41450 100644
--- a/libsanitizer/interception/Makefile.am
+++ b/libsanitizer/interception/Makefile.am
@@ -5,6 +5,10 @@  gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
 
 DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
 AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros -Wno-c99-extensions 
+## We require libstdc++-v3 to be in the same build tree.
+AM_CXXFLAGS += -I../../libstdc++-v3/include \
+	       -I../../libstdc++-v3/include/$(target_noncanonical) \
+	       -I$(srcdir)/../../libstdc++-v3/libsupc++
 ACLOCAL_AMFLAGS = -I m4
 
 noinst_LTLIBRARIES = libinterception.la
@@ -47,8 +51,6 @@  AM_MAKEFLAGS = \
 	"includedir=$(includedir)" \
 	"AR=$(AR)" \
 	"AS=$(AS)" \
-	"CC=$(CC)" \
-	"CXX=$(CXX)" \
 	"LD=$(LD)" \
 	"LIBCFLAGS=$(LIBCFLAGS)" \
 	"NM=$(NM)" \
diff --git a/libsanitizer/interception/Makefile.in b/libsanitizer/interception/Makefile.in
index b32e86e..6810cd6 100644
--- a/libsanitizer/interception/Makefile.in
+++ b/libsanitizer/interception/Makefile.in
@@ -38,7 +38,8 @@  target_triplet = @target@
 subdir = interception
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+	$(top_srcdir)/../config/depstand.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
@@ -196,6 +197,7 @@  sysconfdir = @sysconfdir@
 target = @target@
 target_alias = @target_alias@
 target_cpu = @target_cpu@
+target_noncanonical = @target_noncanonical@
 target_os = @target_os@
 target_vendor = @target_vendor@
 toolexecdir = @toolexecdir@
@@ -207,7 +209,13 @@  AM_CPPFLAGS = -I $(top_srcdir)/include
 
 # May be used by toolexeclibdir.
 gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
-AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros -Wno-c99-extensions 
+AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \
+	-Wno-long-long -fPIC -fno-builtin -fno-exceptions \
+	-fomit-frame-pointer -funwind-tables -fvisibility=hidden \
+	-Wno-variadic-macros -Wno-c99-extensions \
+	-I../../libstdc++-v3/include \
+	-I../../libstdc++-v3/include/$(target_noncanonical) \
+	-I$(srcdir)/../../libstdc++-v3/libsupc++
 ACLOCAL_AMFLAGS = -I m4
 noinst_LTLIBRARIES = libinterception.la
 interception_files = \
@@ -248,8 +256,6 @@  AM_MAKEFLAGS = \
 	"includedir=$(includedir)" \
 	"AR=$(AR)" \
 	"AS=$(AS)" \
-	"CC=$(CC)" \
-	"CXX=$(CXX)" \
 	"LD=$(LD)" \
 	"LIBCFLAGS=$(LIBCFLAGS)" \
 	"NM=$(NM)" \
diff --git a/libsanitizer/sanitizer_common/Makefile.am b/libsanitizer/sanitizer_common/Makefile.am
index 2968c05..4e3df9a 100644
--- a/libsanitizer/sanitizer_common/Makefile.am
+++ b/libsanitizer/sanitizer_common/Makefile.am
@@ -5,6 +5,10 @@  gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
 
 DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
 AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros -Wno-c99-extensions 
+## We require libstdc++-v3 to be in the same build tree.
+AM_CXXFLAGS += -I../../libstdc++-v3/include \
+	       -I../../libstdc++-v3/include/$(target_noncanonical) \
+	       -I$(srcdir)/../../libstdc++-v3/libsupc++
 ACLOCAL_AMFLAGS = -I m4
 
 noinst_LTLIBRARIES = libsanitizer_common.la
@@ -59,8 +63,6 @@  AM_MAKEFLAGS = \
 	"includedir=$(includedir)" \
 	"AR=$(AR)" \
 	"AS=$(AS)" \
-	"CC=$(CC)" \
-	"CXX=$(CXX)" \
 	"LD=$(LD)" \
 	"LIBCFLAGS=$(LIBCFLAGS)" \
 	"NM=$(NM)" \
diff --git a/libsanitizer/sanitizer_common/Makefile.in b/libsanitizer/sanitizer_common/Makefile.in
index 9c7ee51..6889d31 100644
--- a/libsanitizer/sanitizer_common/Makefile.in
+++ b/libsanitizer/sanitizer_common/Makefile.in
@@ -38,7 +38,8 @@  target_triplet = @target@
 subdir = sanitizer_common
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+	$(top_srcdir)/../config/depstand.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
@@ -201,6 +202,7 @@  sysconfdir = @sysconfdir@
 target = @target@
 target_alias = @target_alias@
 target_cpu = @target_cpu@
+target_noncanonical = @target_noncanonical@
 target_os = @target_os@
 target_vendor = @target_vendor@
 toolexecdir = @toolexecdir@
@@ -212,7 +214,13 @@  AM_CPPFLAGS = -I $(top_srcdir)/include
 
 # May be used by toolexeclibdir.
 gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
-AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros -Wno-c99-extensions 
+AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \
+	-Wno-long-long -fPIC -fno-builtin -fno-exceptions \
+	-fomit-frame-pointer -funwind-tables -fvisibility=hidden \
+	-Wno-variadic-macros -Wno-c99-extensions \
+	-I../../libstdc++-v3/include \
+	-I../../libstdc++-v3/include/$(target_noncanonical) \
+	-I$(srcdir)/../../libstdc++-v3/libsupc++
 ACLOCAL_AMFLAGS = -I m4
 noinst_LTLIBRARIES = libsanitizer_common.la
 sanitizer_common_files = \
@@ -265,8 +273,6 @@  AM_MAKEFLAGS = \
 	"includedir=$(includedir)" \
 	"AR=$(AR)" \
 	"AS=$(AS)" \
-	"CC=$(CC)" \
-	"CXX=$(CXX)" \
 	"LD=$(LD)" \
 	"LIBCFLAGS=$(LIBCFLAGS)" \
 	"NM=$(NM)" \