Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V8 gyp scaffolding responsibility handoff #411

Closed
refack opened this issue Nov 6, 2017 · 34 comments
Closed

V8 gyp scaffolding responsibility handoff #411

refack opened this issue Nov 6, 2017 · 34 comments

Comments

@refack
Copy link

refack commented Nov 6, 2017

Refs: nodejs/CTC#76 (comment)
Refs: nodejs/CTC#2 (comment)

As per The Plan

... the legacy GYP config will be removed from V8’s repository, but stays in node/deps/v8. Keeping it in sync with GN build config becomes Node.js’ responsibility ...

AFAICT V8 has already stopped CI testing the .gyp scaffolding, and are planning to remove the .gyp files by the end of the year.

  1. Should we designate an "owner" for those files?
  2. Should we keep upstreaming fixes meanwhile (deps: update V8 to 6.2.414.44 node#16848 (comment))?

/CC @nodejs/v8 @nodejs/gyp @nodejs/build @targos @hashseed

@fhinkel
Copy link
Member

fhinkel commented Nov 7, 2017

Our bot is still running the regular Node make with gyp just like official Node.

@hashseed
Copy link
Member

hashseed commented Nov 7, 2017

Precisely. We still test Node with gyp. We have plans to change this, and will notify once we have something usable.

@refack
Copy link
Author

refack commented Nov 7, 2017

Our bot is still running the regular Node make with gyp just like official Node.

Obviously any CI coverage provided by V8 is greatly appreciated!
AFAICT there seems to be coverage missing - ARM was broken for a while, and Windows wasn't covered (maybe just building with MSBuild vs. ninja? While we use MSBuild and both VS2015 and VS2017).

IMHO the deprecation of the gyp scaffolding, and the pending removal is starting to be felt by node, and I'm just saying we should be ready. This way we won't need to scramble last minute to smooth over build problems when we want to backport fixes (nodejs/node#16848 (comment)).

Another point is that ATM reviewing these patches is cumbersome, since they can only land together with V8 backports or version bumps, see nodejs/node#16848 (comment)

@refack
Copy link
Author

refack commented Dec 6, 2017

To reiterate, we already have knowledge and time investment in maintaining GYP (the tool), so taking ownership of the tool and the .gyp files is not too far fetched.

@seishun
Copy link

seishun commented Jan 5, 2018

@hashseed It's 2018, any news?

@hashseed
Copy link
Member

hashseed commented Jan 5, 2018

In the meantime I created a wrapper script as planned to create a libv8_monolith.a static library that can be used to link node instead of libv8_base.a. I haven't created a PR on the Node.js side yet to make things work smoothly.

To build node without using V8's gyp configs, perform following steps:

  1. check out branch vee-eight-lkgr from https://github.com/v8/node
  2. apply following patch
diff --git a/common.gypi b/common.gypi
index ba44178169..2e16bacb2b 100644
--- a/common.gypi
+++ b/common.gypi
@@ -48,7 +48,7 @@
         'V8_BASE': '<(PRODUCT_DIR)/obj/deps/v8/src/libv8_base.a',
        }, {
          'OBJ_DIR%': '<(PRODUCT_DIR)/obj.target',
-         'V8_BASE%': '<(PRODUCT_DIR)/obj.target/deps/v8/src/libv8_base.a',
+         'V8_BASE%': '<(PRODUCT_DIR)/obj.target/v8_monolith/geni/gn/obj/libv8_monolith.a',
       }],
       ['OS == "win"', {
         'os_posix': 0,
diff --git a/node.gypi b/node.gypi
index 718ef0c9e7..e88bc0520b 100644
--- a/node.gypi
+++ b/node.gypi
@@ -17,7 +17,7 @@
     }],
     [ 'node_use_bundled_v8=="true"', {
       'dependencies': [
-        'deps/v8/src/v8.gyp:v8',
+        'deps/v8/src/v8.gyp:v8_monolith',
         'deps/v8/src/v8.gyp:v8_libplatform'
       ],
     }],
  1. chdir into the node checkout
  2. run deps/v8/tools/node/fetch_deps.py deps/v8 force to fetch the necessary dependencies.
  3. run ./configure && make -j 4 node. This uses deps/v8/tools/node/build_gn.py to build out/Release/obj.target/deps/v8/src/libv8_monolith.a to link into the final executable.

I only tested this with a static build for x64 linux. Once that's usable and streamlined I'll work on a few more build configurations.

@seishun
Copy link

seishun commented Jan 5, 2018

Is there any difference between v8 and v8_monolith other than the way it's built?

@hashseed
Copy link
Member

hashseed commented Jan 5, 2018

Not really. Except that v8 is a collection of files and v8_monolith just one.

@seishun
Copy link

seishun commented Jan 5, 2018

