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

Backport --shared to V4.x codebase to allow building as a shared library / DLL #9385

Closed
wants to merge 4 commits into from

Conversation

sxa
Copy link
Member

@sxa sxa commented Oct 31, 2016

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

build

Description of change

Enable the --shared parameter for building node as a shared library on Linux/OS X/Windows. This is a backport of the support that's already in the V6 codebase. Reference #7687 - FYI @thealphanerd

@nodejs-github-bot nodejs-github-bot added 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++. tools Issues and PRs related to the tools directory. v4.x labels Oct 31, 2016
@sxa sxa changed the title V4.x sharedlib Enable --shared in V4.x codebase to allow building as a shared library / DLL Oct 31, 2016
@sxa sxa changed the title Enable --shared in V4.x codebase to allow building as a shared library / DLL Backport --shared to V4.x codebase to allow building as a shared library / DLL Oct 31, 2016
@jasnell
Copy link
Member

jasnell commented Nov 2, 2016

@nodejs/lts @jbergstroem

@jasnell
Copy link
Member

jasnell commented Nov 2, 2016

Nit: there's a typo in the commit log message in 4bb43f7

@MylesBorins
Copy link
Contributor

@sxa555 were there other pr's for the windows support and abstraction? I don't see those in #7687

Also would it be possible for you to include the full original commit title and message from the original commit that landed, including all applicable meta data

see a722205 for an example

You can include the url to this PR as a Ref:

@sxa
Copy link
Member Author

sxa commented Nov 2, 2016

Added PR Refs to description. The original PRs included multiple number of individual commits which I haven't duplicated individually for V4 - I've just got one commit for each of the three related PRs commit descriptions for the Windows and Linux ones updated to align the messages from those PRs.

Some of the things from my "abstract out" commit were done in commits within the original #6994 but for simplicity of merging what I already had for V4 I've put it all in the third of the commits. Hope that's ok

@sxa sxa force-pushed the v4.x-sharedlib branch 2 times, most recently from 0adff46 to 9cd4f68 Compare November 7, 2016 19:01
@MylesBorins
Copy link
Contributor

@sxa555 the meta data on the commits are still not the same as the original. Please use the entire original commit message.

For example 8df50ac should be changed from

 build: introduce configure --shared

Backport support for building as a shared library on Linux to V4
Ref: https:/nodejs/node/pull/6994

to

 build: configure --shared

Add configure flag for building a shared library that can be
embedded in other applications (like Electron). Add flags
--without-bundled-v8 and --without-v8-platform to control V8
dependencies used.

PR-URL: https:/nodejs/node/pull/6994
Ref: https:/nodejs/node/pull/9385
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Fedor Indutny <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>

I'm a bit concerned with the commit 7bfa0f2 which does not appear to have gone through review yet. Is this simply extra stuff that needs to be modified to make the backport work or is this completely new stuff that needs to be reviewed again?

@sxa
Copy link
Member Author

sxa commented Nov 7, 2016

ref 7bfa0f2 it is a combination of the additions in 410296c to pick up the version info and the modifications that were requested in af2d04b. I'll add the commit messages tomorrow - cheers for the info

@@ -351,7 +354,8 @@ goto exit

:help

echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/intl-none] [nobuild] [nosign] [x86/x64] [vc2013/vc2015] [download-all] [enable-vtune]
echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/intl-none] [nobuild] [nosign] [x86/x64] [vc2013/vc2015] [download-all] [enable-vtune] [dll]
echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/intl-none] [nobuild] [nosign] [x86/x64] [vc2013/vc2015] [download-all]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a style nit.

