Skip to content

test: add lib path env when node_shared=true - #18626

Closed
yhwang wants to merge 1 commit into
nodejs:masterfrom
yhwang:sharedlib-fix-testcase-lib-not-found
Closed

test: add lib path env when node_shared=true#18626
yhwang wants to merge 1 commit into
nodejs:masterfrom
yhwang:sharedlib-fix-testcase-lib-not-found

Conversation

@yhwang

Copy link
Copy Markdown
Member

When building the node with --shared option, the major output is the
shared library. However, we still build a node executable which links
to the shared lib. It's for testing purpose. When testing with the
executable, some test cases move/copy the executable, change the relative
path to the shared library and fail. Using lib path env would solve the
issue. However, in macOS, need to modify the dependency in the
executable by using the install_name_tool utility. In AIX, -brtl
linker option rebinds the symbols in the executable and addon modules
could use them.

Refs: #18535

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

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

test, build

@nodejs-github-botnodejs-github-bot added the build Issues and PRs related to build files or the CI. label Feb 7, 2018
Comment threadMakefile Outdated

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.

Maybe it would be better to make change-install-name a no-op itself, rather than making its usage conditional? The current implementation wouldn’t work on other OSes anyway, right?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

it's only for macOS. so you mean make it no-op for other platform?

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.

@yhwang Yes, exactly that 👍

Comment threadMakefile Outdated

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.

Is /usr/local/lib hardcoded somewhere else, or should we use the actual prefix here?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

It's a good question. I don't know where it comes from. and that's important for shared lib embedders. If they build the shared lib, they may want to change it. And that's for macOS only.

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.

@yhwang I guess it’s coming from $(PREFIX) or ./configure --prefix=…?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Oh, I see. if that's the case, let me change it to variable. Thanks!

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

@addaleax oops, seems the /usr/local/lib comes from here: https://github.com/nodejs/node/blob/master/tools/gyp/pylib/gyp/xcode_emulation.py#L763
And it doesn't honor PREFIX..... is this a bug?

@yhwangyhwangFeb 8, 2018

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

In Linux we use $ORIGIN in rpath when linking. For macOS, we can use @loader_path. Should I add a TODO in the comment and do the change in other PR?
In here, I will leave it to /usr/local/lib for now. is that okay?

[Edit] There is @rpath since macOS 10.5

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

@addaleax I updated my change to use @rpath. Then I reverted my change in Makefile. You may take a look.

Comment threadMakefile Outdated

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.

Release → BUILDTYPE?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Good catch. Let me work on it.

Comment threadtest/common/index.js Outdated

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.

Should this extend LD_LIBRARY_PATH instead of replace it? (Same for LIBPATH and DYLD_LIBRARY_PATH below).

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Sure. Let me change to extend these variables.

@yhwang
yhwangforce-pushed the sharedlib-fix-testcase-lib-not-found branch 2 times, most recently from b354c8c to 0295775CompareFebruary 8, 2018 20:06
@yhwang
yhwangforce-pushed the sharedlib-fix-testcase-lib-not-found branch 2 times, most recently from 7318472 to eed929eCompareFebruary 8, 2018 21:46
@BridgeAR

Copy link
Copy Markdown
Member

@BridgeARBridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 10, 2018
@yhwang

Copy link
Copy Markdown
MemberAuthor

failed on a flaky test case: test_callback_scope/test-resolve-async. It means the CI should be good for this PR.

Comment threadtest/common/index.js Outdated

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 is currently not used at all, right? If so, I would rather remove it again.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

sure!

Comment threadtest/common/index.js Outdated

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.

Since this is only going to be called rarely, I feel like it would be better to move this to a separate file.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

move to a file which both test-child-process-fork-exec-path and test-module-loading-globalpaths can access? not familiar with the directory structure of the testing suites, any suggestion?

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.

There is for example test/common/countdown.js. Similar to that you can just add another file.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

@BridgeAR I moved the function to a new file: shared-lib-util.js

When building the node with `--shared` option, the major output is the
shared library. However, we still build a node executable which links
to the shared lib. It's for testing purpose. When testing with the
executable, some test cases move/copy the executable, change the relative
path to the shared library and fail. Using lib path env would solve the
issue. However, in macOS, need to change the install name for the shared
library and use rpath in the executable. In AIX, `-brtl` linker option
rebinds the symbols in the executable and addon modules could use them.
Signed-off-by: Yihong Wang <yh.wang@ibm.com>
@yhwang
yhwangforce-pushed the sharedlib-fix-testcase-lib-not-found branch from eed929e to b6f1ae3CompareFebruary 13, 2018 00:32

@BridgeARBridgeAR 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.

LGTM

@yhwang

Copy link
Copy Markdown
MemberAuthor

May I have another CI to verify this PR again after I refactor the function to a separated js file?

@mhdawson

Copy link
Copy Markdown
Member

@yhwang

Copy link
Copy Markdown
MemberAuthor

Only failed on pi1. However, on those 6 runs on pi1. 2 runs passed! (If I interpret the results correctly.)

@richardlaurichardlau mentioned this pull request Feb 16, 2018
2 tasks
@BridgeAR

Copy link
Copy Markdown
Member

Landed in ec9e792 🎉

BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Feb 16, 2018
When building the node with `--shared` option, the major output is the
shared library. However, we still build a node executable which links
to the shared lib. It's for testing purpose. When testing with the
executable, some test cases move/copy the executable, change the
relative path to the shared library and fail. Using lib path env would
solve the issue. However, in macOS, need to change the install name for
the shared library and use rpath in the executable. In AIX, `-brtl`
linker option rebinds the symbols in the executable and addon modules
could use them.
Signed-off-by: Yihong Wang <yh.wang@ibm.com>
PR-URL: nodejs#18626
Refs: nodejs#18535
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@yhwang
yhwang deleted the sharedlib-fix-testcase-lib-not-found branch February 16, 2018 17:14
MylesBorins pushed a commit that referenced this pull request Feb 21, 2018
When building the node with `--shared` option, the major output is the
shared library. However, we still build a node executable which links
to the shared lib. It's for testing purpose. When testing with the
executable, some test cases move/copy the executable, change the
relative path to the shared library and fail. Using lib path env would
solve the issue. However, in macOS, need to change the install name for
the shared library and use rpath in the executable. In AIX, `-brtl`
linker option rebinds the symbols in the executable and addon modules
could use them.
Signed-off-by: Yihong Wang <yh.wang@ibm.com>
PR-URL: #18626
Refs: #18535
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@MylesBorinsMylesBorins mentioned this pull request Feb 21, 2018
MylesBorins pushed a commit that referenced this pull request Feb 21, 2018
When building the node with `--shared` option, the major output is the
shared library. However, we still build a node executable which links
to the shared lib. It's for testing purpose. When testing with the
executable, some test cases move/copy the executable, change the
relative path to the shared library and fail. Using lib path env would
solve the issue. However, in macOS, need to change the install name for
the shared library and use rpath in the executable. In AIX, `-brtl`
linker option rebinds the symbols in the executable and addon modules
could use them.
Signed-off-by: Yihong Wang <yh.wang@ibm.com>
PR-URL: #18626
Refs: #18535
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
When building the node with `--shared` option, the major output is the
shared library. However, we still build a node executable which links
to the shared lib. It's for testing purpose. When testing with the
executable, some test cases move/copy the executable, change the
relative path to the shared library and fail. Using lib path env would
solve the issue. However, in macOS, need to change the install name for
the shared library and use rpath in the executable. In AIX, `-brtl`
linker option rebinds the symbols in the executable and addon modules
could use them.
Signed-off-by: Yihong Wang <yh.wang@ibm.com>
PR-URL: nodejs#18626
Refs: nodejs#18535
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@MylesBorins

MylesBorins commented Aug 7, 2018

Copy link
Copy Markdown
Contributor

Should this be backported to v8.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

edit: got it to land

MylesBorins pushed a commit that referenced this pull request Aug 7, 2018
When building the node with `--shared` option, the major output is the
shared library. However, we still build a node executable which links
to the shared lib. It's for testing purpose. When testing with the
executable, some test cases move/copy the executable, change the
relative path to the shared library and fail. Using lib path env would
solve the issue. However, in macOS, need to change the install name for
the shared library and use rpath in the executable. In AIX, `-brtl`
linker option rebinds the symbols in the executable and addon modules
could use them.
Signed-off-by: Yihong Wang <yh.wang@ibm.com>
PR-URL: #18626
Refs: #18535
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@yhwang

Copy link
Copy Markdown
MemberAuthor

@MylesBorins thanks.

MylesBorins pushed a commit that referenced this pull request Aug 7, 2018
When building the node with `--shared` option, the major output is the
shared library. However, we still build a node executable which links
to the shared lib. It's for testing purpose. When testing with the
executable, some test cases move/copy the executable, change the
relative path to the shared library and fail. Using lib path env would
solve the issue. However, in macOS, need to change the install name for
the shared library and use rpath in the executable. In AIX, `-brtl`
linker option rebinds the symbols in the executable and addon modules
could use them.
Signed-off-by: Yihong Wang <yh.wang@ibm.com>
PR-URL: #18626
Refs: #18535
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
MylesBorins pushed a commit that referenced this pull request Aug 9, 2018
When building the node with `--shared` option, the major output is the
shared library. However, we still build a node executable which links
to the shared lib. It's for testing purpose. When testing with the
executable, some test cases move/copy the executable, change the
relative path to the shared library and fail. Using lib path env would
solve the issue. However, in macOS, need to change the install name for
the shared library and use rpath in the executable. In AIX, `-brtl`
linker option rebinds the symbols in the executable and addon modules
could use them.
Signed-off-by: Yihong Wang <yh.wang@ibm.com>
PR-URL: #18626
Refs: #18535
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@MylesBorinsMylesBorins mentioned this pull request Aug 16, 2018
MylesBorins pushed a commit that referenced this pull request Aug 16, 2018
When building the node with `--shared` option, the major output is the
shared library. However, we still build a node executable which links
to the shared lib. It's for testing purpose. When testing with the
executable, some test cases move/copy the executable, change the
relative path to the shared library and fail. Using lib path env would
solve the issue. However, in macOS, need to change the install name for
the shared library and use rpath in the executable. In AIX, `-brtl`
linker option rebinds the symbols in the executable and addon modules
could use them.
Signed-off-by: Yihong Wang <yh.wang@ibm.com>
PR-URL: #18626
Refs: #18535
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.buildIssues and PRs related to build files or the CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@yhwang@BridgeAR@mhdawson@MylesBorins@addaleax@richardlau@nodejs-github-bot