The Coverity Scan Build Tool fails to compile any C file that includes <stdlib.h>
on Ubuntu 18.04 when _GNU_SOURCE
is defined:
$ cat > main.c
#include <stdlib.h>
int main() {
}
$
$ gcc -D_GNU_SOURCE=1 -o main main.c
$
$ /opt/cov-analysis/bin/cov-build --dir cov-int gcc -D_GNU_SOURCE=1 -o main main.c
Coverity Build Capture (64-bit) version 2017.07 on Linux 4.15.0-20-generic x86_64
...
[WARNING] Emitted 0 C/C++ compilation units (0%) successfully
...
$
The same build works perfectly on Ubuntu 16.04 or without _GNU_SOURCE
defined:
$ /volatile/local/cov-analysis/bin/cov-build --dir cov-int gcc -o main main.c
Coverity Build Capture (64-bit) version 2017.07 on Linux 4.15.0-20-generic x86_64
...
Emitted 1 C/C++ compilation units (100%) successfully
...
$
How to get Coverity Scan to build C sources with _GNU_SOURCE
defined on Ubuntu 18.04?
For those interested file cov-int/build-log.txt
can be found here:
https://gist.github.com/DimitriPapadopoulos/0dcd9018eed26401cc6095087d9cc1d5
_Float32
,_Float32x
,_Float64
,_Float64x
, and_Float128
types. Before that happens, you can paper over the issues by defining them as macros: add-D_Float32=float -D_Float64=double -D_Float32x=double -D_Float64x="long double" -D_Float128="long double"
to the gcc command line. Do note that none of the_Float128
-using functions will work with this hack, though.Coverity
,_Float128
,_Float32
,_Float64
,_Float32x
,_Float64x
, you will ll find this page, where the suggested "fix" is basically the same as my above macro suggestion, just in an external header file to be included before any other files./include/x86_64-linux-gnu/bits/floatn.h
which containstypedef double _Float64;
but thanks for the general idea and the link to thesssd
developers' list._GNU_SOURCE
but unfortunately it is required by calls to memmem() and strcasestr() in our code base.