this page (from Arnim Läuger in 2005) explains that a tool chain {GHDL + gcov} can perform VHDL code coverage.
Question : Is it still working today with recent versions of GCC, GCOV and GHDL?
The following command fails
$ ghdl -a -Wc,-ftest-coverage -Wc,-fprofile-arcs tb_example.vhd
ghdl: unknown option '-Wc,-ftest-coverage' for command '-a'
My setup is as follow:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/gnat/bin/../libexec/gcc/x86_64-pc-linux-gnu/4.9.4/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../src/configure --enable-languages=ada,c,c++ --enable-dual-exceptions --enable-_cxa_atexit --enable-threads=posix --with-bugurl=URL:mailto:report#adacore.com --disable-nls --without-libiconv-prefix --disable-libstdcxx-pch --disable-libada --enable-checking=release --disable-multilib --with-mpfr=/boron.a/gnatmail/sandbox/gpl-2016/x86_64-linux/mpfr_stable/install --with-gmp=/boron.a/gnatmail/sandbox/gpl-2016/x86_64-linux/gmp_stable/install --with-mpc=/boron.a/gnatmail/sandbox/gpl-2016/x86_64-linux/mpc_stable/install --with-build-time-tools=/boron.a/gnatmail/sandbox/gpl-2016/x86_64-linux/gcc/build/buildtools/bin --prefix=/boron.a/gnatmail/sandbox/gpl-2016/x86_64-linux/gcc/pkg --build=x86_64-pc-linux-gnu
Thread model: posix
gcc version 4.9.4 20160426 (for GNAT GPL 2016 20160515) (GCC)
$ gcov -v
gcov (GCC) 4.9.4 20160426 (for GNAT GPL 2016 20160515)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
$ ghdl -v
GHDL 0.34dev (20151126) [Dunoon edition]
Compiled with GNAT Version: GPL 2016 (20160515-49)
mcode code generator
Written by Tristan Gingold.
Copyright (C) 2003 - 2015 Tristan Gingold.
GHDL is free software, covered by the GNU General Public License. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cat /proc/version
Linux version 4.4.0-34-generic (buildd#lgw01-20) (gcc version 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2.1) ) #53-Ubuntu SMP Wed Jul 27 16:06:39 UTC 2016
I installed GHDL using the Building with mcode backend procedure. Could it be the root of the evil?
Thanks for help!
Yes, current ghdl does support code coverage.
Make sure you have a recent ghdl version, but note that while ghdl suppports 3 code generation backends (LLVM, gcc and its own JIT compiler, mcode), only the gcc backend currently supports code coverage (via gcov). Specifically, the mcode version you have built will not work.
There ought to be suitable packages for Ubuntu - failing that I have build instructions somewhere for building from source on Debian Jessie which ought to serve for Ubuntu too. (I'll dig them out if need be).
ghdl --version
GHDL 0.34dev (20151126) [Dunoon edition]
Compiled with GNAT Version: 4.9.3
GCC back-end code generator
Written by Tristan Gingold.
check...
Now there are some compile time flags you need to supply...
ghdl -a --std=08 -g -fprofile-arcs -ftest-coverage myfile.vhd
ghdl -a --std=08 -g -fprofile-arcs -ftest-coverage my_TB.vhd
and for elaboration (-Wl, precedes linker options)...
ghdl -e --std=08 -Wl,-lgcov -Wl,--coverage my_tb
./my_tb
and you should have a set of .gcno,.gcda files to be post-processed with gcov (or lcov and genhtml, for prettier reports)
Also works under Vunit and with the OSVVM library.
Branch coverage does not work so well, in part because VHDL's signal assignment semantics translate into a lot of spurious branches in the generated executable.
Under VUnit, I don't use their "code coverage" experimental option.
Instead, I set the relevant flags, run the vu.main() function, catch its return, and invoke lcov as a postprocessing step. An incomplete example run.py script is as follows:
lib.add_compile_option("ghdl.flags", ["-fprofile-arcs"])
vu.set_sim_option("ghdl.flags", ["-Wl,-lgcov"])
try:
vu.main()
except SystemExit as exc:
all_ok = exc.code == 0
if all_ok:
subprocess.call(["lcov", "--capture", "--directory", ".", "--output-file", "code_coverage.info"])
subprocess.call(["genhtml", "code_coverage.info", "--output-directory", "code_html"])
Related
I was trying to activate the option -Wmismatched-tags on gcc (detect inconsistent class/struct declaration, which might happens when using forward declaration), but on Ubuntu I get
c++: error: unrecognized command line option '-Wmismatched-tags'
My gcc version:
# gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
Looking here it seems like it was integrated in gcc 4.9.0
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61339
Am I doing something wrong, or is the option actually not available anymore?
I am aware of Can GCC produce struct/class name mismatches like VS?, however the answer is 10 years old and I was hoping things had improved in the meantime.
Background: I need this in a project where we also build with clang, and where these inconsistencies are treated as error.
Looking here it seems like it was integrated in gcc 4.9.0
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61339
Actually, it doesn't. It was reported in 2014 but as OP explained in
#5th post:
I can't speak for MS, but the original warning I posted was produced
by clang. It does seem to worry about mismatched tags.
In gcc -Wmismatched-tags was introduced only in December 2019 and
became a part of GCC 10 release:
$ git describe e8f1ade269a39ea86a76a2440818e1512ed480ee
basepoints/gcc-10-5517-ge8f1ade269a
Luckily, these days we have docker and official GCC releases are
officially distributed as docker images:
$ docker search gcc
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
gcc The GNU Compiler Collection is a compiling s… 587 [OK]
(...)
so you can just do:
docker run --rm -it gcc
and either mount your source directory into the docker container or
use TRAMP integration for docker
containers or any other
preferred tool to put your code into the container and use the newest gcc inside it:
root#53d309d5d619:/# g++ --version
g++ (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root#53d309d5d619:/# g++ hello.cpp -o hello -Wmismatched-tags
I've been trying to code something using the new experimental feature "modules-ts" that will be included in c++20. I've cloned the gcc branch (found here: https://gcc.gnu.org/wiki/cxx-modules), and I'm trying to follow that tutorial (on the link) using modules-ts but an g++ error is preventing me from doing that:
g++: error: unrecognized command-line option ‘-fmodules-ts’
I tried to see the version of g++, to make sure that is not reading from another previous version. And the answer is:
g++ (GCC) 10.0.0 20191029 (experimental)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Here is the command that I'm trying to run:
g++ -fmodules-ts hello.cppm main.cpp
Modules-ts is not merged into GCC's main branch yet. You need to download GCC's source and compile it yourself, for further instructions see GCC's installation guide. Grab the source using
svn co svn://gcc.gnu.org/svn/gcc/branches/c++-modules SomeLocalDir
instead of
svn checkout svn://gcc.gnu.org/svn/gcc/trunk SomeLocalDir
and you'll get the correct version.
EDIT:
For clarification, in this answer I assumed the OP did not compile the right GCC version because there is no svn revision number inside his gcc --version.
When I trying to compile ArangoDB 3.0, I am getting this issue as below.
wget https://www.arangodb.com/repositories/Source/ArangoDB-3.0.0.tar.gz
tar -xvvf ArangoDB-3.0.0.tar.gz
ln -s ArangoDB-3.0.0 arangodb
OR
git clone https://github.com/arangodb/arangodb
cd arangodb
git checkout 3.0
git pull
I have tried both above binary for compile as below.
cd arangodb/
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
Executing cmake .. -DCMAKE_BUILD_TYPE=Release command give me following error.
-- Checking C++11 support for "regex"
CMake Error at cmake/CheckCXX11Features.cmake:129 (message):
Checking C++11 support for "regex": not supported
Call Stack (most recent call first):
cmake/CheckCXX11Features.cmake:150 (cxx11_check_feature)
CMakeLists.txt:265 (include)
-- Configuring incomplete, errors occurred!
See also "/home/ec2-user/arangodb/build/CMakeFiles/CMakeOutput.log".
OS version on AWS Linux AMI:
Linux 4.4.11-23.53.amzn1.x86_64 #1 SMP Wed Jun 1 22:22:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
GCC version:
gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Regex support was added in gcc 4.9
- #Bill-Lynch
You have two options:
Install a newer compiler.
Go through the code and replace all regexes with equivalent functions.
I am using centos 6.5 which has a cmake 2.6.
I want to upgrade to higher version (cmake 2.8 or cmake 3.0).
I have the downloaded the setup files.
When i run the file using ./configure i get the following error message
[root#dtl-sameet cmake-3.0.0]# ./configure
---------------------------------------------
CMake 3.0.0, Copyright 2000-2014 Kitware, Inc.
C compiler on this system is: gcc
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C++ compiler on this system.
Please specify one using environment variable CXX.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /home/sameet/Downloads/cmake-3.0.0/Bootstrap.cmk/cmake_bootstrap.log
I have updated the gcc to higher version and i want to keep this higher version
[root#dtl-sameet cmake-3.0.0]# gcc --version
gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[root#dtl-sameet cmake-3.0.0]# g++ --version
g++ (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The link answers the similar question but i did not wanted to install "Development Tools" as this would make gcc fall back to old version.
This link answers the similar question but i did not wanted install a package manager.
I set the environmental variable for CXX as
export CXX="/usr/bin/gcc"
It did not work.
Look into Bootstrap.cmk/cmake_bootstrap.log.
The configure script runs a number of tests. I assume that one of them failed.
You need to find out which one, what the test does and how to make it work or disable it.
You might want to update your question and hopefully someone will find out what is wrong with the cmake bootstrap on your system.
I have a Solaris sparc machine and when i build my programs, it generates 32bit code which should be 64bit. How to check the cause?
$uname -a
SunOS sol 5.10 Generic_118833-33 sun4u sparc SUNW,Sun-Fire-V240
$/usr/sfw/bin/gcc --version
gcc (GCC) 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$/usr/sfw/bin/gcc test.c
$file a.out
a.out: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, not stripped, no debugging information available
$
OSNews - SPARC Optimizations With GCC
The creation of 64-bit code requires using the -m64 flag (-m32 for 32-bit code is implied by default).
(Yes, this is different than GCC for x86_64, which defaults to -m64 unless overridden with -m32.)
You should be able to force a 64-bit build using the -m64 option.
If that fails, you can download and install a prebuilt GCC package with 64-bit SPARC support for Solaris 10 from SunFreeware.com (download, gunzip, install with pkgadd -d gcc-...-sparc-local) which will run from /usr/local/bin/gcc.