Matthew Malcomson <matthew.malcom...@arm.com> writes: > This is an analogous option to --bootstrap-asan to configure. It allows > bootstrapping GCC using HWASAN. > > For the same reasons as for ASAN we have to avoid using the HWASAN > sanitizer when compiling libiberty and the lto-plugin. > > Also add a function to query whether -fsanitize=hwaddress has been > passed. > > ChangeLog: > > * configure: Regenerate. > * configure.ac: Add --bootstrap-hwasan option. > > config/ChangeLog: > > * bootstrap-hwasan.mk: New file. > > gcc/ChangeLog: > > * doc/install.texi: Document new option. > > libiberty/ChangeLog: > > * configure: Regenerate. > * configure.ac: Avoid using sanitizer. > > lto-plugin/ChangeLog: > > * Makefile.am: Avoid using sanitizer. > * Makefile.in: Regenerate.
OK, thanks. > ############### Attachment also inlined for ease of reply > ############### > > > diff --git a/config/bootstrap-hwasan.mk b/config/bootstrap-hwasan.mk > new file mode 100644 > index > 0000000000000000000000000000000000000000..4f60bed3fd6e98b47a3a38aea6eba2a7c320da25 > --- /dev/null > +++ b/config/bootstrap-hwasan.mk > @@ -0,0 +1,8 @@ > +# This option enables -fsanitize=hwaddress for stage2 and stage3. > + > +STAGE2_CFLAGS += -fsanitize=hwaddress > +STAGE3_CFLAGS += -fsanitize=hwaddress > +POSTSTAGE1_LDFLAGS += -fsanitize=hwaddress -static-libhwasan \ > + -B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/ \ > + -B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/hwasan/ \ > + -B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/hwasan/.libs > diff --git a/configure b/configure > index > a2ea1a329b69de06906315e54a49c694c9704522..b41a258c80ee9f289de534185eb364bcb5ca6ae5 > 100755 > --- a/configure > +++ b/configure > @@ -9305,7 +9305,7 @@ fi > # or bootstrap-ubsan, bootstrap it. > if echo " ${target_configdirs} " | grep " libsanitizer " > /dev/null 2>&1; > then > case "$BUILD_CONFIG" in > - *bootstrap-asan* | *bootstrap-ubsan* ) > + *bootstrap-hwasan* | *bootstrap-asan* | *bootstrap-ubsan* ) > bootstrap_target_libs=${bootstrap_target_libs}target-libsanitizer, > bootstrap_fixincludes=yes > ;; > diff --git a/configure.ac b/configure.ac > index > 44fa75f3a329ef68f6800c8e09d49a9373f731cf..944f30cfea84e9266b4322df7902b867882d4d8c > 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -2814,7 +2814,7 @@ fi > # or bootstrap-ubsan, bootstrap it. > if echo " ${target_configdirs} " | grep " libsanitizer " > /dev/null 2>&1; > then > case "$BUILD_CONFIG" in > - *bootstrap-asan* | *bootstrap-ubsan* ) > + *bootstrap-hwasan* | *bootstrap-asan* | *bootstrap-ubsan* ) > bootstrap_target_libs=${bootstrap_target_libs}target-libsanitizer, > bootstrap_fixincludes=yes > ;; > diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi > index > 60ee0a9dba17bf8f00d7c5320468ba847f08f8a0..e0f75b3d55582b5d1b8718f94e39c7d50656a926 > 100644 > --- a/gcc/doc/install.texi > +++ b/gcc/doc/install.texi > @@ -2794,6 +2794,11 @@ the build tree. > Compiles GCC itself using Address Sanitization in order to catch invalid > memory > accesses within the GCC code. > > +@item @samp{bootstrap-hwasan} > +Compiles GCC itself using HWAddress Sanitization in order to catch invalid > +memory accesses within the GCC code. This option is only available on > AArch64 > +systems that are running Linux kernel version 5.4 or later. > + > @end table > > @section Building a cross compiler > diff --git a/libiberty/configure b/libiberty/configure > index > ff93c9ee9a6fa9c6bb1938bcdfffb2d0ae8c9698..b6af9baf21204a323cad0e7b40a426c72988ba3b > 100755 > --- a/libiberty/configure > +++ b/libiberty/configure > @@ -5264,6 +5264,7 @@ fi > NOASANFLAG= > case " ${CFLAGS} " in > *\ -fsanitize=address\ *) NOASANFLAG=-fno-sanitize=address ;; > + *\ -fsanitize=hwaddress\ *) NOASANFLAG=-fno-sanitize=hwaddress ;; > esac > > > diff --git a/libiberty/configure.ac b/libiberty/configure.ac > index > 4e2599c14a89bafcb8c7e523b9ce5b3d60b8c0f6..ad952963971a31968b5d109661b9cab0aa4b95fc > 100644 > --- a/libiberty/configure.ac > +++ b/libiberty/configure.ac > @@ -240,6 +240,7 @@ AC_SUBST(PICFLAG) > NOASANFLAG= > case " ${CFLAGS} " in > *\ -fsanitize=address\ *) NOASANFLAG=-fno-sanitize=address ;; > + *\ -fsanitize=hwaddress\ *) NOASANFLAG=-fno-sanitize=hwaddress ;; > esac > AC_SUBST(NOASANFLAG) > > diff --git a/lto-plugin/Makefile.am b/lto-plugin/Makefile.am > index > 204b25f45ef2f22bb246641a2aa9f9d09719737b..8b20e1d1d87e2dda9f37763492ddf39a8022c48c > 100644 > --- a/lto-plugin/Makefile.am > +++ b/lto-plugin/Makefile.am > @@ -11,8 +11,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/../include $(DEFS) > AM_CFLAGS = @ac_lto_plugin_warn_cflags@ $(CET_HOST_FLAGS) > AM_LDFLAGS = @ac_lto_plugin_ldflags@ > AM_LIBTOOLFLAGS = --tag=disable-static > -override CFLAGS := $(filter-out -fsanitize=address,$(CFLAGS)) > -override LDFLAGS := $(filter-out -fsanitize=address,$(LDFLAGS)) > +override CFLAGS := $(filter-out -fsanitize=address > -fsanitize=hwaddress,$(CFLAGS)) > +override LDFLAGS := $(filter-out -fsanitize=address > -fsanitize=hwaddress,$(LDFLAGS)) > > libexecsub_LTLIBRARIES = liblto_plugin.la > gcc_build_dir = @gcc_build_dir@ > diff --git a/lto-plugin/Makefile.in b/lto-plugin/Makefile.in > index > 834699b439e03cd1213c4b7fe1867ff7b5f19e98..20611c6b1e6f5e381d4690e34ab7a69f2c827bb6 > 100644 > --- a/lto-plugin/Makefile.in > +++ b/lto-plugin/Makefile.in > @@ -675,8 +675,8 @@ uninstall-am: uninstall-libexecsubLTLIBRARIES > > .PRECIOUS: Makefile > > -override CFLAGS := $(filter-out -fsanitize=address,$(CFLAGS)) > -override LDFLAGS := $(filter-out -fsanitize=address,$(LDFLAGS)) > +override CFLAGS := $(filter-out -fsanitize=address > -fsanitize=hwaddress,$(CFLAGS)) > +override LDFLAGS := $(filter-out -fsanitize=address > -fsanitize=hwaddress,$(LDFLAGS)) > > all-local: $(in_gcc_libs) >