run deps/v8/tools/node/fetch_deps.py deps/v8 to fetch the necessary dependencies.

The file deps/v8/tools/node/fetch_deps.py does not exist.

@hashseed
Copy link
Member

hashseed commented Jan 5, 2018

Did you check out from github.com/v8/node? I landed it in the last few weeks so it's not yet in node master.

@seishun
Copy link

seishun commented Jan 5, 2018

@hashseed
Copy link
Member

hashseed commented Jan 5, 2018

You are right. Turns out anything called node is ignored by git due to Node's root .gitignore. So when I updated our fork's V8 via script, the whole folder was not added.

I fixed that in our node fork here. I'll upstream that soonish. Thanks for making me aware!

In the meantime I also push a new version of V8 to our fork, with the node folder.

@seishun
Copy link

seishun commented Jan 5, 2018

@hashseed
Copy link
Member

hashseed commented Jan 5, 2018

Ugh. Yeah that's a detail I forgot. We wanted to get this landed first and set up the infra changes before enabling it. Just removing pass and uncommenting the function call should do the trick.

@seishun
Copy link

seishun commented Jan 5, 2018

It doesn't seem to work. Here's the output:

seishun@ns396737:~/v8-node$ deps/v8/tools/node/fetch_deps.py deps/v8
Using depot tools in /home/seishun/v8-node/deps/v8/_depot_tools
Initializing temporary git repository in v8.
Initialized empty Git repository in /home/seishun/v8-node/deps/v8/.git/
[master (root-commit) ede811c] init
Fetching dependencies.
Syncing projects: 100% (23/23), done.                                   
Traceback (most recent call last):
  File "/home/seishun/v8-node/deps/v8/_depot_tools/gclient.py", line 2679, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/home/seishun/v8-node/deps/v8/_depot_tools/gclient.py", line 2665, in main
    return dispatcher.execute(OptionParser(), argv)
  File "/home/seishun/v8-node/deps/v8/_depot_tools/subcommand.py", line 252, in execute
    return command(parser, args[1:])
  File "/home/seishun/v8-node/deps/v8/_depot_tools/gclient.py", line 2420, in CMDsync
    ret = client.RunOnDeps('update', args)
  File "/home/seishun/v8-node/deps/v8/_depot_tools/gclient.py", line 1510, in RunOnDeps
    self.RunHooksRecursively(self._options, pm)
  File "/home/seishun/v8-node/deps/v8/_depot_tools/gclient.py", line 1033, in RunHooksRecursively
    hook.run(self.root.root_dir)
  File "/home/seishun/v8-node/deps/v8/_depot_tools/gclient.py", line 219, in run
    cmd, cwd=cwd, always=self._verbose)
  File "/home/seishun/v8-node/deps/v8/_depot_tools/gclient_utils.py", line 314, in CheckCallAndFilterAndHeader
    return CheckCallAndFilter(args, **kwargs)
  File "/home/seishun/v8-node/deps/v8/_depot_tools/gclient_utils.py", line 509, in CheckCallAndFilter
    **kwargs)
  File "/home/seishun/v8-node/deps/v8/_depot_tools/subprocess2.py", line 262, in __init__
    % (str(e), kwargs.get('cwd'), args[0]))
OSError: Execution failed with error: [Errno 2] No such file or directory.
Check that . or download_from_google_storage exist and have execution permission.
Uninitializing temporary git repository
>> Cleaning up /home/seishun/v8-node/deps/v8/.git
Traceback (most recent call last):
  File "deps/v8/tools/node/fetch_deps.py", line 90, in <module>
    Main(sys.argv[1])
  File "deps/v8/tools/node/fetch_deps.py", line 86, in Main
    FetchDeps(v8_path, depot_tools)
  File "deps/v8/tools/node/fetch_deps.py", line 70, in FetchDeps
    cwd=os.path.join(v8_path, os.path.pardir))
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/seishun/v8-node/deps/v8/_depot_tools/gclient', 'sync', '--spec', "solutions = [{'managed': False, 'custom_vars': {'build_for_node': True}, 'url': 'https://chromium.googlesource.com/v8/v8.git', 'custom_deps': {'v8/third_party/android_tools': None, 'v8/test/wasm-js': None, 'v8/test/benchmarks/data': None, 'v8/test/mozilla/data': None, 'v8/third_party/colorama/src': None, 'v8/testing/gmock': None, 'v8/third_party/markupsafe': None, 'v8/test/test262/data': None, 'v8/testing/gtest': None, 'v8/third_party/catapult': None, 'v8/third_party/jinja2': None, 'v8/test/test262/harness': None, 'v8/tools/swarming_client': None, 'v8/tools/luci-go': None, 'v8/base/trace_event/common': None, 'v8/third_party/instrumented_libraries': None, 'v8/tools/gyp': None}, 'deps_file': 'DEPS', 'name': 'v8'}]"]' returned non-zero exit status 1

