Patchwork Use explicit -I for libstdc++-v3 header files

login
register
mail settings
Submitter H.J. Lu
Date Nov. 29, 2012, 6:30 p.m.
Message ID <20121129183008.GA31615@intel.com>
Download mbox | patch
Permalink /patch/202804/
State New
Headers show

Comments

H.J. Lu - Nov. 29, 2012, 6:30 p.m.
Hi,

Since libsanitizer is used for bootstrap and compiled with raw_cxx,
we need to use explicit -I for libstdc++-v3 header files in
libsanitizer.  Otherwise, we will get

libtool: compile: unrecognized option `-D_GNU_SOURCE'
libtool: compile: Try `libtool --help' for more information.

This patch fixes it.  OK to install?

Thanks.


H.J.
---
 libsanitizer/Makefile.am                  |  2 --
 libsanitizer/Makefile.in                  |  6 +++---
 libsanitizer/aclocal.m4                   |  1 +
 libsanitizer/asan/Makefile.am             |  6 ++++--
 libsanitizer/asan/Makefile.in             | 14 ++++++++++----
 libsanitizer/configure                    | 22 ++++++++++++++++++++--
 libsanitizer/configure.ac                 |  1 +
 libsanitizer/interception/Makefile.am     |  6 ++++--
 libsanitizer/interception/Makefile.in     | 14 ++++++++++----
 libsanitizer/sanitizer_common/Makefile.am |  6 ++++--
 libsanitizer/sanitizer_common/Makefile.in | 14 ++++++++++----
 libsanitizer/tsan/Makefile.am             |  6 ++++--
 libsanitizer/tsan/Makefile.in             | 13 +++++++++----
 14 files changed, 97 insertions(+), 31 deletions(-)
 create mode 100644 libsanitizer/ChangeLog.asan

2012-11-22  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.
	* tsan/Makefile.am: Likewise.
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.
	* asan/Makefile.in: Likewise.
	* interception/Makefile.in: Likewise.
	* sanitizer_common/Makefile.in: Likewise.
	* tsan/Makefile.in: Likewise.
Andrew Pinski - Nov. 29, 2012, 6:34 p.m.
On Thu, Nov 29, 2012 at 10:30 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> Hi,
>
> Since libsanitizer is used for bootstrap and compiled with raw_cxx,
> we need to use explicit -I for libstdc++-v3 header files in
> libsanitizer.  Otherwise, we will get
>
> libtool: compile: unrecognized option `-D_GNU_SOURCE'
> libtool: compile: Try `libtool --help' for more information.
>
> This patch fixes it.  OK to install?

Is there a reason why your change to have libsanitizer be bootstrapped
wait to be committed until this patch was approved?
I think you should revert the change to have libsanitizer be
bootstrapped and only commit that after this patch has been approved
because right now nobody can do any work as bootstrap is broken.

Thanks,
Andrew Pinski


