Enable linaro-gcc bootstrap with asan config. 23/214623/1
authorMikhail Kashkarov <m.kashkarov@partner.samsung.com>
Thu, 1 Aug 2019 13:34:10 +0000 (16:34 +0300)
committerMikhail Kashkarov <m.kashkarov@partner.samsung.com>
Tue, 24 Sep 2019 18:18:55 +0000 (21:18 +0300)
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
packaging/gcc-aarch64.spec
packaging/gcc-armv7hl.spec
packaging/gcc-armv7l.spec
packaging/linaro-gcc.spec

index d22b10c..70baaf9 100644 (file)
@@ -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
index 721ec73..7410205 100644 (file)
 %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
index 5f236fe..04c6b08 100644 (file)
 %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
index e7cd626..9644de5 100644 (file)
 %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
index ddecc73..360ab85 100644 (file)
 %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