Skip to content

build: fix cctest build failure in Windows#21228

Closed
yhwang wants to merge 1 commit into
nodejs:masterfrom
yhwang:fix-windows-undefined-symbols
Closed

build: fix cctest build failure in Windows#21228
yhwang wants to merge 1 commit into
nodejs:masterfrom
yhwang:fix-windows-undefined-symbols

Conversation

@yhwang

@yhwang yhwang commented Jun 9, 2018

Copy link
Copy Markdown
Member

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

yhwang commented Jun 9, 2018

Copy link
Copy Markdown
Member Author

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

@Trott

Trott commented Jun 9, 2018

Copy link
Copy Markdown
Member

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

@Trott

Trott commented Jun 9, 2018

Copy link
Copy Markdown
Member

@jasnell jasnell requested review from bnoordhuis and refack June 10, 2018 20:46

@refack refack left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread node.gyp Outdated

Copy link
Copy Markdown
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
Copy Markdown
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.

@yhwang yhwang Jun 11, 2018

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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
Copy Markdown
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.

Comment thread node.gyp Outdated

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread node.gyp Outdated

Copy link
Copy Markdown
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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

sure!

Comment thread node.gyp Outdated

Copy link
Copy Markdown
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
Copy Markdown
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 :-).

Comment thread node.gyp Outdated

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@yhwang yhwang Jun 12, 2018

Copy link
Copy Markdown
Member Author

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

refack commented Jun 10, 2018

Copy link
Copy Markdown
Contributor

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

yhwang commented Jun 18, 2018

Copy link
Copy Markdown
Member Author

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

@bnoordhuis bnoordhuis left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member

@yhwang What’s the status here?

@yhwang

yhwang commented Jul 19, 2018

Copy link
Copy Markdown
Member Author

@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
Copy Markdown
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

yhwang commented Jul 24, 2018

Copy link
Copy Markdown
Member Author

@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

yhwang commented Aug 1, 2018

Copy link
Copy Markdown
Member Author

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

jasnell commented Sep 10, 2018

Copy link
Copy Markdown
Member

Ping... any updates on this one?

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

yhwang commented Sep 11, 2018

Copy link
Copy Markdown
Member Author

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

@refack

refack commented Sep 11, 2018

Copy link
Copy Markdown
Contributor

I'm fine with the current workaround...

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

this review is outdated

@yhwang

yhwang commented Sep 13, 2018

Copy link
Copy Markdown
Member Author

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

@yhwang

yhwang commented Sep 13, 2018

Copy link
Copy Markdown
Member Author

@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

yhwang commented Sep 13, 2018

Copy link
Copy Markdown
Member Author

CI is green

@addaleax

Copy link
Copy Markdown
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.

8 participants