Skip to content

build: look for libnode.so in lib subdirectory #58213

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

khardix
Copy link

@khardix khardix commented May 7, 2025

When building with --shared, ninja will output the libnode.so into a {build_dir}/lib directory, not in the root {build_dir}. This fixes the install script to look for it in the correct place.


Found during review of a Fedora rpm, where we apparently been moving the libnode.so manually to the root of the build directory manually this entire time. Let's see if we can stop doing that. 😅

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. python PRs and issues that require attention from people who are familiar with Python. labels May 7, 2025
@khardix
Copy link
Author

khardix commented May 7, 2025

CC @richardlau FYI

@richardlau
Copy link
Member

@khardix Unfortunately the make and ninja generators in gyp use different output directories, and this breaks non-ninja builds.
e.g.

$ tools/install.py --dest-dir /tmp/testinstl --prefix "" install
installing /tmp/testinstl/bin/node
installing /tmp/testinstl/lib/libnode.so.137
Traceback (most recent call last):
  File "/home/rlau/sandbox/github/node/tools/install.py", line 426, in <module>
    run(parse_options(sys.argv[1:]))
  File "/home/rlau/sandbox/github/node/tools/install.py", line 379, in run
    files(options, install)
  File "/home/rlau/sandbox/github/node/tools/install.py", line 185, in files
    action(options, [os.path.join(options.build_dir, 'lib', output_lib)],
  File "/home/rlau/sandbox/github/node/tools/install.py", line 84, in install
    try_copy(options, path, dest)
  File "/home/rlau/sandbox/github/node/tools/install.py", line 73, in try_copy
    return shutil.copy2(source_path, target_path)
  File "/usr/lib64/python3.9/shutil.py", line 444, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib64/python3.9/shutil.py", line 264, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: '/home/rlau/sandbox/github/node/out/Release/lib/libnode.so.137'

Using make instead of ninja and configure --shared, I end up with:

$ find . -type f -name "libnode.so.*"
./out/Release/obj.target/libnode.so.137
./out/Release/.deps/home/rlau/sandbox/github/node/out/Release/obj.target/libnode.so.137.d
./out/Release/.deps/home/rlau/sandbox/github/node/out/Release/libnode.so.137.d
./out/Release/libnode.so.137
$

I'm not sure if there's an easy way for install.py to know whether ninja was used. If configure is passed --ninja then I believe the generated config.mk will contain

BUILD_WITH=ninja

(BUILD_WITH will not be present there at all if --ninja is NOT passed to configure).

@khardix
Copy link
Author

khardix commented May 7, 2025

Thanks for the analysis; I'll try to take another look at this next week (we have holidays in Czechia this one).

Copy link
Member

@richardlau richardlau left a comment

Choose a reason for hiding this comment

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

Requesting changes as per #58213 (comment) (since this now has an approval).

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. needs-ci PRs that need a full CI run. python PRs and issues that require attention from people who are familiar with Python.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants