New issue
Advanced search Search tips

Issue 607977 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Aug 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Remove the LTCG warnings in the GN builds

Project Member Reported by sebmarchand@chromium.org, Apr 29 2016

Issue description

We're encountering 2 kind of warnings when doing an Official GN build on Windows:
- MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
- /LTCG specified but no code generation required; remove /LTCG from the link command line to improve linker performance

We're always using the "/LTCG" linker flag for these builds, so the first problem is that some static libraries get build without it, despite the fact that most of their object have been compiled with /GL, lib.exe realizes this and restarts. It's relatively easy to fix this by adding the LTCG flag to the arflags.

The second one is caused by the fact that we're always using the "/LTCG" linker flag for the Official builds. We could probably fix this by moving this flag to the 'optimize_max' config (which enable /GL), but this also cause some problems if a static library gets compiled with this config, but the module including it doesn't. e.g. chrome_elf.dll doesn't use the 'optimize_max' config but it links against base_static.lib which requires LTCG... This results in the following warning:
[GL_PGO]E:\src\chrome\src>ninja -C out\ReleaseGN chrome_elf
ninja: Entering directory `out\ReleaseGN'
[1/1] LINK(DLL) chrome_elf.dll chrome_elf.dll.lib
base_static.lib(pe_image.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance

Ideally the solution should be "If one of the static libraries that you're using has some arflags defined, then you should pass them to your ldflags", but I'm not sure that there's a way to do this ?

We could also just try to *reduce* the number of warnings, not remove them all.
 
If we are using /GL in a haphazard way then avoiding all of these warnings is probably impossible. However the problem becomes much more tractable once we have /GL enabled almost everywhere - the answer then becomes to specify /LTCG everywhere.

Probably the solution is to always use /LTCG on official builds for the linker, and to use /LTCG for libraries that build with LTCG. That will entirely fix the library warnings, will make the linker warnings no worse, and we should then get rid of all of these warnings whenever /GL is enabled everywhere.

That's what I was planning to do. Now I'm just waiting for the fix that adds |arflags| to GN to stick before doing this.
Components: Build
Labels: Build-Tools-GN
The arflags fix landed a while ago ...
Owner: sebmarchand@chromium.org
Yep, I've used it in https://codereview.chromium.org/2018293002/diff/160001/build/config/compiler/BUILD.gn , there's still a few warnings but it's not as bad as it used to be.
Status: Fixed (was: Untriaged)

Sign in to add a comment