This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Add --with-build-config=bootstrap-asan support
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 17 Nov 2012 15:54:41 -0800
- Subject: PATCH: Add --with-build-config=bootstrap-asan support
Hi,
This patch adds --with-build-config=bootstrap-asan support. OK to
install?
Thanks.
H.J.
---
2012-11-17 H.J. Lu <hongjiu.lu@intel.com>
* Makefile.def (target_modules): Add bootstrap=true for
libsanitizer.
* Makefile.tpl (LIBASAN_LIBS): New for gcc-bootstrap. Defined
if $(BUILD_CONFIG) contains bootstrap-asan.
(POSTSTAGE1_CXX_EXPORT): Add $(LIBASAN_LIBS) to CXX.
(POSTSTAGE1_HOST_EXPORTS): Add $(LIBASAN_LIBS) to CC.
* configure.ac (bootstrap_target_libs): Add libsanitizer.
* Makefile.in: Regenerated.
* configure: Likewise.
config/
2012-11-17 H.J. Lu <hongjiu.lu@intel.com>
* bootstrap-asan.mk: New file.
diff --git a/Makefile.def b/Makefile.def
index 1ea63ac..8d54ad2 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -119,7 +119,7 @@ target_modules = { module= libstdc++-v3;
lib_path=src/.libs;
raw_cxx=true; };
target_modules = { module= libmudflap; lib_path=.libs; };
-target_modules = { module= libsanitizer; lib_path=.libs; };
+target_modules = { module= libsanitizer; bootstrap=true; lib_path=.libs; };
target_modules = { module= libssp; lib_path=.libs; };
target_modules = { module= newlib; };
target_modules = { module= libgcc; bootstrap=true; no_check=true; };
diff --git a/Makefile.tpl b/Makefile.tpl
index 146666a..e40e92b 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -131,6 +131,12 @@ POSTSTAGE1_LDFLAGS = @poststage1_ldflags@
# Libraries to use for stage2 and later.
POSTSTAGE1_LIBS = @poststage1_libs@
+@if gcc-bootstrap
+ifneq ($(filter bootstrap-asan,$(BUILD_CONFIG)),)
+LIBASAN_LIBS=-B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/asan/.libs
+endif
+@endif gcc-bootstrap
+
# This is the list of variables to export in the environment when
# configuring any subdirectory. It must also be exported whenever
# recursing into a build directory in case that directory's Makefile
@@ -242,6 +248,7 @@ POSTSTAGE1_CXX_EXPORT = \
-B$$r/$(HOST_SUBDIR)/prev-gcc/ -B$(build_tooldir)/bin/ -nostdinc++ \
-B$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/src/.libs \
-B$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs \
+ $(LIBASAN_LIBS) \
-I$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/include/$(TARGET_SUBDIR) \
-I$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/include \
-I$$s/libstdc++-v3/libsupc++ \
@@ -256,6 +263,7 @@ POSTSTAGE1_HOST_EXPORTS = \
$(HOST_EXPORTS) \
CC="$(STAGE_CC_WRAPPER) $$r/$(HOST_SUBDIR)/prev-gcc/xgcc$(exeext) \
-B$$r/$(HOST_SUBDIR)/prev-gcc/ -B$(build_tooldir)/bin/ \
+ $(LIBASAN_LIBS) \
$(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
CC_FOR_BUILD="$$CC"; export CC_FOR_BUILD; \
$(POSTSTAGE1_CXX_EXPORT) \
diff --git a/config/bootstrap-asan.mk b/config/bootstrap-asan.mk
new file mode 100644
index 0000000..cae203b
--- /dev/null
+++ b/config/bootstrap-asan.mk
@@ -0,0 +1,5 @@
+# This option enables -faddress-sanitizer for stage2 and stage3.
+
+STAGE2_CFLAGS += -faddress-sanitizer
+STAGE3_CFLAGS += -faddress-sanitizer
+POSTSTAGE1_LDFLAGS += -faddress-sanitizer -static-libasan
diff --git a/configure.ac b/configure.ac
index 24ea7e5..64e0387 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2433,6 +2433,11 @@ if echo " ${target_configdirs} " | grep " libgomp " > /dev/null 2>&1 ; then
bootstrap_target_libs=${bootstrap_target_libs}target-libgomp,
fi
+# If we are building libsanitizer, bootstrap it.
+if echo " ${target_configdirs} " | grep " libsanitizer " > /dev/null 2>&1 ; then
+ bootstrap_target_libs=${bootstrap_target_libs}target-libsanitizer,
+fi
+
# Determine whether gdb needs tk/tcl or not.
# Use 'maybe' since enable_gdbtk might be true even if tk isn't available
# and in that case we want gdb to be built without tk. Ugh!