From 944f05c0d1df2085f01f758b2790fccdfa3a9d25 Mon Sep 17 00:00:00 2001 From: Mikhail Kashkarov Date: Thu, 1 Aug 2019 16:34:10 +0300 Subject: [PATCH] Enable linaro-gcc bootstrap with asan config. We couldn't verify linaro-gcc bootstrap with dynmaic ASan as we don't update library pathes while running executables, so the compilation is performed with the new instrumentations and the old external runtime from the build environment is used during run. And we'll also get runtime conflicts with 2 libasan.so version inside sanitized environment, so it doesn't make sense to define 'asanbootstrap' with 'asan'. If we really do want to test dynamic ASan, we could add the following to the POSTSTAGE1_LDFLAGS: "-rpath$$r/prev-$(TARGET_SUBDIR)/libsanitizer/asan/.libs" and keep additional rpathes for final binaries or use patchelf tool. Change-Id: I8783f0395521126f8e01125e24bc40ed457bc008 --- config/bootstrap-asan.mk | 2 +- packaging/gcc-aarch64.spec | 17 +++++++++++++++++ packaging/gcc-armv7hl.spec | 17 +++++++++++++++++ packaging/gcc-armv7l.spec | 17 +++++++++++++++++ packaging/linaro-gcc.spec | 17 +++++++++++++++++ 5 files changed, 69 insertions(+), 1 deletion(-) diff --git a/config/bootstrap-asan.mk b/config/bootstrap-asan.mk index 1d377a1..e73d4c2 100644 --- a/config/bootstrap-asan.mk +++ b/config/bootstrap-asan.mk @@ -5,7 +5,7 @@ export ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1 STAGE2_CFLAGS += -fsanitize=address STAGE3_CFLAGS += -fsanitize=address -POSTSTAGE1_LDFLAGS += -fsanitize=address \ +POSTSTAGE1_LDFLAGS += -fsanitize=address -static-libasan \ -B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/ \ -B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/asan/ \ -B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/asan/.libs diff --git a/packaging/gcc-aarch64.spec b/packaging/gcc-aarch64.spec index 561e812..5e67f48 100644 --- a/packaging/gcc-aarch64.spec +++ b/packaging/gcc-aarch64.spec @@ -40,6 +40,23 @@ %define gcc_exit_on_make_finish 1 %endif +# Bootstrap build constrains for ASan config +%if 0%{?asanbootstrap} + %ifarch %arm aarch64 # or #if 0#{?qemu_user_space_build} + %{error:"'asanbootstrap' supposed to be used with i586/x86_64 arch"} + # The #error macro primitive cannot stop the build because macros are context + # free, lazily expanded whereever they are needed, not only during build. + # Use non-existing define for now to abort the build. + %abort_build + %endif + # We'll get 2 libasan runtime conflict: preloaded one and another from build dir. + %if 0%{?asan} + %{error:"'asanbootstrap' could not be used with sanitized environment."} + %{error:"Use 'asanbootstrap' without defined 'asan'"} + %abort_build + %endif +%endif + %define quadmath_arch %ix86 x86_64 ia64 %define tsan_arch x86_64 aarch64 %define asan_arch x86_64 %ix86 ppc ppc64 %sparc %arm aarch64 diff --git a/packaging/gcc-armv7hl.spec b/packaging/gcc-armv7hl.spec index 99449a5..c4df150 100644 --- a/packaging/gcc-armv7hl.spec +++ b/packaging/gcc-armv7hl.spec @@ -40,6 +40,23 @@ %define gcc_exit_on_make_finish 1 %endif +# Bootstrap build constrains for ASan config +%if 0%{?asanbootstrap} + %ifarch %arm aarch64 # or #if 0#{?qemu_user_space_build} + %{error:"'asanbootstrap' supposed to be used with i586/x86_64 arch"} + # The #error macro primitive cannot stop the build because macros are context + # free, lazily expanded whereever they are needed, not only during build. + # Use non-existing define for now to abort the build. + %abort_build + %endif + # We'll get 2 libasan runtime conflict: preloaded one and another from build dir. + %if 0%{?asan} + %{error:"'asanbootstrap' could not be used with sanitized environment."} + %{error:"Use 'asanbootstrap' without defined 'asan'"} + %abort_build + %endif +%endif + %define quadmath_arch %ix86 x86_64 ia64 %define tsan_arch x86_64 aarch64 %define asan_arch x86_64 %ix86 ppc ppc64 %sparc %arm aarch64 diff --git a/packaging/gcc-armv7l.spec b/packaging/gcc-armv7l.spec index 26c50c8..2b02abf 100644 --- a/packaging/gcc-armv7l.spec +++ b/packaging/gcc-armv7l.spec @@ -40,6 +40,23 @@ %define gcc_exit_on_make_finish 1 %endif +# Bootstrap build constrains for ASan config +%if 0%{?asanbootstrap} + %ifarch %arm aarch64 # or #if 0#{?qemu_user_space_build} + %{error:"'asanbootstrap' supposed to be used with i586/x86_64 arch"} + # The #error macro primitive cannot stop the build because macros are context + # free, lazily expanded whereever they are needed, not only during build. + # Use non-existing define for now to abort the build. + %abort_build + %endif + # We'll get 2 libasan runtime conflict: preloaded one and another from build dir. + %if 0%{?asan} + %{error:"'asanbootstrap' could not be used with sanitized environment."} + %{error:"Use 'asanbootstrap' without defined 'asan'"} + %abort_build + %endif +%endif + %define quadmath_arch %ix86 x86_64 ia64 %define tsan_arch x86_64 aarch64 %define asan_arch x86_64 %ix86 ppc ppc64 %sparc %arm aarch64 diff --git a/packaging/linaro-gcc.spec b/packaging/linaro-gcc.spec index 8fcae34..3e4664b 100644 --- a/packaging/linaro-gcc.spec +++ b/packaging/linaro-gcc.spec @@ -37,6 +37,23 @@ %define gcc_exit_on_make_finish 1 %endif +# Bootstrap build constrains for ASan config +%if 0%{?asanbootstrap} + %ifarch %arm aarch64 # or #if 0#{?qemu_user_space_build} + %{error:"'asanbootstrap' supposed to be used with i586/x86_64 arch"} + # The #error macro primitive cannot stop the build because macros are context + # free, lazily expanded whereever they are needed, not only during build. + # Use non-existing define for now to abort the build. + %abort_build + %endif + # We'll get 2 libasan runtime conflict: preloaded one and another from build dir. + %if 0%{?asan} + %{error:"'asanbootstrap' could not be used with sanitized environment."} + %{error:"Use 'asanbootstrap' without defined 'asan'"} + %abort_build + %endif +%endif + %define quadmath_arch %ix86 x86_64 ia64 %define tsan_arch x86_64 aarch64 %define asan_arch x86_64 %ix86 ppc ppc64 %sparc %arm aarch64 -- 2.7.4