[pulseaudio-discuss] `LDFLAGS` are not passed down preventing usage of AddressSanitizer (ASan)

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Fri May 15 02:42:40 PDT 2015


On Sat, 2015-05-02 at 22:25 +0200, Paul Menzel wrote:
> Dear PulseAudio folks,
> 
> 
> my goal is to build PulseAudio with the “fast memory error detector”
> AddressSanitizer (ASan) [1].
> 
>         $ CFLAGS="-O1 -g -fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-fsanitize=address" ./autogen.sh
>         $ CFLAGS="-O1 -g -fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-fsanitize=address" make V=1
>         […]
>         $ cd src/
>         $ $ gcc -std=gnu99 -shared  -fPIC -DPIC  modules/.libs/module_console_kit_la-module-console-kit.o   -Wl,-rpath -Wl,/src/pulseaudio/src/.libs -Wl,-rpath -Wl,/usr/local/lib/pulseaudio ./.libs/libpulsecore-6.0.so ./.libs/libpulsecommon-6.0.so ./.libs/libpulse.so -ldbus-1 -lcap -lpthread -lrt -ldl -lm  -pthread -O1 -Wl,-z -Wl,nodelete -Wl,--no-undefined   -pthread -Wl,-soname -Wl,module-console-kit.so -o .libs/module-console-kit.so
>         modules/.libs/module_console_kit_la-module-console-kit.o: In function `add_session':
>         /src/pulseaudio/src/modules/module-console-kit.c:64: undefined reference to `__asan_option_detect_stack_use_after_return'
>         /src/pulseaudio/src/modules/module-console-kit.c:64: undefined reference to `__asan_stack_malloc_2'
>         /src/pulseaudio/src/modules/module-console-kit.c:73: undefined reference to `__asan_report_load4'
>         /src/pulseaudio/src/modules/module-console-kit.c:83: undefined reference to `__asan_report_load4'
>         /src/pulseaudio/src/modules/module-console-kit.c:103: undefined reference to `__asan_report_store4'
>         /src/pulseaudio/src/modules/module-console-kit.c:106: undefined reference to `__asan_report_load4'
>         /src/pulseaudio/src/modules/module-console-kit.c:110: undefined reference to `__asan_report_load4'
>         /src/pulseaudio/src/modules/module-console-kit.c:110: undefined reference to `__asan_report_store4'
>         /src/pulseaudio/src/modules/module-console-kit.c:113: undefined reference to `__asan_report_load4'
>         /src/pulseaudio/src/modules/module-console-kit.c:114: undefined reference to `__asan_report_load4'
>         /src/pulseaudio/src/modules/module-console-kit.c:119: undefined reference to `__asan_report_load4'
>         /src/pulseaudio/src/modules/module-console-kit.c:119: undefined reference to `__asan_report_load4'
> 
> So it looks like `LDFLAGS` has gone missing here. Adding
> `-fsanitize=address` manually results in successful linking.
> 
>         $ gcc -std=gnu99 -shared  -fsanitize=address -fPIC -DPIC  modules/.libs/module_console_kit_la-module-console-kit.o   -Wl,-rpath -Wl,/src/pulseaudio/src/.libs -Wl,-rpath -Wl,/usr/local/lib/pulseaudio ./.libs/libpulsecore-6.0.so ./.libs/libpulsecommon-6.0.so ./.libs/libpulse.so -ldbus-1 -lcap -lpthread -lrt -ldl -lm  -pthread -O1 -Wl,-z -Wl,nodelete -Wl,--no-undefined   -pthread -Wl,-soname -Wl,module-console-kit.so -o .libs/module-console-kit.so
>         $ ls .libs/module-console-kit.so 
>         .libs/module-console-kit.so
> 
> Am I using the build system incorrectly or is this a bug?

I'm not sure, but I would guess that it is a bug. My understanding is
that when configure is run, CFLAGS and LDFLAGS should be picked up from
the environment. You set the same variables to the same values also when
running make, which is redundant, but of course doing so shouldn't be
harmful either.

As a workaround, you could try setting the variables as make parameters
instead of as environment variables:

make CFLAGS="..." LDFLAGS="..."

-- 
Tanu



More information about the pulseaudio-discuss mailing list