>
> Thanks.
>
>
> H.J.
> ---
>  libsanitizer/Makefile.am                  |  2 --
>  libsanitizer/Makefile.in                  |  6 +++---
>  libsanitizer/aclocal.m4                   |  1 +
>  libsanitizer/asan/Makefile.am             |  6 ++++--
>  libsanitizer/asan/Makefile.in             | 14 ++++++++++----
>  libsanitizer/configure                    | 22 ++++++++++++++++++++--
>  libsanitizer/configure.ac                 |  1 +
>  libsanitizer/interception/Makefile.am     |  6 ++++--
>  libsanitizer/interception/Makefile.in     | 14 ++++++++++----
>  libsanitizer/sanitizer_common/Makefile.am |  6 ++++--
>  libsanitizer/sanitizer_common/Makefile.in | 14 ++++++++++----
>  libsanitizer/tsan/Makefile.am             |  6 ++++--
>  libsanitizer/tsan/Makefile.in             | 13 +++++++++----
>  14 files changed, 97 insertions(+), 31 deletions(-)
>  create mode 100644 libsanitizer/ChangeLog.asan
>
> 2012-11-22  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.
>         * tsan/Makefile.am: Likewise.
>         * Makefile.in: Regenerated.
>         * aclocal.m4: Likewise.
>         * configure: Likewise.
>         * asan/Makefile.in: Likewise.
>         * interception/Makefile.in: Likewise.
>         * sanitizer_common/Makefile.in: Likewise.
>         * tsan/Makefile.in: Likewise.
>
> diff --git a/libsanitizer/Makefile.am b/libsanitizer/Makefile.am
> index 64d3d2e..cd4e92d 100644
> --- a/libsanitizer/Makefile.am
> +++ b/libsanitizer/Makefile.am
> @@ -37,8 +37,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 21c2711..53e0be9 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@
> @@ -278,8 +280,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 48f984c..0d6007e 100755
> --- a/libsanitizer/configure
> +++ b/libsanitizer/configure
> @@ -686,6 +686,7 @@ am__isrc
>  INSTALL_DATA
>  INSTALL_SCRIPT
>  INSTALL_PROGRAM
> +target_noncanonical
>  target_os
>  target_vendor
>  target_cpu
> @@ -2566,6 +2567,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}
>
>
> @@ -11080,7 +11098,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11083 "configure"
> +#line 11101 "configure"
>  #include "confdefs.h"
>
>  #if HAVE_DLFCN_H
> @@ -11186,7 +11204,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11189 "configure"
> +#line 11207 "configure"
>  #include "confdefs.h"
>
>  #if HAVE_DLFCN_H
> diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac
> index 2d62ec4..9c73904 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 029417f..7669e8c 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
> @@ -51,8 +55,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 bd58c4d..bc41d72 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 \
> @@ -211,6 +212,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@
> @@ -222,7 +224,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 = \
> @@ -264,8 +272,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)" \
> diff --git a/libsanitizer/tsan/Makefile.am b/libsanitizer/tsan/Makefile.am
> index a391986..6a4bf75 100644
> --- a/libsanitizer/tsan/Makefile.am
> +++ b/libsanitizer/tsan/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
> +## 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
>
>  toolexeclib_LTLIBRARIES = libtsan.la
> @@ -67,8 +71,6 @@ AM_MAKEFLAGS = \
>         "includedir=$(includedir)" \
>         "AR=$(AR)" \
>         "AS=$(AS)" \
> -       "CC=$(CC)" \
> -       "CXX=$(CXX)" \
>         "LD=$(LD)" \
>         "LIBCFLAGS=$(LIBCFLAGS)" \
>         "NM=$(NM)" \
> diff --git a/libsanitizer/tsan/Makefile.in b/libsanitizer/tsan/Makefile.in
> index 23550e5..5b1e536 100644
> --- a/libsanitizer/tsan/Makefile.in
> +++ b/libsanitizer/tsan/Makefile.in
> @@ -38,7 +38,8 @@ target_triplet = @target@
>  subdir = tsan
>  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 \
> @@ -229,6 +230,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@
> @@ -240,7 +242,12 @@ AM_CPPFLAGS = -I $(top_srcdir) -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
> +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 -I../../libstdc++-v3/include \
> +       -I../../libstdc++-v3/include/$(target_noncanonical) \
> +       -I$(srcdir)/../../libstdc++-v3/libsupc++
>  ACLOCAL_AMFLAGS = -I m4
>  toolexeclib_LTLIBRARIES = libtsan.la
>  tsan_files = \
> @@ -301,8 +308,6 @@ AM_MAKEFLAGS = \
>         "includedir=$(includedir)" \
>         "AR=$(AR)" \
>         "AS=$(AS)" \
> -       "CC=$(CC)" \
> -       "CXX=$(CXX)" \
>         "LD=$(LD)" \
>         "LIBCFLAGS=$(LIBCFLAGS)" \
>         "NM=$(NM)" \
> --
> 1.7.11.7
>
H.J. Lu - Nov. 29, 2012, 6:40 p.m.
On Thu, Nov 29, 2012 at 10:34 AM, Andrew Pinski <pinskia@gmail.com> wrote:
> On Thu, Nov 29, 2012 at 10:30 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>> Hi,
>>
>> Since libsanitizer is used for bootstrap and compiled with raw_cxx,
>> we need to use explicit -I for libstdc++-v3 header files in
>> libsanitizer.  Otherwise, we will get
>>
>> libtool: compile: unrecognized option `-D_GNU_SOURCE'
>> libtool: compile: Try `libtool --help' for more information.
>>
>> This patch fixes it.  OK to install?
>
> Is there a reason why your change to have libsanitizer be bootstrapped
> wait to be committed until this patch was approved?
> I think you should revert the change to have libsanitizer be
> bootstrapped and only commit that after this patch has been approved
> because right now nobody can do any work as bootstrap is broken.
>

I posted my patch:

http://gcc.gnu.org/ml/gcc-patches/2012-11/msg01530.html

Since it didn't fix anything at the time,  there was no incentive
for anyone to review it.  Please someone review my patch
and get over with it.

FWIW,  libjava has the same issue with libstdc++ dependency
as a bootstrap library.  I applied the same solution to libsanitizer.
Andrew Pinski - Nov. 29, 2012, 6:41 p.m.
On Thu, Nov 29, 2012 at 10:40 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Nov 29, 2012 at 10:34 AM, Andrew Pinski <pinskia@gmail.com> wrote:
>> On Thu, Nov 29, 2012 at 10:30 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>>> Hi,
>>>
>>> Since libsanitizer is used for bootstrap and compiled with raw_cxx,
>>> we need to use explicit -I for libstdc++-v3 header files in
>>> libsanitizer.  Otherwise, we will get
>>>
>>> libtool: compile: unrecognized option `-D_GNU_SOURCE'
>>> libtool: compile: Try `libtool --help' for more information.
>>>
>>> This patch fixes it.  OK to install?
>>
>> Is there a reason why your change to have libsanitizer be bootstrapped
>> wait to be committed until this patch was approved?
>> I think you should revert the change to have libsanitizer be
>> bootstrapped and only commit that after this patch has been approved
>> because right now nobody can do any work as bootstrap is broken.
>>
>
> I posted my patch:
>
> http://gcc.gnu.org/ml/gcc-patches/2012-11/msg01530.html
>
> Since it didn't fix anything at the time,  there was no incentive
> for anyone to review it.  Please someone review my patch
> and get over with it.

So you broke the build to force someone to review your patch?  That
seems backwards.

Thanks,
Andrew

>
> FWIW,  libjava has the same issue with libstdc++ dependency
> as a bootstrap library.  I applied the same solution to libsanitizer.
>
>
> --
> H.J.

Patch

diff --git a/libsanitizer/Makefile.am b/libsanitizer/Makefile.am
index 64d3d2e..cd4e92d 100644
--- a/libsanitizer/Makefile.am
+++ b/libsanitizer/Makefile.am
@@ -37,8 +37,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 21c2711..53e0be9 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@
@@ -278,8 +280,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 48f984c..0d6007e 100755
--- a/libsanitizer/configure
+++ b/libsanitizer/configure
@@ -686,6 +686,7 @@  am__isrc
 INSTALL_DATA
 INSTALL_SCRIPT
 INSTALL_PROGRAM
+target_noncanonical
 target_os
 target_vendor
 target_cpu
@@ -2566,6 +2567,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}
 
 
@@ -11080,7 +11098,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11083 "configure"
+#line 11101 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11186,7 +11204,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11189 "configure"
+#line 11207 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac
index 2d62ec4..9c73904 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 029417f..7669e8c 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
@@ -51,8 +55,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 bd58c4d..bc41d72 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 \
@@ -211,6 +212,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@
@@ -222,7 +224,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 = \
@@ -264,8 +272,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)" \
diff --git a/libsanitizer/tsan/Makefile.am b/libsanitizer/tsan/Makefile.am
index a391986..6a4bf75 100644
--- a/libsanitizer/tsan/Makefile.am
+++ b/libsanitizer/tsan/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
+## 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
 
 toolexeclib_LTLIBRARIES = libtsan.la
@@ -67,8 +71,6 @@  AM_MAKEFLAGS = \
 	"includedir=$(includedir)" \
 	"AR=$(AR)" \
 	"AS=$(AS)" \
-	"CC=$(CC)" \
-	"CXX=$(CXX)" \
 	"LD=$(LD)" \
 	"LIBCFLAGS=$(LIBCFLAGS)" \
 	"NM=$(NM)" \
diff --git a/libsanitizer/tsan/Makefile.in b/libsanitizer/tsan/Makefile.in
index 23550e5..5b1e536 100644
--- a/libsanitizer/tsan/Makefile.in
+++ b/libsanitizer/tsan/Makefile.in
@@ -38,7 +38,8 @@  target_triplet = @target@
 subdir = tsan
 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 \
@@ -229,6 +230,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@
@@ -240,7 +242,12 @@  AM_CPPFLAGS = -I $(top_srcdir) -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
+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 -I../../libstdc++-v3/include \
+	-I../../libstdc++-v3/include/$(target_noncanonical) \
+	-I$(srcdir)/../../libstdc++-v3/libsupc++
 ACLOCAL_AMFLAGS = -I m4
 toolexeclib_LTLIBRARIES = libtsan.la
 tsan_files = \
@@ -301,8 +308,6 @@  AM_MAKEFLAGS = \
 	"includedir=$(includedir)" \
 	"AR=$(AR)" \
 	"AS=$(AS)" \
-	"CC=$(CC)" \
-	"CXX=$(CXX)" \
 	"LD=$(LD)" \
 	"LIBCFLAGS=$(LIBCFLAGS)" \
 	"NM=$(NM)" \