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: fix cctest build failure in Windows #21228

Closed
wants to merge 1 commit into from

Conversation

yhwang
Copy link
Member

@yhwang yhwang commented Jun 9, 2018

cctest needs to access some internal APIs in node core. Putting
node_lib_target_name as dependency would causes linking error when
node_lib is built as shared lib in Windows. The reason being is
those internal APIs don't have __declspec(dllexport). For cctest
we still need to specify individual obj files and link them instead
of node_lib. In Windows, changes of the dependencies in libraries
trigger the cctest to rebuild. However, in Linux platforms, it
doesn't work. Instead, need to put obj dependencies into sources.

Signed-off-by: Yihong Wang yh.wang@ibm.com

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the build Issues and PRs related to build files or the CI. label Jun 9, 2018
@yhwang yhwang requested a review from danbev June 9, 2018 06:32
@yhwang
Copy link
Member Author

yhwang commented Jun 9, 2018

I've verified the change on Windows 2016 and Ubuntu 16.04.

@Trott
Copy link
Member

Trott commented Jun 9, 2018

@nodejs/platform-windows @nodejs/build @nodejs/testing

@Trott
Copy link
Member

Trott commented Jun 9, 2018

Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

LGTM, but have some stuff to discuss

node.gyp Outdated
@@ -920,6 +920,143 @@
'node_dtrace_provider',
],

