Check gcc or g++ Compiler Build Configuration Options

Check gcc or g++ Compiler Build Configuration Options

When working with different toolchain installations, understanding how the compiler itself was built can be useful for debugging, portability checks, and feature awareness. The build configuration reveals what languages are enabled, which prefixes are used, supported targets, and many internal build options. This tutorial explains how to check gcc or g++ compiler build configuration options.

Here is how gcc or g++ build configuration can be inspected:

gcc -v 2>&1 | grep 'Configured with' | sed 's/ --/\n--/g'
g++ -v 2>&1 | grep 'Configured with' | sed 's/ --/\n--/g'
  • -v - enables verbose mode, printing internal build and execution details of the compiler.
  • 2>&1 - merges standard error output with standard output so that configuration details become visible in the pipeline.
  • grep 'Configured with' - filters the output to isolate the section where it shows original build configuration options.
  • sed 's/ --/\n--/g' - reformats the long single-line configuration string into a readable multi-line format by placing each -- option on a new line.

A typical result may look like:

Configured with: ../src/configure -v
--with-pkgversion='Ubuntu 11.4.0-1ubuntu1~22.04.3'
--with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2
--prefix=/usr
--with-gcc-major-version-only
--program-suffix=-11
--program-prefix=x86_64-linux-gnu-
--enable-shared
...

Leave a Comment

Cancel reply

Your email address will not be published.