%prep
%build
-%if 0%{?asan} || 0%{?ubsan}
+%if 0%{?asan} || 0%{?ubsan} || 0%{?hwasan}
%gcc_unforce_options
%endif
# By default this is ${gcc_install_dir}/liblto_plugin.so
target_liblto_plugin="$(%{target_arch}-gcc -print-file-name=liblto_plugin.so)"
# update baselibs.conf, overwrite LTO plugin
-sed -e "s,#PLUGIN_POSTIN#,if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi," -i %{_sourcedir}/baselibs.conf
+
+sed -e "s,#PLUGIN_POSTIN#,if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi#PLUGIN_POSTIN_SAN#," -i %{_sourcedir}/baselibs.conf
+%if 0%{?asan} || 0%{?hwasan_build}
+sed -e "s,#PLUGIN_POSTIN_SAN#,\"\n post \"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," -i %{_sourcedir}/baselibs.conf
+%else
+sed -e "s,#PLUGIN_POSTIN_SAN#,," -i %{_sourcedir}/baselibs.conf
+%endif
sed -e "s,#PLUGIN_POSTUN#,ln -sf liblto_plugin.so.0 ${target_liblto_plugin}," -i %{_sourcedir}/baselibs.conf
# Add support of gcc-unforce-options for baselibs-generated packages
%prep
%build
-%if 0%{?asan} || 0%{?ubsan}
+%if 0%{?asan} || 0%{?ubsan} || 0%{?hwasan}
%gcc_unforce_options
%endif
# By default this is ${gcc_install_dir}/liblto_plugin.so
target_liblto_plugin="$(%{target_arch}-gcc -print-file-name=liblto_plugin.so)"
# update baselibs.conf, overwrite LTO plugin
-sed -e "s,#PLUGIN_POSTIN#,if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi," -i %{_sourcedir}/baselibs.conf
+
+sed -e "s,#PLUGIN_POSTIN#,if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi#PLUGIN_POSTIN_SAN#," -i %{_sourcedir}/baselibs.conf
+%if 0%{?asan} || 0%{?hwasan_build}
+sed -e "s,#PLUGIN_POSTIN_SAN#,\"\n post \"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," -i %{_sourcedir}/baselibs.conf
+%else
+sed -e "s,#PLUGIN_POSTIN_SAN#,," -i %{_sourcedir}/baselibs.conf
+%endif
sed -e "s,#PLUGIN_POSTUN#,ln -sf liblto_plugin.so.0 ${target_liblto_plugin}," -i %{_sourcedir}/baselibs.conf
# Add support of gcc-unforce-options for baselibs-generated packages
%prep
%build
-%if 0%{?asan} || 0%{?ubsan}
+%if 0%{?asan} || 0%{?ubsan} || 0%{?hwasan}
%gcc_unforce_options
%endif
# By default this is ${gcc_install_dir}/liblto_plugin.so
target_liblto_plugin="$(%{target_arch}-gcc -print-file-name=liblto_plugin.so)"
# update baselibs.conf, overwrite LTO plugin
-sed -e "s,#PLUGIN_POSTIN#,if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi," -i %{_sourcedir}/baselibs.conf
+
+sed -e "s,#PLUGIN_POSTIN#,if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi#PLUGIN_POSTIN_SAN#," -i %{_sourcedir}/baselibs.conf
+%if 0%{?asan} || 0%{?hwasan_build}
+sed -e "s,#PLUGIN_POSTIN_SAN#,\"\n post \"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," -i %{_sourcedir}/baselibs.conf
+%else
+sed -e "s,#PLUGIN_POSTIN_SAN#,," -i %{_sourcedir}/baselibs.conf
+%endif
sed -e "s,#PLUGIN_POSTUN#,ln -sf liblto_plugin.so.0 ${target_liblto_plugin}," -i %{_sourcedir}/baselibs.conf
# Add support of gcc-unforce-options for baselibs-generated packages
%prep
%build
-%if 0%{?asan} || 0%{?ubsan}
+%if 0%{?asan} || 0%{?ubsan} || 0%{?hwasan}
%gcc_unforce_options
%endif
# By default this is ${gcc_install_dir}/liblto_plugin.so
target_liblto_plugin="$(%{target_arch}-gcc -print-file-name=liblto_plugin.so)"
# update baselibs.conf, overwrite LTO plugin
-sed -e "s,#PLUGIN_POSTIN#,if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi," -i %{_sourcedir}/baselibs.conf
+
+sed -e "s,#PLUGIN_POSTIN#,if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi#PLUGIN_POSTIN_SAN#," -i %{_sourcedir}/baselibs.conf
+%if 0%{?asan} || 0%{?hwasan_build}
+sed -e "s,#PLUGIN_POSTIN_SAN#,\"\n post \"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," -i %{_sourcedir}/baselibs.conf
+%else
+sed -e "s,#PLUGIN_POSTIN_SAN#,," -i %{_sourcedir}/baselibs.conf
+%endif
sed -e "s,#PLUGIN_POSTUN#,ln -sf liblto_plugin.so.0 ${target_liblto_plugin}," -i %{_sourcedir}/baselibs.conf
# Add support of gcc-unforce-options for baselibs-generated packages