'variables': {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 2 levels?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it because of condition evaluation order.
In that case it's also possible to > or "late variable expansion operator", or just put a comment.

Copy link
Member Author

@yhwang yhwang Jun 11, 2018

Choose a reason for hiding this comment

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

because the only variables we need in cctest target are var_defines and dep_objs. Other variables are just intermediate. I can flatten them if variable scope is minor.

Copy link
Member Author

Choose a reason for hiding this comment

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

@refack after trying to flatten the variables, I need to use > for late variable expansion and I found it's easy to get confused. I'd prefer 2 level variable and I will put a comment there. how do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

👍
Comment is totally reasonable, but IMHO it's needed since it's a non-trivial pattern.

node.gyp Outdated
],
'conditions': [
[ 'node_use_openssl=="true"', {
'var_defines+': [ 'HAVE_OPENSSL=1' ],
Copy link
Contributor

Choose a reason for hiding this comment

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

So GYP has default list appending semantics so no need for the + suffix
+ just means "prepend"

Copy link
Member Author

Choose a reason for hiding this comment

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

I ran into some issues when I didn't use + sign in other place. In this case, I can remove it.

node.gyp Outdated
'variables': {
'obj_path': '<(obj_dir)/<(node_lib_target_name)/src',
'obj_gen_path': '<(obj_dir)/<(node_lib_target_name)/gen',
'obj_insp_path': '<(obj_dir)/<(node_lib_target_name)/src/inspector',
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's go with obj_inspetor_path

Copy link
Member Author

Choose a reason for hiding this comment

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

sure!

node.gyp Outdated
'dep_objs+': [
'<(obj_path)<(obj_separator)node_crypto.<(obj_suffix)',
'<(obj_path)<(obj_separator)node_crypto_bio.<(obj_suffix)',
'<(obj_path)<(obj_separator)'
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO this could be kept on one line (it's not the only >80 line anyway). But others may disagree.

Copy link
Member Author

Choose a reason for hiding this comment

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

I realized there are other >80 lines. however, let me follow the convention :-).

node.gyp Outdated
],
'defines': [
'HAVE_INSPECTOR=1',
'test/cctest/test_inspector_socket_server.cc',
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't we merge these lists?

Copy link
Member Author

Choose a reason for hiding this comment

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

merge? can you elaborate it more?

Copy link
Member Author

Choose a reason for hiding this comment

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

are you talking about merging this into variables? I don't know sources is available inside variables. If yes, I will merge them.

Copy link
Member Author

Choose a reason for hiding this comment

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

@refack I can't access sources inside variables. then what do you mean by merge?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's just that having the condition in multiple point makes it hard to grok.

So maybe define a conditionally filled variable

  'node_inspector_sources' : [],
  ...
  ['v8_enable_inspector==1', {
    'node_inspector_sources' : [
      'test/cctest/test_inspector_socket.cc',
      'test/cctest/test_inspector_socket_server.cc',
      '<@(node_inspector_generated_sources)',
  ]

Then here (or anywhere else where sources if appended) just have an unconditional

    'sources': [ '>@(node_inspector_sources)']

Copy link
Member Author

Choose a reason for hiding this comment

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

I see. I can merge them.

Copy link
Member Author

@yhwang yhwang Jun 12, 2018

Choose a reason for hiding this comment

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

@refack I found gyp throws an error when the variable is an empty array (./configure --without-inspector). Therefore, I need to preload the sources in cctest target into that new variable: var_sources. Same as var_defines.

@refack
Copy link
Contributor

refack commented Jun 10, 2018

Looks good in general, left some comments and questions.
(should also CC nodejs/gyp, but it's mostly overlapped anyway)

Resume CI: https://ci.nodejs.org/job/node-test-commit/19141/

@yhwang yhwang force-pushed the fix-windows-undefined-symbols branch 2 times, most recently from b2a4611 to 13d7c48 Compare June 12, 2018 17:16
@yhwang yhwang added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 18, 2018
@yhwang yhwang force-pushed the fix-windows-undefined-symbols branch from 13d7c48 to 748464b Compare June 18, 2018 18:01
@yhwang
Copy link
Member Author

yhwang commented Jun 18, 2018

rebase the code and new CI: https://ci.nodejs.org/job/node-test-commit/19311/

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.

This PR basically reverts 30f89df from a few months ago and (re)introduces a lot of duplication.

cctest needs to access some internal APIs in node core.

I'd say a better way forward is to identify those internal APIs and decide on a case-by-case basis what to do with them. Can you list them?

I could also live with disabling cctest for shared library builds; the static build gives good enough coverage.

@bnoordhuis
Copy link
Member

I could also live with disabling cctest for shared library builds

Another solution: introduce a NODE_PRIVATE_EXTERN macro that turns on __declspec(dllexport) in shared library builds and __declspec(dllimport) in cctest.

@apapirovski apapirovski removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 25, 2018
@addaleax
Copy link
Member

@yhwang What’s the status here?

@yhwang
Copy link
Member Author

yhwang commented Jul 19, 2018

@addaleax sorry for the lack of activity for this one. I was not able to have time handle this last month.

Based on @bnoordhuis 's comment. I will disable the cctest in Windows when building shared lib. For those internal APIs that are needed by cctest, I think introducing a NODE_PRIVATE_EXTERN macro still can't resolve the issue. In that case, we will need to compile the shared lib 2 times, with and without the macro. If we do believe the static lib already has good coverage, then there is no need to introduce the change to compile the shared lib differently in Windows, especially 2 times with different macros.

@addaleax
Copy link
Member

@yhwang thanks for the update, makes sense to me!

cctest depends on some internal APIs which don't declare
`__declspec(dllexport)` and causes build failure when building
node as shared lib on Windows. Since we already have good test
coverage in static lib, we decide to skip the cctest in shared
lib build on Windows.

Signed-off-by: Yihong Wang <yh.wang@ibm.com>
@yhwang yhwang force-pushed the fix-windows-undefined-symbols branch from 748464b to 0ec2e1d Compare July 24, 2018 20:46
@yhwang
Copy link
Member Author

yhwang commented Jul 24, 2018

@bnoordhuis @refack I completely removed my original change and just skip cctest target in the new change based on the feedback. Please review the change again. Thanks.

@yhwang
Copy link
Member Author

yhwang commented Aug 1, 2018

ping @bnoordhuis @refack @danbev . for now, I just disable the cctest on Windows when building shared lib. Let's discuss re-enabling it in another issue if needed.

@jasnell
Copy link
Member

jasnell commented Sep 10, 2018

Ping... any updates on this one?

@jasnell jasnell added the stalled Issues and PRs that are stalled. label Sep 10, 2018
@yhwang
Copy link
Member Author

yhwang commented Sep 11, 2018

I updated the change based on the comments and wait for review/comment. after the update, I haven't received any feedback yet.

@refack
Copy link
Contributor

refack commented Sep 11, 2018

I'm fine with the current workaround...

@yhwang yhwang dismissed bnoordhuis’s stale review September 13, 2018 16:23

this review is outdated

@yhwang
Copy link
Member Author

yhwang commented Sep 13, 2018

@bnoordhuis 's review is for old change. let me dismiss his old review

@yhwang
Copy link
Member Author

yhwang commented Sep 13, 2018

@yhwang yhwang added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Sep 13, 2018
@yhwang
Copy link
Member Author

yhwang commented Sep 13, 2018

CI is green

@addaleax
Copy link
Member

Landed in 29cf335

@addaleax addaleax closed this Sep 17, 2018
addaleax pushed a commit that referenced this pull request Sep 17, 2018
cctest depends on some internal APIs which don't declare
`__declspec(dllexport)` and causes build failure when building
node as shared lib on Windows. Since we already have good test
coverage in static lib, we decide to skip the cctest in shared
lib build on Windows.

Signed-off-by: Yihong Wang <yh.wang@ibm.com>

PR-URL: #21228
Reviewed-By: Refael Ackermann <refack@gmail.com>
targos pushed a commit that referenced this pull request Sep 18, 2018
cctest depends on some internal APIs which don't declare
`__declspec(dllexport)` and causes build failure when building
node as shared lib on Windows. Since we already have good test
coverage in static lib, we decide to skip the cctest in shared
lib build on Windows.

Signed-off-by: Yihong Wang <yh.wang@ibm.com>

PR-URL: #21228
Reviewed-By: Refael Ackermann <refack@gmail.com>
targos pushed a commit that referenced this pull request Sep 19, 2018
cctest depends on some internal APIs which don't declare
`__declspec(dllexport)` and causes build failure when building
node as shared lib on Windows. Since we already have good test
coverage in static lib, we decide to skip the cctest in shared
lib build on Windows.

Signed-off-by: Yihong Wang <yh.wang@ibm.com>

PR-URL: #21228
Reviewed-By: Refael Ackermann <refack@gmail.com>
targos pushed a commit that referenced this pull request Sep 20, 2018
cctest depends on some internal APIs which don't declare
`__declspec(dllexport)` and causes build failure when building
node as shared lib on Windows. Since we already have good test
coverage in static lib, we decide to skip the cctest in shared
lib build on Windows.

Signed-off-by: Yihong Wang <yh.wang@ibm.com>

PR-URL: #21228
Reviewed-By: Refael Ackermann <refack@gmail.com>
@yhwang yhwang deleted the fix-windows-undefined-symbols branch November 30, 2018 19:00
BethGriggs pushed a commit to BethGriggs/node that referenced this pull request Mar 20, 2019
cctest depends on some internal APIs which don't declare
`__declspec(dllexport)` and causes build failure when building
node as shared lib on Windows. Since we already have good test
coverage in static lib, we decide to skip the cctest in shared
lib build on Windows.

Signed-off-by: Yihong Wang <yh.wang@ibm.com>

PR-URL: nodejs#21228
Reviewed-By: Refael Ackermann <refack@gmail.com>
BethGriggs pushed a commit that referenced this pull request Mar 20, 2019
cctest depends on some internal APIs which don't declare
`__declspec(dllexport)` and causes build failure when building
node as shared lib on Windows. Since we already have good test
coverage in static lib, we decide to skip the cctest in shared
lib build on Windows.

Signed-off-by: Yihong Wang <yh.wang@ibm.com>

Backport-PR-URL: #25758
PR-URL: #21228
Reviewed-By: Refael Ackermann <refack@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Mar 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. build Issues and PRs related to build files or the CI. stalled Issues and PRs that are stalled.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants