[ASan] Create a blacklist for ASan build 19/173419/3 accepted/tizen/base/20180413.181200 submit/tizen_base/20180412.024621
authorSlava Barinov <v.barinov@samsung.com>
Wed, 21 Mar 2018 08:52:38 +0000 (11:52 +0300)
committerDenis Khalikov <d.khalikov@partner.samsung.com>
Mon, 26 Mar 2018 05:51:04 +0000 (08:51 +0300)
If the package is added to %asan_incompatible_pkgs in project config, the macro
%gcc_unforce_options will be executed before build.

This approach can be applied to some of packages which are not intended to
build with ASan and disabling ASan flags is enough.

Change-Id: I12af731714768f3c207fa115fb78efec88ba177b
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
packaging/gcc-contrib.spec
packaging/macros.asan [new file with mode: 0644]

index ebf80c0..6ebd173 100644 (file)
@@ -66,9 +66,10 @@ Source22: macros.ubsan
 Source23: extract-ubsan-logs
 Source24: lsan.supp
 Source25: TSAN_OPTIONS
+Source26: macros.asan
 Group:         Development/Building
 Summary:       GCC related scripts
-License:       MIT 
+License:       MIT
 %{?cross:ExcludeArch: %{cross}}
 %description
 GCC related scripts
@@ -100,6 +101,10 @@ cat >> /usr/lib/rpm/tizen_macros << EOF
   %%gcc_unforce_options \\
   %%gcc_force_options %%asan_force_options -fcommon
 EOF
+
+# Add ASan's blacklist macro to tizen_macros
+cat %{_rpmconfigdir}/macros.asan >> %{_rpmconfigdir}/tizen_macros
+
 # ASan needs a whole shadow address space
 # Using ulimit can only set the value for current user so we need to set /etc/security/limits.conf directly.
 sed '/End of file/i\abuild\tsoft\tas\t-1\nabuild\thard\tas\t-1' -i /etc/security/limits.conf
@@ -410,6 +415,7 @@ chmod 644 %{buildroot}/TSAN_OPTIONS
 mkdir -p %{buildroot}/%{_rpmconfigdir}/tizen/
 install -m 0644 %{SOURCE21} %{buildroot}/
 install -m 0644 %{SOURCE22} %{buildroot}/%{_rpmconfigdir}/
+install -m 0644 %{SOURCE26} %{buildroot}/%{_rpmconfigdir}/
 install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/
 
 %files
@@ -419,6 +425,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/
 %defattr(-,root,root,-)
 %{_prefix}/bin/gcc-force-options
 %{_prefix}/bin/gcc-unforce-options
+%{_rpmconfigdir}/macros.asan
 
 %files -n ubsan-force-options
 %defattr(-,root,root,-)
diff --git a/packaging/macros.asan b/packaging/macros.asan
new file mode 100644 (file)
index 0000000..1cc4fa9
--- /dev/null
@@ -0,0 +1,17 @@
+# /etc/rpm/macros.asan
+
+# A function to blacklist packages from ASan build.
+# If package is listed in blacklist named %asan_incompatible_pkgs,
+# the %gcc_unforce_options will be applied before build
+# The blacklist can be maintained in OBS project config
+
+%__spec_build_pre \
+  %{___build_pre} \
+  %{lua:         \
+    if (nil ~= string.find(                                    \
+        " " .. rpm.expand("%asan_incompatible_pkgs") .. " ",    \
+       " " .. rpm.expand("%name") .. " "))                     \
+    then print(rpm.expand("%gcc_unforce_options"))             \
+    end           \
+   }              \
+   %{nil}