[PATCH weston 2/4] configure.ac: fix linking when using compiler sanitizers

Arnaud Vrac rawoul at gmail.com
Sat Aug 5 11:58:59 UTC 2017


The GCC address sanitizer overrides dlopen and dlclose, so the configure
test does not detect libdl as a needed dependency for linking. It is
still needed though, as dlsym is not exported by the sanitizer. The
result is that linking fails in the end.

Fix this by checking for dlsym instead of dlopen.

This can be reproduced by configuring the build with:
CFLAGS="-fsanitize=address -fsanitize=undefined"
LDFLAGS="-fsanitize=address -fsanitize=undefined"

Signed-off-by: Arnaud Vrac <rawoul at gmail.com>
---
 Makefile.am  | 4 ++--
 configure.ac | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index e9679e68..58a5c596 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -74,7 +74,7 @@ libweston_ at LIBWESTON_MAJOR@_la_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON
 libweston_ at LIBWESTON_MAJOR@_la_CFLAGS = $(AM_CFLAGS) \
 	$(COMPOSITOR_CFLAGS) $(EGL_CFLAGS) $(LIBUNWIND_CFLAGS) $(LIBDRM_CFLAGS)
 libweston_ at LIBWESTON_MAJOR@_la_LIBADD = $(COMPOSITOR_LIBS) $(LIBUNWIND_LIBS) \
-	$(DLOPEN_LIBS) -lm $(CLOCK_GETTIME_LIBS) \
+	$(DL_LIBS) -lm $(CLOCK_GETTIME_LIBS) \
 	$(LIBINPUT_BACKEND_LIBS) libshared.la
 libweston_ at LIBWESTON_MAJOR@_la_LDFLAGS = -version-info $(LT_VERSION_INFO)
 
@@ -194,7 +194,7 @@ weston_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON 		\
 weston_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS) $(LIBUNWIND_CFLAGS)
 weston_LDADD = libshared.la libweston- at LIBWESTON_MAJOR@.la \
 	$(COMPOSITOR_LIBS) $(LIBUNWIND_LIBS) \
-	$(DLOPEN_LIBS) $(LIBINPUT_BACKEND_LIBS) \
+	$(DL_LIBS) $(LIBINPUT_BACKEND_LIBS) \
 	$(CLOCK_GETRES_LIBS) \
 	-lm
 
diff --git a/configure.ac b/configure.ac
index 61d7f37b..5179dfed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -86,7 +86,8 @@ AC_ARG_VAR([WESTON_SHELL_CLIENT],
 
 PKG_PROG_PKG_CONFIG()
 
-WESTON_SEARCH_LIBS([DLOPEN], [dl], [dlopen])
+# Check for dlsym instead of dlopen because ASAN hijacks the latter
+WESTON_SEARCH_LIBS([DL], [dl], [dlsym])
 
 # In old glibc versions (< 2.17) clock_gettime() and clock_getres() are in librt
 WESTON_SEARCH_LIBS([CLOCK_GETTIME], [rt], [clock_gettime])
-- 
2.13.0



More information about the wayland-devel mailing list