@hashseed
Copy link
Member

hashseed commented Jan 5, 2018

Hm yeah something seems to be missing. I'll look into it next week. Thanks for the feedback!

@hashseed
Copy link
Member

hashseed commented Jan 5, 2018

I figured it out. gclient needs depot_tools to be included in PATH to work. I fixed the script and am pushing the fix to v8/node/vee-eight-lkgr.

Sorry about all the trouble. I'm testing this again on a clean machine to make sure.

@hashseed
Copy link
Member

hashseed commented Jan 5, 2018

Seems to work for me now. I also changed the fetch_deps.py script to accept a second argument to skip the patching.
deps/v8/tools/node/fetch_deps.py deps/v8 force should work.

@seishun
Copy link

seishun commented Jan 6, 2018

There's a different error now:

seishun@ns396737:~/v8-node$ deps/v8/tools/node/fetch_deps.py deps/v8 force
Checking out depot_tools.
Cloning into '/home/seishun/v8-node/deps/v8/_depot_tools'...
remote: Sending approximately 29.77 MiB ...
remote: Total 25020 (delta 16153), reused 25020 (delta 16153)
Receiving objects: 100% (25020/25020), 29.77 MiB | 23.36 MiB/s, done.
Resolving deltas: 100% (16153/16153), done.
Checking connectivity... done.
Using depot tools in /home/seishun/v8-node/deps/v8/_depot_tools
Initializing temporary git repository in v8.
Initialized empty Git repository in /home/seishun/v8-node/deps/v8/.git/
[master (root-commit) 70c7515] init
Fetching dependencies.
Bootstrapping cipd client for linux-amd64 from https://chrome-infra-packages.appspot.com/client?platform=linux-amd64&version=git_revision:2288f0cb47eea8b5430882867099586afcee2368...
Syncing projects: 100% (23/23), done.                                   
Running hooks:  95% (22/23) regyp_if_needed     
________ running '/usr/bin/python v8/gypfiles/gyp_v8 --running-as-hook' in '.'
Traceback (most recent call last):
  File "v8/gypfiles/gyp_v8", line 46, in <module>
    import gyp
ImportError: No module named gyp
Error: Command '/usr/bin/python v8/gypfiles/gyp_v8 --running-as-hook' returned non-zero exit status 1 in .
Uninitializing temporary git repository
>> Cleaning up /home/seishun/v8-node/deps/v8/.git
Traceback (most recent call last):
  File "deps/v8/tools/node/fetch_deps.py", line 93, in <module>
    Main(sys.argv[1])
  File "deps/v8/tools/node/fetch_deps.py", line 89, in Main
    FetchDeps(v8_path, depot_tools)
  File "deps/v8/tools/node/fetch_deps.py", line 73, in FetchDeps
    env=env)
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['gclient', 'sync', '--spec', "solutions = [{'managed': False, 'custom_vars': {'build_for_node': True}, 'url': 'https://chromium.googlesource.com/v8/v8.git', 'custom_deps': {'v8/third_party/android_tools': None, 'v8/test/wasm-js': None, 'v8/test/benchmarks/data': None, 'v8/test/mozilla/data': None, 'v8/third_party/colorama/src': None, 'v8/testing/gmock': None, 'v8/third_party/markupsafe': None, 'v8/test/test262/data': None, 'v8/testing/gtest': None, 'v8/third_party/catapult': None, 'v8/third_party/jinja2': None, 'v8/test/test262/harness': None, 'v8/tools/swarming_client': None, 'v8/tools/luci-go': None, 'v8/base/trace_event/common': None, 'v8/third_party/instrumented_libraries': None, 'v8/tools/gyp': None}, 'deps_file': 'DEPS', 'name': 'v8'}]"]' returned non-zero exit status 2

@hashseed
Copy link
Member

hashseed commented Jan 6, 2018

For some reason my python distribution has gyp as package included. Yours doesn't. But then again we should not need it at all.

Does this patch fix the issue?

[2018-01-06 20:32:59] yangguo@yangguo2:~/test/node3$ less patch

diff --git a/deps/v8/DEPS b/deps/v8/DEPS
index d79a0d1fb4..38293dfb4c 100644
--- a/deps/v8/DEPS
+++ b/deps/v8/DEPS
@@ -319,6 +319,7 @@ hooks = [
     # A change to a .gyp, .gypi, or to GYP itself should run the generator.
     'name': 'regyp_if_needed',
     'pattern': '.',
+    'condition': 'build_for_node != True',
     'action': ['python', 'v8/gypfiles/gyp_v8', '--running-as-hook'],
   },
   # Download and initialize "vpython" VirtualEnv environment packages.

@seishun
Copy link

seishun commented Jan 6, 2018

Seems to work now.

