Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc 7.1.1 on Fedora 26 dumpversion now only includes major version by default

Tags:

version

gcc7

After upgrading from Fedora 25 to 26 the default gcc version is now version 7.1.1 and the output of gcc -dumpversion has changed from major.minor.patch to just major.

new output:

$ gcc -dumpversion
7

The manual states

-dumpversion

Print the compiler version (for example, 3.0, 6.3.0 or 7)—and don’t do anything else. This is the compiler version used in filesystem paths, specs, can be depending on how the compiler has been configured just a single number (major version), two numbers separated by dot (major and minor version) or three numbers separated by dots (major, minor and patchlevel version).

I have not found where to change this compiler configuration to include the three numbers configured with dots. The closest I have found is the major version only configuration:

--with-gcc-major-version-only Specifies that GCC should use only the major number rather than major.minor.patchlevel in filesystem paths.

like image 583
Jake1164 Avatar asked Jul 18 '17 13:07

Jake1164


People also ask

What version of gcc do I have Linux?

You need to use the which command to locate c compiler binary called gcc. Usually, it is installed in /usr/bin directory.

What version of gcc do I have installed?

So if you ever need to check the version of the GCC C++ compiler that you have installed on your PC, you can do it through the command prompt by typing in the single line, g++ --version, and this will return the result.

How do I know my compiler version?

Type “g++ –version” in command prompt to check whether C++ compiler is installed in your machine.

How do I find gcc compiler on Mac?

You can run brew info gcc to get path where it is installed and get exact name of the binary by listing the directory. $ brew info gcc gcc: stable 11.2. 0 (bottled), HEAD GNU compiler collection https://gcc.gnu.org/ /usr/local/Cellar/gcc/11.2.


2 Answers

I used both options together:

gcc -dumpfullversion -dumpversion

This seems to work on old and new in a uniform way:

[root@zeta ~]# gcc -dumpfullversion -dumpversion

4.4.7

[jenkins@build-el7 ~]$ gcc -dumpfullversion -dumpversion

7.2.1

like image 52
user8978657 Avatar answered Sep 20 '22 18:09

user8978657


So after some research I found the configure the version is a compile time option (if you compile the compiler from source).

I also found that there is a new gcc -dumpfullversion option that will provide the full version number, ie 7.1.1 which is what our build system expects. Small caveat is that -dumpfullversion is not supported on older versions of gcc.

So we had to change the build system to get the version via gcc -dumpversion and check if its a single digit and if so then substitute -dumpfullversion to get the full major.minor.patch gcc version.

like image 33
Jake1164 Avatar answered Sep 21 '22 18:09

Jake1164