Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Issue 177043010: Introduce the 'link_dependency' attribute that removes the targets having this (Closed)

Created:
6 years, 9 months ago by Alexander Potapenko
Modified:
6 years, 9 months ago
CC:
gyp-developer_googlegroups.com
Visibility:
Public.

Description

Introduce the 'link_dependency' attribute that removes the targets having this attribute from the 'none' targets' dependencies. The intention behind this change is to let the users have static_library or shared_library targets on which _every_ other executable/shared_library target must depend, without introducing excessive dependencies on the former ones from the 'none' metatargets (such excessive dependencies may trigger generator bugs like https://code.google.com/p/gyp/issues/detail?id=409). GYP r1860

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+87 lines, -0 lines) Patch
M pylib/gyp/input.py View 2 chunks +18 lines, -0 lines 0 comments Download
A test/link-dependency/gyptest-link-dependency.py View 1 2 1 chunk +21 lines, -0 lines 0 comments Download
A test/link-dependency/main.c View 1 1 chunk +7 lines, -0 lines 0 comments Download
A test/link-dependency/mymalloc.c View 1 1 chunk +4 lines, -0 lines 0 comments Download
A test/link-dependency/test.gyp View 1 1 chunk +37 lines, -0 lines 0 comments Download

Messages

Total messages: 15 (0 generated)
Alexander Potapenko
Hi Mark, Brad, this is another shot at https://code.google.com/p/gyp/issues/detail?id=380, because the current solution triggers something ...
6 years, 9 months ago (2014-02-27 11:40:08 UTC) #1
Mark Mentovai
Why this instead of fixing the bug in the ninja generator? If the ninja generator ...
6 years, 9 months ago (2014-02-27 16:48:30 UTC) #2
Alexander Potapenko
On 2014/02/27 16:48:30, Mark Mentovai wrote: > Why this instead of fixing the bug in ...
6 years, 9 months ago (2014-02-27 17:06:43 UTC) #3
Mark Mentovai
The hypothesis on bug 317670 is a little speculative. I’ll put this on ice ’til ...
6 years, 9 months ago (2014-02-27 17:13:24 UTC) #4
Alexander Potapenko
On 2014/02/27 17:13:24, Mark Mentovai wrote: > The hypothesis on bug 317670 is a little ...
6 years, 9 months ago (2014-03-04 12:14:33 UTC) #5
Mark Mentovai
OK. In that case, can you write a test for the new link_dependency behavior?
6 years, 9 months ago (2014-03-04 14:02:20 UTC) #6
Alexander Potapenko
On 2014/03/04 14:02:20, Mark Mentovai wrote: > OK. In that case, can you write a ...
6 years, 9 months ago (2014-03-04 14:55:27 UTC) #7
Mark Mentovai
LGTM
6 years, 9 months ago (2014-03-04 15:00:10 UTC) #8
Alexander Potapenko
On 2014/03/04 15:00:10, Mark Mentovai wrote: > LGTM Can you please land this CL when ...
6 years, 9 months ago (2014-03-04 15:19:53 UTC) #9
Mark Mentovai
Sure. I committed this as GYP r1860.
6 years, 9 months ago (2014-03-04 15:25:24 UTC) #10
Nico
It looks like this broke tests on various bots: http://build.chromium.org/f/client/gyp/
6 years, 9 months ago (2014-03-07 22:36:09 UTC) #11
Nico
On 2014/03/07 22:36:09, Nico wrote: > It looks like this broke tests on various bots: ...
6 years, 9 months ago (2014-03-10 17:35:57 UTC) #12
Alexander Potapenko
On 2014/03/10 17:35:57, Nico wrote: > On 2014/03/07 22:36:09, Nico wrote: > > It looks ...
6 years, 9 months ago (2014-03-11 09:10:13 UTC) #13
Nico
On 2014/03/11 09:10:13, Alexander Potapenko wrote: > On 2014/03/10 17:35:57, Nico wrote: > > On ...
6 years, 9 months ago (2014-03-11 16:33:18 UTC) #14
Alexander Potapenko
6 years, 9 months ago (2014-03-11 17:21:09 UTC) #15
Message was sent while issue was closed.
First GYP generates a CMakeLists.txt file which contains the following targets:
 'malloc' - for libmalloc.so
 'main_initial' - for the binary called 'main' depending on libmalloc.so
 'main' - for the meta-target depending on main_initial (and correctly not
depending on libmalloc.so because we've set the link_dependency attribute)

The patch in question isn't generator-specific, that's why it works for other
output formats, and even produces the correct CMakeLists.txt file.
But then CMake generates a build.ninja file for this config, and the presence of
a target called 'main' and the binary called 'main' blows CMake's mind - it just
tries to create two targets with a similar name.

I suspect this is a problem with CMake's Ninja generator being a bit too
straightforward.
GYP's Ninja generator is smart enough to not generate the phony target for the
dummy meta-target if it doesn't have other dependencies, but that's not the case
with CMake.
Ninja stops reporting the error if I remove the phony target.

This situation (as well as https://code.google.com/p/gyp/issues/detail?id=409)
happens because GYP allows users (e.g. Chrome) to have a binary target foo that
produces a binary bar, while there's another target named bar. Various generator
under various circumstances (e.g. when other dependencies are added) may create
rules named 'bar' for both targets.
Because doing so isn't explicitly prohibited, each generator will have to handle
this situation on their own (e.g. mangle the names for phony targets
differently).

Because my patch neither adds the restriction to GYP nor fixes the existing
problems in the CMake generator, but just works around some common case where
the error is possible in the non-CMake land, I don't think we should run the
test under CMake.

Powered by Google App Engine
This is Rietveld 408576698