%define ubsan_force_options -fsanitize=undefined,bounds-strict,float-divide-by-zero,float-cast-overflow
%define lsan_force_options -fsanitize=leak -marm -Wa,-mimplicit-it=arm -fno-omit-frame-pointer -Wp,-U_FORTIFY_SOURCE -Wl,--as-needed -ldl -lpthread
%define isan_force_options -fsanitize=unsigned-integer-overflow
-
+%define tsan_force_options -fsanitize=thread -fno-omit-frame-pointer -Wp,-U_FORTIFY_SOURCE -Wl,--as-needed -ldl -lpthread
%define asan_runtime_options halt_on_error=false:start_deactivated=true:print_cmdline=true:quarantine_size_mb=1:detect_leaks=0:log_path=/tmp/asan.log:log_exe_name=1
%define ubsan_runtime_options print_cmdline=true:log_path=/tmp/ubsan.log
%define lsan_runtime_options print_cmdline=true:detect_leaks=1:log_path=/tmp/lsan.log:log_exe_name=1:fast_unwind_on_malloc=false:malloc_context_size=5:suppressions=/lsan.supp:print_suppressions=false
+%define tsan_runtime_options print_cmdline=true:log_path=/tmp/tsan.log:detect_deadlocks=1:second_deadlock_stack=1
Name: gcc-contrib%{?cross:-%{cross}}
# With generated files in src we could drop the following
Source22: macros.ubsan
Source23: extract-ubsan-logs
Source24: lsan.supp
+Source25: TSAN_OPTIONS
Group: Development/Building
Summary: GCC related scripts
License: MIT
/usr/bin/gcc-unforce-options
[ -d /emul/ ] && chmod a-w /emul/usr/bin/
+%package -n tsan-force-options
+Summary: Scripts to enable automatic package sanitization
+Group: System Environment
+Requires: gcc
+Requires: libtsan
+
+%description -n tsan-force-options
+Scripts for TSan instrumentation
+
+%post -n tsan-force-options
+# Change mode to allow all users to run gcc-force/unforce-options
+chmod a+w /usr/bin
+chmod a+w %{libsubdir}
+[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-*/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w
+/usr/bin/gcc-force-options %tsan_force_options
+# Add TSan-related macros
+cat >> /usr/lib/rpm/tizen_macros << EOF
+
+%%tsan_force_options %{tsan_force_options}
+%%gcc_unforce_options /usr/bin/gcc-unforce-options
+%%gcc_force_options /usr/bin/gcc-force-options
+%%gcc_force_default_options %%gcc_force_options %%tsan_force_options
+EOF
+
+%preun -n tsan-force-options
+# Restore read-only mode
+chmod a-w /usr/bin
+chmod a-w %{libsubdir}
+[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-*/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a-w
+/usr/bin/gcc-unforce-options
+[ -d /emul/ ] && chmod a-w /emul/usr/bin/
+
+%package -n tsan-runtime-env
+Summary: TSan runtime environment
+Group: Development/Libraries
+Requires: libtsan
+Requires(post): smack
+
+%description -n tsan-runtime-env
+TSan runtime environment
+
+%post -n tsan-runtime-env
+echo "%{tsan_runtime_options}" > /TSAN_OPTIONS
+chsmack -a "_" /TSAN_OPTIONS
+
%package -n asan-build-env
Summary: Asan build environment
Group: Development/Libraries
chmod 644 %{buildroot}/lsan.supp
%endif
+%ifarch %tsan_arch
+cp %{SOURCE25} %{buildroot}
+chmod 644 %{buildroot}/TSAN_OPTIONS
+%endif
+
mkdir -p %{buildroot}/%{_rpmconfigdir}/tizen/
install -m 0644 %{SOURCE21} %{buildroot}/
install -m 0644 %{SOURCE22} %{buildroot}/%{_rpmconfigdir}/
%{_prefix}/bin/gcc-unforce-options
%endif
+%ifarch %tsan_arch
+%files -n tsan-force-options
+%defattr(-,root,root,-)
+%{_prefix}/bin/gcc-force-options
+%{_prefix}/bin/gcc-unforce-options
+%endif
+
%files -n asan-build-env
%defattr(-,root,root,-)
/ASAN_OPTIONS
/lsan.supp
%endif
+%ifarch %tsan_arch
+%files -n tsan-runtime-env
+%defattr(-,root,root,-)
+/TSAN_OPTIONS
+%endif
+
%ifarch %ubsan_arch
%files -n ubsan-build-env
%defattr(-,root,root,-)