Helgrind (Valgrind) and OpenMP (C): avoiding false positives?

前端 未结 3 1944
北荒
北荒 2020-12-16 09:09

The documentation for the Valgrind thread error detection tool Helgrind, found here

warns that, if you use GCC to compile your OpenMP code, GCC\'s OpenMP runtime lib

3条回答
  •  既然无缘
    2020-12-16 09:56

    Sorry to put this in as an answer since it's more of a comment, but it's too long to fit in as a comment, so here goes:

    From the site you referenced.

    Runtime support library for GNU OpenMP (part of GCC), at least for GCC versions 4.2 and 4.3. The GNU OpenMP runtime library (libgomp.so) constructs its own synchronisation primitives using combinations of atomic memory instructions and the futex syscall, which causes total chaos since in Helgrind since it cannot "see" those.

    Fortunately, this can be solved using a configuration-time option (for GCC). Rebuild GCC from source, and configure using --disable-linux-futex. This makes libgomp.so use the standard POSIX threading primitives instead. Note that this was tested using GCC 4.2.3 and has not been re-tested using more recent GCC versions. We would appreciate hearing about any successes or failures with more recent versions.

    as you mentioned in your post, this has to do with libgomp.so, but that's a shared object, so I don't see how you can pass the -static flag and still use that library. Am I just misinformed?

提交回复
热议问题