Skip to content

GypPathToUniqueOutput from ninja.py #37

Closed
@indutny

Description

@indutny

Original GYP puts compilation results to obj/${intPrefix} dir if they are of some specific types (which differ by platform).

I'm not sure how to fix it at this moment, but node uses this feature of GYP when linking to v8/openssl. We need to fix it somehow.

cc @refack maybe you have an idea?

Activity

refack

refack commented on Mar 21, 2017

@refack
Contributor

Do you have a tree example? On which platform?
(I assume not Windows since I was able to link node.exe on Windows)

indutny

indutny commented on Mar 21, 2017

@indutny
OwnerAuthor

Not windows, actually. https://github.com/nodejs/node/blob/940b5303bef7aee9b24214c62e4b6f182f23f82a/node.gyp#L386-L399

It is different on Mac and other Unixes. On Mac GYP puts everything into ./out/Release be it libv8_base.a or whatever, on unixes it will put .a files in obj/... folders. I assume that this is because GYP prevents name conflicts... but still, it appears to work without it at the moment.

indutny

indutny commented on Mar 21, 2017

@indutny
OwnerAuthor

The problem is that node.gyp expects the .a file to be at different location on Linux and FreeBSD.

indutny

indutny commented on Mar 22, 2017

@indutny
OwnerAuthor
indutny

indutny commented on Mar 22, 2017

@indutny
OwnerAuthor

@evmar sorry to bring you in here without asking you first, I hope this is ok.

You have reviewed that original CL for placing GYP outputs in different dirs on different platforms. May I ask you to share with us what downsides may be in placing everything in ./out/Release? I suppose it comes down to multiple-toolset, but otherwise is there anything else to consider?

indutny

indutny commented on Mar 22, 2017

@indutny
OwnerAuthor

Will placing outputs to unique paths for toolset !== 'target' be enough to mitigate this?

refack

refack commented on Mar 22, 2017

@refack
Contributor
evmar

evmar commented on Mar 22, 2017

@evmar

@nico is the gyp+mac wizard who can maybe explain this decision.

I don't really understand this node code, so this advice is vague, but:

  • I think the design of gyp is that build rules shouldn't care where static libraries are written (the actual path the library ends up at is meant to be an internal implementation detail).
  • I would think the proper place for library-specific logic would be on the library's build rule, not on the rule that depends on the library.
  • Chrome uses OpenSSL (well, BoringSSL, but that's a fork of OpenSSL) and it doesn't need this special casing. Do you know why?
indutny

indutny commented on Mar 22, 2017

@indutny
OwnerAuthor

I absolutely agree with all points here. The reason why node uses it is because addons (read shared_library) need to access OpenSSL and V8 functions. Hence, node.gyp has whole-archive linker directives. These directives will make all symbols available in the final executable, however they need the path to the static library which is placed somewhere in either product or object dir.

Anyway, the question is more about whether putting everything with toolset == 'target' in ./out/Release is a bad pattern, and if it should be avoided?

indutny

indutny commented on Mar 22, 2017

@indutny
OwnerAuthor

( @evmar thanks for coming here with answers! We appreciate it! )

evmar

evmar commented on Mar 22, 2017

@evmar

My vague recollection of the history is that we originally only worked on Linux and put the archives in the subdirectories because otherwise they'd need to be globally unique names across the project. And then for some Mac reason we needed to put the archives not in subdirectories, which meant users now must be careful to use globally unique names. So I think it'd be harmless to put them all in the top-level directory on all platforms. Just kinda ugly! But I think @nico knows better than me.

indutny

indutny commented on Mar 22, 2017

@indutny
OwnerAuthor

This does not work for projects whose output is either static or shared library, though. I suppose that ideally top-level .gyp file results may be put to ./out/Release, while others may be put to obj subfolders.

evmar

evmar commented on Mar 23, 2017

@evmar

(Just another disclaimer that I haven't worked in this area for >5 years, but...) As I recall static_library/shared_library was considered an internal build detail, and there was some other target type (maybe loadable_module?) for variants of those that were considered build output and which would get predictable paths.

indutny

indutny commented on Mar 23, 2017

@indutny
OwnerAuthor

Yeah, sounds good then. I was afraid of some unforeseen caveats that I haven't considered. Going to keep it as it is now, and land #38. Thank yoU!

6 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

      Participants

      @nico@evmar@refack@indutny

      Issue actions

        `GypPathToUniqueOutput` from `ninja.py` · Issue #37 · indutny/gyp.js