packaging: append -ldl -lpthread to ASan force options. 96/138496/8
authorSangmin Seo <sangmin7.seo@samsung.com>
Wed, 12 Jul 2017 09:37:50 +0000 (18:37 +0900)
committerSangmin Seo <sangmin7.seo@samsung.com>
Fri, 28 Jul 2017 00:26:32 +0000 (09:26 +0900)
When building for address sanitization, some packages complain about
missing symbols due to omitted -ldl or -pthread.  This patch appends
-ldl and -lpthread to the ASan force options in order to resolve this
kind of issue.  Note that since -ldl and -lpthread are already needed
by libasan, adding them to the ASan force options should not cause any
problems.

This patch also adds -Wl,--as-needed before -ldl -lpthread in the
force options to prevent libdl or libpthread from being linked when
unnecessary.

Change-Id: Ic50059d4684e15773f56c589cfacda0bc944d955
Signed-off-by: Sangmin Seo <sangmin7.seo@samsung.com>
packaging/gcc-aarch64.spec
packaging/gcc-armv7l.spec
packaging/linaro-gcc.spec

index ef0e568..b10c27c 100644 (file)
@@ -54,7 +54,7 @@
 %define libdir %{!?cross:%{_libdir}}%{?cross:%{_prefix}/lib%{?aarch64:64}}
 %define libsubdir %{libdir}/gcc/%{target_arch}/%{version}
 
-%define asan_force_options -fsanitize-recover=address -fsanitize=address -fno-omit-frame-pointer -Wp,-U_FORTIFY_SOURCE
+%define asan_force_options -fsanitize-recover=address -fsanitize=address -fno-omit-frame-pointer -Wp,-U_FORTIFY_SOURCE -Wl,--as-needed -ldl -lpthread
 %define ubsan_force_options -fsanitize=undefined,bounds-strict,float-divide-by-zero,float-cast-overflow
 %define lsan_force_options -fsanitize=leak -fno-omit-frame-pointer -Wp,-U_FORTIFY_SOURCE
 
index 878d527..cf24112 100644 (file)
@@ -54,7 +54,7 @@
 %define libdir %{!?cross:%{_libdir}}%{?cross:%{_prefix}/lib%{?aarch64:64}}
 %define libsubdir %{libdir}/gcc/%{target_arch}/%{version}
 
-%define asan_force_options -fsanitize-recover=address -fsanitize=address -fno-omit-frame-pointer -Wp,-U_FORTIFY_SOURCE
+%define asan_force_options -fsanitize-recover=address -fsanitize=address -fno-omit-frame-pointer -Wp,-U_FORTIFY_SOURCE -Wl,--as-needed -ldl -lpthread
 %define ubsan_force_options -fsanitize=undefined,bounds-strict,float-divide-by-zero,float-cast-overflow
 %define lsan_force_options -fsanitize=leak -fno-omit-frame-pointer -Wp,-U_FORTIFY_SOURCE
 
index 5058a99..34d9221 100644 (file)
@@ -51,7 +51,7 @@
 %define libdir %{!?cross:%{_libdir}}%{?cross:%{_prefix}/lib%{?aarch64:64}}
 %define libsubdir %{libdir}/gcc/%{target_arch}/%{version}
 
-%define asan_force_options -fsanitize-recover=address -fsanitize=address -fno-omit-frame-pointer -Wp,-U_FORTIFY_SOURCE
+%define asan_force_options -fsanitize-recover=address -fsanitize=address -fno-omit-frame-pointer -Wp,-U_FORTIFY_SOURCE -Wl,--as-needed -ldl -lpthread
 %define ubsan_force_options -fsanitize=undefined,bounds-strict,float-divide-by-zero,float-cast-overflow
 %define lsan_force_options -fsanitize=leak -fno-omit-frame-pointer -Wp,-U_FORTIFY_SOURCE