Home > OS >  GCC v12.1 warning about serial compilation
GCC v12.1 warning about serial compilation

Time:05-13

I have upgraded my whole arch linux system today. gcc was also upgraded from v11.2 to v12.1. I tried compiling some of my programs with g by the following command:

g   -O3 -DNDEBUG -Os -Ofast -Og -s -march=native -flto -funroll-all-loops -std=c  20 main.cc -o ./main

The program compiled perfectly and ran as excepted without any errors, but I got a warning:

lto-wrapper: warning: using serial compilation of 2 LTRANS jobs

But, when the same program was compiled using v11.2 it produces zero number of errors and warnings.

My Questions:

  • What is the meaning of this warning?
  • How can I fix this?
  • Is this warning occurred due to upgrading gcc version to v12.1

Here's my g configuration on my machine:

Using built-in specs.
COLLECT_GCC=g  
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=c,c  ,ada,fortran,go,lto,objc,obj-c   --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.1.0 (GCC) 

I cannot find any good resource to know more about this warning.

CodePudding user response:

Apparently that is a recent change in the -flto option. With a little bit of variation in the google search I was able to find this mail conversation:

Likewise if people just use -flto and auto-detection finds nothing:

warning: using serial compilation of N LTRANS jobs note: refer to http://.... for how to use parallel compile

[...]

That is, teach users rather than second-guessing and eventually blowing things up. IMHO only the jobserver mode is safe to automatically use.

So this is about using the -flto options correctly. I could not manage to easily get a GCC 12 on my system and thus could not try it myself, but you can try -flto=1 or -flto=auto to get rid of the warning.

Anyway it seems that this warning is rather harmless. It just tells you that GCC uses 2 threads in parallel to do the link time optimization.

The exact semantics and effects of the -flto is (together with the other optimization options) described in detail in the GCC manual. By the way you should not spam optimization options like you do in your command line. For example specifying multiple -O... options will only have the effect of the last one of them. Unless you know exactly what you are doing and have carefully read the manual, just stick to use -O3 and you will be fine.

  • Related