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

build: introduce configure --shared #6994

Closed
wants to merge 9 commits into from

Conversation

stefanmb
Copy link
Contributor

Checklist
  • tests and code linting passes
  • documentation is changed or added
  • the commit message follows commit guidelines
Affected core subsystem(s)

build, configure

Description of change

This PR is the continuation of #5918 where the originator (@indutny) agreed that I can take over this task in order to land the changes as soon as possible.

The PR consists of two commits, the original one from #5918 which adds "[a] configure flag for building shared library that could be used to embed Node.js in some application (like Electron)" and a second commit that modifies the following aspects:

  • Use the "--shared" configure flag to build a shared library.
  • Use the "--no-bundled-v8" flag to exclude V8 headers from the deps/ folder, this option is useful to Electron which provides its own copy of V8.
  • Use the "--no-v8-platform" flag to avoid initializing the V8 platform inside Node (useful for some embedders).
  • Insure that "./configure --shared && make" works and produces a useable libnode.so for anyone (i.e. decouple --shared from Electron's build system).

I intend to land both commits in the PR at the same time (the original one from @indutny and my changes on top of it) to maintain a clear history/ownership of the work. If anyone feels strongly about this approach either way, please let me know.

All these options are provided as-is for embedders are not officially supported at this time, as indicated in the documentation.

Future changes:

This PR is concerned with Linux only - once this PR is landed a separate PR will be made to resolve issues related to building a DLL on Windows.

@stefanmb stefanmb added c++ Issues and PRs that require attention from people who are familiar with C++. install Issues and PRs related to the installers. build Issues and PRs related to build files or the CI. labels May 26, 2016
@stefanmb stefanmb self-assigned this May 26, 2016
@stefanmb stefanmb mentioned this pull request May 26, 2016
4 tasks
@stefanmb
Copy link
Contributor Author

@MylesBorins
Copy link
Contributor

@stefanmb it looks like this needs a rebase. Let me know if there is anything I can help with on this

@rvagg
Copy link
Member

rvagg commented May 31, 2016

@nodejs/build we should probably reach out to distro packagers to get feedback on this, if it's not useful to them all then it's probably not worth it as it is. Who do we have? @kapouer is the only one I can think of off the top of my head.

@kapouer
Copy link
Contributor

kapouer commented May 31, 2016

Yes, why not. I'll try to use that option later today and report back.

@kapouer
Copy link
Contributor

kapouer commented May 31, 2016

When building a shared library, it is a common and good practice to give it a soname.
v8 contains an example of how to do so with gyp, just grep soname there.
I think the right soname for node is libnode.so.${process.versions.modules}.

@bnoordhuis
Copy link
Member

/cc @sgallagher - see #6994 (comment).

@sgallagher
Copy link
Contributor

Passing the buck over to @thughes

@mhdawson
Copy link
Member

We are interested in it because we have internal product teams that what to include Node.js in a product without having a separate process. So I don't see that it should be tied to the distro packages. If they say it would be useful to have a shared library but this does not address the requirement then we need that input and need to adjust. If on the other hand they just don't need a shared library I don't think that invalidates its usefulness as we have examples like electron and our internal team which do want it as a shared library.

@kapouer
Copy link
Contributor

kapouer commented May 31, 2016

@mhdawson on the debian side i'm pretty sure it's going to be useful, one way or another.

@mhdawson
Copy link
Member

@kapouer good to hear.

@stefanmb
Copy link
Contributor Author

@thealphanerd Rebased onto master, thanks.

@rvagg @mhdawson In addition to Michael's comments, I think the need for this feature was strongly expressed in #5918, nodejs/node-v0.x-archive#7336, and nodejs/roadmap#9. It is my intention to get this feature working on all platforms starting with Linux in this PR.

@kapouer Thank you for the soname suggestion, I've implemented it (and fixed the install.py script which I'd previously broken due to some bad merging, sorry!). It required a few hacks to get the information in the right place but the end product will now be "libnode.so.${process.versions.modules}" as you indicated. This may be a bit counter-intuitive to regular users since the module version does not map to the Node release version in an obvious way, but I believe it makes sense to provide this naming convention for embedders.

New CI: https://ci.nodejs.org/job/node-test-pull-request/2880/

@stefanmb
Copy link
Contributor Author

@jbergstroem
Copy link
Member

@kapouer do you know of any packages that would use this?

@kapouer
Copy link
Contributor

kapouer commented Jun 1, 2016

