%define lsan_arch x86_64 %ix86 armv7l aarch64
%define ubsan_arch x86_64 %ix86 ppc ppc64 %arm aarch64
%define cilkrts_arch x86_64 %ix86
+%define esan_arch x86_64 armv7l
%ifarch armv7l
%define ARCH armv7l
%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:handle_segv=0:log_path=/tmp/asan.log:log_exe_name=1:fast_unwind_on_fatal=1
+%define esan_force_options -fsanitize=efficiency-working-set -fno-omit-frame-pointer -Wp,-U_FORTIFY_SOURCE -Wl,--as-needed -ldl -lpthread
+%define esan_cache_force_options -fsanitize=efficiency-cache-frag -fno-omit-frame-pointer -Wp,-U_FORTIFY_SOURCE -Wl,--as-needed -ldl -lpthread
%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
+%define esan_runtime_options print_cmdline=true:log_path=/tmp/esan.log
Name: gcc-contrib%{?cross:-%{cross}}
# With generated files in src we could drop the following
Source24: lsan.supp
Source25: TSAN_OPTIONS
Source26: macros.asan
+Source27: ESAN_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 esan-force-options
+Summary: Scripts to enable automatic package sanitization
+Group: System Environment
+Requires: gcc
+Requires: libesan
+
+%description -n esan-force-options
+Scripts for ESan instrumentation
+
+%post -n esan-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 %esan_force_options
+# Add ESan-related macros
+cat >> /usr/lib/rpm/tizen_macros << EOF
+
+%%esan_force_options %{esan_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 %%esan_force_options
+EOF
+
+%preun -n esan-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 esan-cache-force-options
+Summary: Scripts to enable automatic package sanitization
+Group: System Environment
+Requires: gcc
+Requires: libesan
+
+%description -n esan-cache-force-options
+Scripts for ESan instrumentation
+
+%post -n esan-cache-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 %esan_cache_force_options
+# Add ESan-related macros
+cat >> /usr/lib/rpm/tizen_macros << EOF
+
+%%esan_cache_force_options %{esan_cache_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 %%esan_cache_force_options
+EOF
+
+%preun -n esan-cache-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 esan-runtime-env
+Summary: ESan runtime environment
+Group: Development/Libraries
+Requires: libesan
+Requires(post): smack
+
+%description -n esan-runtime-env
+ESan runtime environment
+
+%post -n esan-runtime-env
+echo "%{esan_runtime_options}" > /ESAN_OPTIONS
+chsmack -a "_" /ESAN_OPTIONS
+
+%package -n esan-build-env
+Summary: ESan build environment
+Group: Development/Libraries
+Requires: libesan
+
+%description -n esan-build-env
+ESan build environment
+
+%post -n esan-build-env
+echo "%{esan_runtime_options}" > /ESAN_OPTIONS
+echo ":process_range_access=0" >> /ESAN_OPTIONS
+chsmack -a "_" /ESAN_OPTIONS
+
%package -n tsan-runtime-env
Summary: TSan runtime environment
Group: Development/Libraries
chmod 644 %{buildroot}/TSAN_OPTIONS
%endif
+%ifarch %esan_arch
+cp %{SOURCE27} %{buildroot}
+chmod 644 %{buildroot}/ESAN_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 %esan_arch
+%files -n esan-force-options
+%defattr(-,root,root,-)
+%{_prefix}/bin/gcc-force-options
+%{_prefix}/bin/gcc-unforce-options
+%endif
+
+%ifarch %esan_arch
+%files -n esan-cache-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
%{_rpmconfigdir}/macros.ubsan
%{_rpmconfigdir}/tizen/extract-ubsan-logs
+%ifarch %esan_arch
+%files -n esan-runtime-env
+%defattr(-,root,root,-)
+/ESAN_OPTIONS
+
+%files -n esan-build-env
+%defattr(-,root,root,-)
+/ESAN_OPTIONS
+%endif
+
%files -n ubsan-runtime-env
%defattr(-,root,root,-)
%endif