packaging: append -ldl -lpthread to ASan force options.
authorSangmin Seo <sangmin7.seo@samsung.com>
Wed, 12 Jul 2017 09:37:50 +0000 (18:37 +0900)
committerDongkyun Son <dongkyun.s@samsung.com>
Fri, 28 Jul 2023 10:41:23 +0000 (19:41 +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 d59c731..6880c64 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 54429d3..37f0f98 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 38ad36f..9297a19 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