[PATCH 1/2] configure: add support for thread sanitizer (--enable-tsan)

Matthias Maennich maennich@google.com
Tue Mar 17 23:18:15 GMT 2020


Hi!

On Mon, Mar 16, 2020 at 03:00:02PM +0000, Giuliano Procida wrote:
>On Thu, 12 Mar 2020 at 11:32, 'Matthias Maennich' via kernel-team
><kernel-team@android.com> wrote:
>>
>> Similarly to asan and ubsan, add support for tsan conditionally at
>> configure time. This allows us to track down race conditions etc.
>>
>>         * configure.ac: Add configure options for -fsanitize=thread
>
>Please verify that there's no need to add the various flags to LDFLAGS
>(or no difference if you do so) thanks to CXX anf CFLAGS.
>msan (for which there isn't support yet; it also requires Clang and

Will post a patch for msan right away :-)

>lld in particular) definitely requires its flag at link time.

Autotools generates the makefiles such that CXX or CC is used for
linking and that gets passed the CXXFLAGS / CFLAGS. Having the compiler
drive the link step allows it to translate the compile flag into the
full set of linker flags. Hence, we do not need to set any LDFLAGS.

TL;DR: we are good :-)

>
>Assuming this is the case:
>Reviewed-by: Giuliano Procida <gprocida@google.com>
>
>It's also noticeable that turning on some sanitisers affects abidiff
>output. This can't be good and we should look into it when we have
>time.

When running this in our hermetic build toolchain that appears to be not
an issue. Though I do not yet see where this happens when running with
a normal autotools based build.

Cheers,
Matthias

>
>Regards,
>Giuliano.
>
>> Signed-off-by: Matthias Maennich <maennich@google.com>
>> ---
>>  configure.ac | 12 ++++++++++++
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/configure.ac b/configure.ac
>> index ba800a72ac7a..50a50c6c8932 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -120,6 +120,12 @@ AC_ARG_ENABLE(asan,
>>               ENABLE_ASAN=$enableval,
>>               ENABLE_ASAN=no)
>>
>> +AC_ARG_ENABLE(tsan,
>> +             AS_HELP_STRING([--enable-tsan=yes|no],
>> +                            [enable the support of building with -fsanitize=thread)]),
>> +             ENABLE_TSAN=$enableval,
>> +             ENABLE_TSAN=no)
>> +
>>  AC_ARG_ENABLE(ubsan,
>>               AS_HELP_STRING([--enable-ubsan=yes|no],
>>                              [enable the support of building with -fsanitize=undefined)]),
>> @@ -614,6 +620,11 @@ if test x$ENABLE_ASAN = xyes; then
>>      CXXFLAGS="$CXXFLAGS -fsanitize=address"
>>  fi
>>
>> +if test x$ENABLE_TSAN = xyes; then
>> +    CFLAGS="$CFLAGS -fsanitize=thread"
>> +    CXXFLAGS="$CXXFLAGS -fsanitize=thread"
>> +fi
>> +
>>  if test x$ENABLE_UBSAN = xyes; then
>>      CFLAGS="$CFLAGS -fsanitize=undefined"
>>      CXXFLAGS="$CXXFLAGS -fsanitize=undefined"
>> @@ -907,6 +918,7 @@ AC_MSG_NOTICE([
>>      Enable python 3                               : ${ENABLE_PYTHON3}
>>      Enable running tests under Valgrind            : ${enable_valgrind}
>>      Enable build with -fsanitize=address          : ${ENABLE_ASAN}
>> +    Enable build with -fsanitize=thread           : ${ENABLE_TSAN}
>>      Enable build with -fsanitize=undefined        : ${ENABLE_UBSAN}
>>      Generate html apidoc                          : ${ENABLE_APIDOC}
>>      Generate html manual                          : ${ENABLE_MANUAL}
>> --
>> 2.25.1.481.gfbce0eb801-goog
>>
>> --
>> To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com.
>>


More information about the Libabigail mailing list