static void fn(void) __attribute__((constructor)); \
static void fn(void)
NODE_CTOR_PREFIX void fn(void) __attribute__((constructor)); \
NODE_CTOR_PREFIX void fn(void)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make sure the backslashes line up?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -995,7 +995,7 @@
'VCCLCompilerTool': {
'Optimization': '0',
'conditions': [
['component=="shared_library"', {
['component=="shared_library" or node_shared=="true"', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In v6.x this looks like:

['component=="shared_library" or force_dynamic_crt==1', {

Further, in master I think it still uses force_dynamic_crt

I would have expected the backport for 4.x to be consistent ?

So this should be consistent with what we landed in v8 right ?

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to me like there are some changes in this PR which are not in the original PRs, unless I'm looking incorrectly as noted in line comments. I think a backport should just be the original changes with the only additional changes being those needed to make them apply/work.

If thats the case and I'm misunderstanding just let me know.

output_prefix += 'lib.target/'
output_file = 'lib' + output_file + '.so'

action([output_prefix + output_file], 'bin/' + output_file)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In v6.x it looks like this:

parser.add_option('--static-libstdc++',
action='store_true',
dest='use_static_libstdcpp',
help='statically link to libstdc++ library instead of dynamically linking')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this was removed in v6.x so thinking we don't want to add in v4.x. I also don't see it in #6994 so I'm wondering where it came from.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, although there is another reference to -static-libstdc++ in the configure script. I've removed it.

@@ -351,7 +354,7 @@ goto exit

:help

echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/intl-none] [nobuild] [nosign] [x86/x64] [vc2013/vc2015] [download-all] [enable-vtune]
echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/intl-none] [nobuild] [nosign] [x86/x64] [vc2013/vc2015] [download-all] [enable-vtune] [dll]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line for v6.x is
echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-inspector/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/without-intl] [nobuild] [nosign] [x86/x64] [vc2015] [download-all] [enable-vtune]

which does not have the [dll], and its not there in master either ? Its also not in #7487

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point - it probably should have been though. I'll look at getting that added in via master. I've removed it for consistency here though

@sxa
Copy link
Member Author

sxa commented Nov 17, 2016

Updated with the V8 change (including version bump) as a separate commit as requested

@MylesBorins
Copy link
Contributor

MylesBorins commented Nov 17, 2016

hey @sxa555 sorry for making this so difficult. I ended up fixing the backport on v6.x and have landed a proper backport, with appropriate meta data, in 5bb29683a5fe7600026fc8ea3747d707376dd31e

As such you can you please remove 00052e5 from this PR and rebase against the staging branch. After doing that I'll want to run the test suite one more time and then this will be ready to land!

edit: IGNORE ALL OF THIS

@MylesBorins
Copy link
Contributor

It looks like the other patch didn't work. I bet that is the reason for the original diff... something likely landed in the gyp file of v6.x that fixed it between when it originally landed and now. This patch lands and works, so let's just stick to it.

If this CI is green I will land this PR: https://ci.nodejs.org/job/node-test-pull-request/4876/

@sxa
Copy link
Member Author

sxa commented Nov 18, 2016

test/freebsd 11 looks to be failing for other integration tests so I don't think that's related. Have pushed a fix to the linter failure by adding another space.

@MylesBorins MylesBorins changed the base branch from v4.x to v4.x-staging November 18, 2016 18:24
@MylesBorins
Copy link
Contributor

@sxa555 sorry that this process keeps dragging out. it would appear you made this PR target v4.x when it should have been targeting v4.x-staging

When targeting the correct branch there is a conflict in node.gyp

--- a/node.gyp
+++ b/node.gyp
@@@ -94,12 -99,10 +99,19 @@@
        'deps/v8/tools/tickprocessor-driver.js',
      ],
      'conditions': [
++<<<<<<< HEAD
 +      [ 'OS=="win" and '
 +        'node_use_openssl=="true" and '
 +        'node_shared_openssl=="false"', {
 +        'use_openssl_def': 1,
 +      }, {
 +        'use_openssl_def': 0,
++=======
+       [ 'node_shared=="true"', {
+         'node_target_type%': 'shared_library',
+       }, {
+         'node_target_type%': 'executable',
++>>>>>>> build: configure --shared
        }],
      ],
    },

Once the conflict is resolved, we can run the CI one last time. Thank you for your patience

stefanmb and others added 4 commits November 18, 2016 18:45
PR-URL: nodejs#8084
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Add configure flag for building a shared library that can be
embedded in other applications (like Electron). Add flags
--without-bundled-v8 and --without-v8-platform to control V8
dependencies used.

PR-URL: nodejs#6994
Ref: nodejs#9385
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Fedor Indutny <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>

Reference:  nodejs#7487
WIP: Add soname & fix make install

PR-URL: nodejs#6994
Ref: nodejs#9385
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Fedor Indutny <[email protected]>

The build system currently creates a shared library on OS X with the
same name as on Linux i.e.  libnode.so.48.  This is inconsistent with
the conventions on OS X which uses libnode.48.dylib This commit changes
the build process and install.py (used by make binary) to build with
the correct name on OS X when the --shared configure parameter is used.

PR-URL: nodejs#7687
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
@sxa
Copy link
Member Author

sxa commented Nov 18, 2016

Now resolved :-)

@MylesBorins
Copy link
Contributor

MylesBorins pushed a commit that referenced this pull request Nov 18, 2016
Ref: #9385
PR-URL: #8084
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Nov 18, 2016
Add configure flag for building a shared library that can be
embedded in other applications (like Electron). Add flags
--without-bundled-v8 and --without-v8-platform to control V8
dependencies used.

PR-URL: #6994
Ref: #7487
Ref: #9385
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Fedor Indutny <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
MylesBorins pushed a commit that referenced this pull request Nov 18, 2016
Original Commit Message:
  Added "dll" option to vcbuild.bat
  Insure that Unix SO name is not used on Windows (i.e. produce a .dll file)
  Insure that Node and its V8 dependency link against the Visual C++ Runtime
  dynamically.
  Requires backported V8 patch, see PR 7802.

  Ref: #7802

  PR-URL: #7487
  Reviewed-By: Alexis Campailla <[email protected]>
  Reviewed-By: Michael Dawson <[email protected]>

PR-URL: #9385
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Myles Borins <[email protected]>
MylesBorins pushed a commit that referenced this pull request Nov 18, 2016
Originally part of 410296c abstracted out in backport

PR-URL: #9385
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Myles Borins <[email protected]>
@MylesBorins
Copy link
Contributor

MylesBorins commented Nov 18, 2016

landed in 527db40...e97723b

@MylesBorins MylesBorins removed this from the 4.7.0 milestone Nov 22, 2016
@MylesBorins MylesBorins mentioned this pull request Nov 22, 2016
BethGriggs pushed a commit to ibmruntimes/node that referenced this pull request Dec 7, 2016
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++. tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants