From 482bd1c27dd35ee055a741692a2f6e886404eb21 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 d22b10c..70baaf9 100644 --- a/config/bootstrap-asan.mk +++ b/config/bootstrap-asan.mk @@ -5,7 +5,7 @@ export LSAN_OPTIONS="detect_leaks=0" 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 721ec73..7410205 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 esan_arch x86_64 %arm diff --git a/packaging/gcc-armv7hl.spec b/packaging/gcc-armv7hl.spec index 5f236fe..04c6b08 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 esan_arch x86_64 %arm diff --git a/packaging/gcc-armv7l.spec b/packaging/gcc-armv7l.spec index e7cd626..9644de5 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 esan_arch x86_64 %arm diff --git a/packaging/linaro-gcc.spec b/packaging/linaro-gcc.spec index ddecc73..360ab85 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 esan_arch x86_64 %arm -- 2.7.4