@jbergstroem besides addons (it's more natural to link them to libnode) no, not yet. Electron, eventually...

@jbergstroem
Copy link
Member

@kapouer ok, thanks. How about libv8 bindings? Would any of those deps overflow/consider switching?

@kapouer
Copy link
Contributor

kapouer commented Jun 1, 2016

Could you be a little more specific ? I don't understand the question.

@jbergstroem
Copy link
Member

@kapouer sorry; was just wondering if packages that builds against a shared v8 would/could be interested in this.

@kapouer
Copy link
Contributor

kapouer commented Jun 2, 2016

@jbergstroem i'm not sure it would be a good idea to link to libnode for a software that just needs v8. Maybe one day libnode will expose only nan-like symbols ?

@stefanmb stefanmb force-pushed the sharedlib-pr1 branch 2 times, most recently from 16b3dbf to 69fca3e Compare June 2, 2016 21:43
@stefanmb
Copy link
Contributor Author

stefanmb commented Jun 2, 2016

Based on some comments from @mhdawson I've made the following changes:

  • Rebase again onto master.
  • Fixed NODE_CTOR_PREFIX to be guarded under the correct NODE_SHARED_MODE define. This define will remove static from the DSO constructors for the modules when in shared library mode. It's not strictly needed to do so in order to have the constructor symbols exported, but Electron uses them so I've kept compatibility, see build: add --enable-shared and --enable-static node-v0.x-archive#7336 (comment) for details.
  • Remove superfluous dependencies in node.gyp.
  • Fixed some rules in node.gyp to check for no_bundled_v8 instead of node_shared

CI: https://ci.nodejs.org/job/node-test-pull-request/2906/

@mhdawson
Copy link
Member

mhdawson commented Jun 8, 2016

LGTM with one question I'd like to have confirmation for. I assume that post-mortem and vtune support is disabled for node_no_bundled_v8 because we need the specific v8 version/code to support those which we don't have when that option is supported, right ?

@stefanmb
Copy link
Contributor Author

stefanmb commented Jun 8, 2016

@mhdawson Those options both introduce dependencies from the bundled V8 folder:
deps/v8/src/third_party/vtune/v8vtune.gyp:v8_vtune and deps/v8/tools/gyp/v8.gyp:postmortem-metadata respectively. The node_no_bundled_v8 option is meant to exclude dependencies on the bundled V8.

sxa pushed a commit to sxa/node that referenced this pull request Nov 21, 2016
Updates to build the shared library version of node on AIX. Adds the
same functionality to AIX that was added on Linux under this:

Ref: nodejs#6994
@MylesBorins MylesBorins mentioned this pull request Nov 22, 2016
mhdawson pushed a commit that referenced this pull request Nov 22, 2016
Updates to build the shared library version of node on AIX. Adds the
same functionality to AIX that was added on Linux under this:

Ref: #6994

PR-URL: #9675
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
sxa pushed a commit to sxa/node that referenced this pull request Nov 23, 2016
Updates to build the shared library version of node on AIX. Adds the
same functionality to AIX that was added on Linux under this:

Ref: nodejs#6994

PR-URL: nodejs#9675
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
sxa pushed a commit to sxa/node that referenced this pull request Nov 23, 2016
Updates to build the shared library version of node on AIX. Adds the
same functionality to AIX that was added on Linux under this:

Ref: nodejs#6994

PR-URL: nodejs#9675
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
sxa pushed a commit to sxa/node that referenced this pull request Nov 23, 2016
Updates to build the shared library version of node on AIX. Adds the
same functionality to AIX that was added on Linux under this:

Ref: nodejs#6994

PR-URL: nodejs#9675
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
MylesBorins referenced this pull request Nov 24, 2016
Required to support the shared library builds on AIX - this sets the
shared library suffix within GYP to .a instead of .so on AIX
My patch: https://codereview.chromium.org/2492233002/ was landed as
as part of this one which fixed some other (not required, but
included for completeness of the backport) changes:

Ref: https://codereview.chromium.org/2511733005/
MylesBorins pushed a commit that referenced this pull request Nov 24, 2016
Updates to build the shared library version of node on AIX. Adds the
same functionality to AIX that was added on Linux under this:

Ref: #6994

PR-URL: #9675
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
MylesBorins pushed a commit that referenced this pull request Dec 6, 2016
This LTS release comes with 108 commits. This includes 30 which are doc
related, 28 which are test related, 16 which are build / tool related,
and 4 commits which are updates to dependencies.

Notable Changes:

The SEMVER-MINOR changes include:

* build:
  - export openssl symbols on Windows making it possible to build
    addons linked against the bundled version of openssl (Alex Hultman)
    #7576
* debugger:
  - make listen address configurable in the debugger server
    (Ben Noordhuis) #3316
* dgram:
  - generalized send queue to handle close fixing a potential throw
    when dgram socket is closed in the listening event handler.
    (Matteo Collina) #7066
* http:
  - Introduce the 451 status code "Unavailable For Legal Reasons"
    (Max Barinov) #4377
* tls:
  - introduce `secureContext` for `tls.connect` which is useful for
    caching client certificates, key, and CA certificates.
    (Fedor Indutny) #4246

Notable SEMVER-PATCH changes include:

* build:
  - introduce the configure --shared option for embedders (sxa555)
    #6994
* gtest:
  - the test reporter now outputs tap comments as yamlish
    (Johan Bergström) #9262
* src:
  - node no longer aborts when c-ares initialization fails
    (Ben Noordhuis) #8710
* tls:
  - fix memory leak when writing data to TLSWrap instance during
    handshake (Fedor Indutny)
    #9586

PR-URL: #9736
MylesBorins pushed a commit that referenced this pull request Dec 6, 2016
This LTS release comes with 108 commits. This includes 30 which are doc
related, 28 which are test related, 16 which are build / tool related,
and 4 commits which are updates to dependencies.

Notable Changes:

The SEMVER-MINOR changes include:

* build:
  - export openssl symbols on Windows making it possible to build
    addons linked against the bundled version of openssl (Alex Hultman)
    #7576
* debugger:
  - make listen address configurable in the debugger server
    (Ben Noordhuis) #3316
* dgram:
  - generalized send queue to handle close fixing a potential throw
    when dgram socket is closed in the listening event handler.
    (Matteo Collina) #7066
* http:
  - Introduce the 451 status code "Unavailable For Legal Reasons"
    (Max Barinov) #4377
* tls:
  - introduce `secureContext` for `tls.connect` which is useful for
    caching client certificates, key, and CA certificates.
    (Fedor Indutny) #4246

Notable SEMVER-PATCH changes include:

* build:
  - introduce the configure --shared option for embedders (sxa555)
    #6994
* gtest:
  - the test reporter now outputs tap comments as yamlish
    (Johan Bergström) #9262
* src:
  - node no longer aborts when c-ares initialization fails
    (Ben Noordhuis) #8710
* tls:
  - fix memory leak when writing data to TLSWrap instance during
    handshake (Fedor Indutny)
    #9586

PR-URL: #9736
MylesBorins pushed a commit that referenced this pull request Dec 6, 2016
This LTS release comes with 108 commits. This includes 30 which are doc
related, 28 which are test related, 16 which are build / tool related,
and 4 commits which are updates to dependencies.

Notable Changes:

The SEMVER-MINOR changes include:

* build:
  - export openssl symbols on Windows making it possible to build
    addons linked against the bundled version of openssl (Alex Hultman)
    #7576
* debugger:
  - make listen address configurable in the debugger server
    (Ben Noordhuis) #3316
* dgram:
  - generalized send queue to handle close fixing a potential throw
    when dgram socket is closed in the listening event handler.
    (Matteo Collina) #7066
* http:
  - Introduce the 451 status code "Unavailable For Legal Reasons"
    (Max Barinov) #4377
* tls:
  - introduce `secureContext` for `tls.connect` which is useful for
    caching client certificates, key, and CA certificates.
    (Fedor Indutny) #4246

Notable SEMVER-PATCH changes include:

* build:
  - introduce the configure --shared option for embedders (sxa555)
    #6994
* gtest:
  - the test reporter now outputs tap comments as yamlish
    (Johan Bergström) #9262
* src:
  - node no longer aborts when c-ares initialization fails
    (Ben Noordhuis) #8710
* tls:
  - fix memory leak when writing data to TLSWrap instance during
    handshake (Fedor Indutny)
    #9586

PR-URL: #9736
imyller added a commit to imyller/meta-nodejs that referenced this pull request Dec 7, 2016
    This LTS release comes with 108 commits. This includes 30 which are doc
    related, 28 which are test related, 16 which are build / tool related,
    and 4 commits which are updates to dependencies.

    Notable Changes:

    The SEMVER-MINOR changes include:

    * build:
      - export openssl symbols on Windows making it possible to build
        addons linked against the bundled version of openssl (Alex Hultman)
        nodejs/node#7576
    * debugger:
      - make listen address configurable in the debugger server
        (Ben Noordhuis) nodejs/node#3316
    * dgram:
      - generalized send queue to handle close fixing a potential throw
        when dgram socket is closed in the listening event handler.
        (Matteo Collina) nodejs/node#7066
    * http:
      - Introduce the 451 status code "Unavailable For Legal Reasons"
        (Max Barinov) nodejs/node#4377
    * tls:
      - introduce `secureContext` for `tls.connect` which is useful for
        caching client certificates, key, and CA certificates.
        (Fedor Indutny) nodejs/node#4246

    Notable SEMVER-PATCH changes include:

    * build:
      - introduce the configure --shared option for embedders (sxa555)
        nodejs/node#6994
    * gtest:
      - the test reporter now outputs tap comments as yamlish
        (Johan Bergstrom) nodejs/node#9262
    * src:
      - node no longer aborts when c-ares initialization fails
        (Ben Noordhuis) nodejs/node#8710
    * tls:
      - fix memory leak when writing data to TLSWrap instance during
        handshake (Fedor Indutny)
        nodejs/node#9586

    PR-URL: nodejs/node#9736

Signed-off-by: Ilkka Myller <ilkka.myller@nodefield.com>
imyller added a commit to imyller/meta-nodejs that referenced this pull request Dec 7, 2016
    This LTS release comes with 108 commits. This includes 30 which are doc
    related, 28 which are test related, 16 which are build / tool related,
    and 4 commits which are updates to dependencies.

    Notable Changes:

    The SEMVER-MINOR changes include:

    * build:
      - export openssl symbols on Windows making it possible to build
        addons linked against the bundled version of openssl (Alex Hultman)
        nodejs/node#7576
    * debugger:
      - make listen address configurable in the debugger server
        (Ben Noordhuis) nodejs/node#3316
    * dgram:
      - generalized send queue to handle close fixing a potential throw
        when dgram socket is closed in the listening event handler.
        (Matteo Collina) nodejs/node#7066
    * http:
      - Introduce the 451 status code "Unavailable For Legal Reasons"
        (Max Barinov) nodejs/node#4377
    * tls:
      - introduce `secureContext` for `tls.connect` which is useful for
        caching client certificates, key, and CA certificates.
        (Fedor Indutny) nodejs/node#4246

    Notable SEMVER-PATCH changes include:

    * build:
      - introduce the configure --shared option for embedders (sxa555)
        nodejs/node#6994
    * gtest:
      - the test reporter now outputs tap comments as yamlish
        (Johan Bergstrom) nodejs/node#9262
    * src:
      - node no longer aborts when c-ares initialization fails
        (Ben Noordhuis) nodejs/node#8710
    * tls:
      - fix memory leak when writing data to TLSWrap instance during
        handshake (Fedor Indutny)
        nodejs/node#9586

    PR-URL: nodejs/node#9736

Signed-off-by: Ilkka Myller <ilkka.myller@nodefield.com>
MylesBorins pushed a commit that referenced this pull request Dec 8, 2016
Updates to build the shared library version of node on AIX. Adds the
same functionality to AIX that was added on Linux under this:

Ref: #6994

PR-URL: #9675
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
MylesBorins pushed a commit that referenced this pull request Dec 9, 2016
Updates to build the shared library version of node on AIX. Adds the
same functionality to AIX that was added on Linux under this:

Ref: #6994

PR-URL: #9675
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@dominictarr
Copy link
Contributor

My understanding is also that this would be essential for running on a unrooted andoid. you get one process, which must be java, but you can link a .so which could be libnode.so. That is how jxcore (RIP) did it.

@MylesBorins
Copy link
Contributor

@dominictarr you should find this commit now in the latest v4, v6, and v7

I believe there are still other edges regarding android... let me know if you try and get it working

MylesBorins pushed a commit that referenced this pull request Dec 21, 2016
Updates to build the shared library version of node on AIX. Adds the
same functionality to AIX that was added on Linux under this:

Ref: #6994

PR-URL: #9675
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
MylesBorins pushed a commit that referenced this pull request Dec 21, 2016
Updates to build the shared library version of node on AIX. Adds the
same functionality to AIX that was added on Linux under this:

Ref: #6994

PR-URL: #9675
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. c++ Issues and PRs that require attention from people who are familiar with C++. install Issues and PRs related to the installers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.