New issue
Advanced search Search tips

Issue 836786 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug



Sign in to add a comment

gn checks for duplicate object files _after_ writing ninja files

Project Member Reported by thakis@chromium.org, Apr 25 2018

Issue description

Have a cc file listed twice in your gn file. GN produces this nice error:

ERROR at //path/to/BUILD.gn:1:1: Duplicate object file
static_library("MyLib") {
^--------------------------
The target //path/to/MyLib:MyLib
generates two object files with the same name:
  obj/path/to/MyLib:MyLib/MyLib.file.o

It could be you accidentally have a file listed twice in the
sources. Or, depending on how your toolchain maps sources to
object files, two source files with the same name in different
directories could map to the same object file.

In the latter case, either rename one of the files or move one of
the sources to a separate source_set to avoid them both being in


That's great. However, that's done _after_ writing the duplicate .o files to the ninja file (https://cs.chromium.org/chromium/src/tools/gn/ninja_binary_target_writer.cc?type=cs&sq=package:chromium&l=336 --  WriteSources() called before CheckForDuplicateObjectFiles(obj_files)), so the next time we try to build ninja then errors out with 

ninja: error: obj/path/to/MyLib.ninja:40: multiple rules generate obj/path/to/MyLib:MyLib/MyLib.file.o [-w dupbuild=err]

 
Cc: liaoyuke@chromium.org tikuta@chromium.org
Yet another case where we'd benefit from waiting until we're fully done processing the graph to actually write the files to disk.

Comment 2 by lgrey@chromium.org, Apr 26 2018

Status: Available (was: Untriaged)

Sign in to add a comment