Is this the final solution? I'm curious why you went with a fetch_deps.py script. I understand that checking in binaries is not ideal, but relying on a remote resource makes it susceptible to link rot, consequently there's no guarantee that this commit will be buildable in the future.

@hashseed
Copy link
Member

hashseed commented Jan 6, 2018

Thanks for verifying!

This is not the "final" solution in the sense of that's where Node.js' build system should end up. The problem this should solve is that the V8 team is committed to test against Node.js, but wants to end support for gyp. This is not designed as a full replacement for V8's gyp configs.

In the short term, Node.js inherits ownership over V8's gyp configurations to continue building with pure gyp configs (no GN wrapper). Ultimately Node.js will have to figure out whether to keep maintaining its own and V8's gyp configurations, or find something better altogether.

These remote resources are ones that V8 relies on and are tested on our infrastructure, so for the purpose of V8 testing against Node.js, link rot is not an issue. However, for building Node.js without having to rely on V8 and Chrome resources, this would indeed be a problem, so the gyp configs have to be maintained.

@seishun
Copy link

seishun commented Jan 7, 2018

Ultimately Node.js will have to figure out whether to keep maintaining its own and V8's gyp configurations, or find something better altogether.

That's the issue - if Node.js were to consider adopting GN (at least for V8), the dependence on V8 and Chrome resources might become an obstacle, considering the Node.js repo is currently self-contained.

@hashseed
Copy link
Member

hashseed commented Jan 7, 2018

Having talked to the GN team in the past, I don't think GN is a viable option for Node.js to completely follow through. This gyp-gn bridge is really just to cut the dependency to gyp for our integration testing.

@seishun
Copy link

seishun commented Jan 7, 2018

Having talked to the GN team in the past, I don't think GN is a viable option for Node.js to completely follow through.

Any reason for that besides the dependence on remote resources? And could you clarify what PR you meant in #411 (comment)? I assumed it referred to the GN wrapper.

@hashseed
Copy link
Member

hashseed commented Jan 7, 2018

The doc lays out a couple of reasons. Mostly because GN does not support the full range of platforms that Node.js does.

The PR I have in mind is to introduce a build flag to Node.js to be able to use the gn wrapper, currently the patch in step 2.

@seishun
Copy link

seishun commented Jan 7, 2018

Mostly because GN does not support the full range of platforms that Node.js does.

According to @refack, the V8 support for those platforms that are not supported by GN is maintained by companies interested in such support (IRC log). So it seems reasonable to expect those companies to help with GN support on those platforms as well if Node.js were to follow this route. It seems to me that it would be more efficient in the long run than maintaining gyp configs.

@hashseed
Copy link
Member

hashseed commented Jan 7, 2018

A couple of thoughts:

  • Platforms not backed by companies, such as FreeBSD, will not receive any support.
  • I have been wanting to asking @mhdawson for ever how the GN support for S390 and PPC looks. I heard rumors that there was something being worked on.
  • GN relies on a number of platform-dependent configs and binaries. You will not get around of fetching these resources from somewhere, unless you want to include them in Node altogether.
  • GN is not designed for broad public adoption from what I gathered.
  • The advantage of GN over something new, e.g. cmake, is that V8 already comes with GN files. Configs for cmake would have to be maintained, just like for gyp in the near future. Bazel has the same advantage as GN.
  • I'm not even sure Chromium/V8 will stick with GN in, say, 5 years :P

@seishun
Copy link

seishun commented Jan 7, 2018

Platforms not backed by companies, such as FreeBSD, will not receive any support.

Are there any other such platforms? FreeBSD is free and works on x86-64, so pretty much any collaborator can get involved with its support.

GN relies on a number of platform-dependent configs and binaries. You will not get around of fetching these resources from somewhere, unless you want to include them in Node altogether.

I think including them in Node is an option.

Bazel has the same advantage as GN.

In that case, Bazel is definitely worth looking into.

I'm not even sure Chromium/V8 will stick with GN in, say, 5 years :P

I'd say if the effort to adopt GN remains useful for 5 years, it would be more than worth it.

@mhdawson
Copy link
Member

mhdawson commented Jan 8, 2018

@hashseed I'll ask the people who were working on the GN support to comment here.

@hashseed
Copy link
Member

I streamlined things a bit.

git clone https://github.com/v8/node v8-node
cd v8-node 
git checkout vee-eight-lkgr
./configure --build-v8-with-gn
make -j4 test

@jasnell
Copy link
Member

jasnell commented Feb 17, 2018

Is there a next step here? Or can this issue be closed?

@hashseed
Copy link
Member

Guess next steps will have to happen when upgrading to V8 6.6.

@fhinkel
Copy link
Member

fhinkel commented Mar 8, 2018

Closing via nodejs/node#19201, feel free to re-open if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants