I would like to use coverity for static analysis, and I needed it for c++. Since my project uses Android NDK, I configured the compiler as:
cov-configure –comptype gcc –compiler ~/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc-4.6
Then I ran cov-build –dir coverity ndk-build –j8 NDK_DEBUG=1
Everything builds, but I have a warning
*[*WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.**
So I ignored the warning and ran
cov-analyze –dir coverity –all
**Coverity Static Analysis for C/C++ version 6.6.1 on Linux 2.6.38-8-server x86_64
Internal version numbers: d614fc01a4 p-eureka-push-15003.308
Looking for translation units
Error: no matching translation units.**
So is my compiler configured properly? Has anyone configured a compiler for Android NDK before?
You indicated to coverity that the compiler is ~/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc-4.6
Make sure this is the correct full path in the command (maybe replace '~'?), and that arm-linux-androideabi-gcc-4.6 is exactly what is used for compilation.
I had the same issue because Coverity expected GCC to be used, but my build used cc!
Then I set:
~/coverity-current/bin/cov-configure --compiler /usr/bin/cc --comptype gcc
It displayed:
[WARNING] A template configuration is recommended for this compiler.
Add "--template" to your command line, or use one of the
template configuration shortcut command lines below:
cov-configure --gcc # GNU C/C++ compiler (gcc/g++)
cov-configure --msvc # Microsoft C/C++ compiler (cl)
cov-configure --java # Sun Java compiler (javac)
You must remove the specific configuration before re-running with "--template".
* Configuring /usr/bin/cc as a C compiler
[WARNING] Config gcc-config-2 already exists for cc gcc gcc-4.8 as gcc and will be reused.
* Configuring /usr/bin/cc as a C++ compiler
[WARNING] Config g++-config-2 already exists for cc gcc gcc-4.8 as g++ and will be reused.
Generated coverity_config.xml at location /home/default/cov-analysis-linux64-X.X.X/config/coverity_config.xml
Successfully generated configuration for the compilers: cc gcc gcc-4.8
The cov-build command is:
../../coverity-current/bin/cov-build --dir ~/build_cov/myapp/cov-log-all-output make -C ~/build_cov/myapp
The result:
../../coverity-current/bin/cov-build --dir ~/build_cov/myapp/cov-log-all-output make -C ~/build_cov/myapp
[...]
76 C/C++ compilation units (100%) are ready for analysis
The cov-build utility completed successfully.
You have a bigger emit-db file in cov-log-all-output/c/emit/pcname/
You should configure the correct compiler for NDK:
cov-configure --comptype gcc -compiler arm-linux-androideabi-gcc --template
In coverity/build-log.txt, you should see all of the commands executed during the build (look for "EXECUTING:"). Double-check that the compiler commands match the compiler that you specified to cov-configure. You can configure more than one compiler, and it might be useful to configure a generic gcc ("cov-configure --gcc").
Keep in mind that if your ndk-build doesn't actually build anything then cov-build will give a similar message. In other words, the message doesn't always indicate a problem--it's possible that the build completed and didn't actually compile any files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With