FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

build: fix building with ninja by richardlau · Pull Request #32071 · nodejs/node · GitHub

/ node Public

build: fix building with ninja - #32071

Merged
richardlau merged 1 commit into
nodejs:masterfrom
richardlau:largepages
Mar 4, 2020
Merged

build: fix building with ninja#32071
richardlau merged 1 commit into
nodejs:masterfrom
richardlau:largepages

Conversation

Copy link
Copy Markdown
Member

The ninja build places objects in a different directory.

Refs: #31981 (comment)

cc @gabrielschulhof

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

nodejs-github-bot added the build Issues and PRs related to build files or the CI. label Mar 3, 2020

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Contributor

richardlau added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Mar 3, 2020

gabrielschulhof 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This breaks on Ubuntu 18.04.

Copy link
Copy Markdown
Contributor

The file given needs to be the object file, not the static library.

richardlau removed the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Mar 3, 2020

Copy link
Copy Markdown
Contributor

... and it needs to be the first file given to the linker.

Copy link
Copy Markdown
Contributor

I mean, if you build with this change, it fails to find the mapping for large pages – probably because the value of __node_text_start is 0x0000000000000000, because the symbol is not linked in. That's why the object file needs to be passed to the linker directly, not via the static library.

Copy link
Copy Markdown
Contributor

Is there a gyp variable holding the directory where object files are placed?

Copy link
Copy Markdown
Member Author

Is there a gyp variable holding the directory where object files are placed?

<obj_dir>, but the location of the object files under that appear different when using ninja vs. make.

node/common.gypi

Lines 88 to 94 in 3d894d0

['GENERATOR == "ninja"', {
'obj_dir': '<(PRODUCT_DIR)/obj',
'v8_base': '<(PRODUCT_DIR)/obj/tools/v8_gypfiles/libv8_snapshot.a',
}, {
'obj_dir%': '<(PRODUCT_DIR)/obj.target',
'v8_base': '<(PRODUCT_DIR)/obj.target/tools/v8_gypfiles/libv8_snapshot.a',
}],

Copy link
Copy Markdown
Contributor

@richardlau oh, so ninja doesn't do src/large_pages/node_text_start.o, meaning that it's the same as the path to the source file, but with .o?

Copy link
Copy Markdown
Contributor

@richardlau we should then be able to use a condition like the one above to switch between the two paths, right?

Copy link
Copy Markdown
Member Author

@richardlau we should then be able to use a condition like the one above to switch between the two paths, right?

I'm testing that right now.

Copy link
Copy Markdown
Contributor

@richardlau can you also manually run node --use-largepages=on? It should not output failed to find text region.

Copy link
Copy Markdown
Contributor

The test that runs node --use-largepages=on cannot be made to expect quiet on stderr, because mapping is fairly platform-dependent, and failure to map must not be fatal to the execution. Thus, the test only tests that Node.js successfully runs with the flag, not that it successfully maps with the flag.

Copy link
Copy Markdown
Member Author

@richardlau can you also manually run node --use-largepages=on? It should not output failed to find text region.

I don't think my Linux environment has support for large pages (it prints Large pages are not enabled.).

Copy link
Copy Markdown
Contributor

@richardlau

echo madvise > /sys/kernel/mm/transparent_hugepage/enabled

Copy link
Copy Markdown
Member Author

@richardlau

echo madvise > /sys/kernel/mm/transparent_hugepage/enabled

@gabrielschulhof It's a shared development server so I almost certainly don't have permissions to do that.

Copy link
Copy Markdown
Contributor

@richardlau OK, no problem. I can test on my machine when you push to this PR.

Copy link
Copy Markdown
Contributor

@richardlau another good check is to examine the

g++ -o /home/nix/node/node/out/Release/node -pthread -rdynamic -m64 -Wl,--whole-archive...

line at the end of the build to make sure that node_text_start.o is the first file listed.

Copy link
Copy Markdown
Contributor

@richardlau testing ...

Copy link
Copy Markdown
Member Author

FTR with Ninja it looks like the object file is written to <(obj_dir)/src/large_pages/node_text_start.node_text_start.o.

with make:

  g++ -o /home/users/riclau/sandbox/github/nodejs/out/Release/node -pthread -rdynamic -m64 -Wl,--whole-archive /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/libnode.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_base_without_compiler.a -Wl,--no-whole-archive /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/node_text_start/src/large_pages/node_text_start.o -Wl,--whole-archive /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/deps/zlib/libzlib.a -Wl,--no-whole-archive -Wl,--whole-archive /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/deps/uv/libuv.a -Wl,--no-whole-archive -Wl,-z,noexecstack -Wl,--whole-archive /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_snapshot.a -Wl,--no-whole-archive -Wl,-z,relro -Wl,-z,now -Wl,--whole-archive,/home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/deps/openssl/libopenssl.a -Wl,--no-whole-archive -pthread  -Wl,--start-group /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/node/src/node_main.o /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/node/gen/node_code_cache.o /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/node/gen/node_snapshot.o /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/deps/histogram/libhistogram.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/deps/uvwasi/libuvwasi.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/libnode.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/libnode_text_start.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_libplatform.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/tools/icu/libicui18n.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/deps/zlib/libzlib.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/deps/llhttp/libllhttp.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/deps/cares/libcares.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/deps/uv/libuv.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/deps/nghttp2/libnghttp2.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/deps/brotli/libbrotli.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/deps/openssl/libopenssl.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_base_without_compiler.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/tools/icu/libicuucx.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/tools/icu/libicudata.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_libbase.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_libsampler.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_compiler.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_snapshot.a /home/users/riclau/sandbox/github/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_initializers.a -lm -ldl -Wl,--end-group

and with ninja:

[60/60] c++ -pthread -rdynamic -m64 -Wl,--whole-archive obj/libnode.a obj/tools/v8_gypfiles/libv8_base_without_compiler.a -Wl,--no-whole-archive obj/src/large_pages/node_text_start.node_text_start.o -Wl,--whole-archive obj/deps/zlib/libzlib.a -Wl,--no-whole-archive -Wl,--whole-archive obj/deps/uv/libuv.a -Wl,--no-whole-archive -Wl,-z,noexecstack -Wl,--whole-archive obj/tools/v8_gypfiles/libv8_snapshot.a -Wl,--no-whole-archive -Wl,-z,relro -Wl,-z,now -Wl,--whole-archive,obj/deps/openssl/libopenssl.a -Wl,--no-whole-archive -pthread -o node -Wl,--start-group obj/gen/node.node_code_cache.o obj/gen/node.node_snapshot.o obj/src/node.node_main.o obj/deps/histogram/libhistogram.a obj/deps/uvwasi/libuvwasi.a obj/libnode.a obj/libnode_text_start.a obj/tools/v8_gypfiles/libv8_libplatform.a obj/tools/icu/libicui18n.a obj/deps/zlib/libzlib.a obj/deps/llhttp/libllhttp.a obj/deps/cares/libcares.a obj/deps/uv/libuv.a obj/deps/nghttp2/libnghttp2.a obj/deps/brotli/libbrotli.a obj/deps/openssl/libopenssl.a obj/tools/v8_gypfiles/libv8_base_without_compiler.a obj/tools/icu/libicuucx.a obj/tools/icu/libicudata.a obj/tools/v8_gypfiles/libv8_libbase.a obj/tools/v8_gypfiles/libv8_libsampler.a obj/tools/v8_gypfiles/libv8_compiler.a obj/tools/v8_gypfiles/libv8_snapshot.a obj/tools/v8_gypfiles/libv8_initializers.a  -lm -ldl -Wl,--end-group

gabrielschulhof commented Mar 4, 2020
edited
Loading

Copy link
Copy Markdown
Contributor

@richardlau argh! This works, but the command line changes:

g++
-o
/home/gschulho/node/out/Release/node
-pthread
-rdynamic
-m64
-Wl,--whole-archive
/home/gschulho/node/out/Release/obj.target/libnode.a
/home/gschulho/node/out/Release/obj.target/tools/v8_gypfiles/libv8_base_without_compiler.a
-Wl,--no-whole-archive
/home/gschulho/node/out/Release/obj.target/node_text_start/src/large_pages/node_text_start.o

so the textobject file gets placed after libnode.a and libv8_base_without_compiler.a and so the usefulness of the symbol is greatly diminished because it comes a lot later in the game. I don't understand why the switch to a condition has such a terrible effect.

I would like to test putting the condition in the variables section so that we can add the ldflags+ unconditionally. Maybe that'll please The GYP King™ 🤷

Copy link
Copy Markdown
Contributor

Pushed one more minor change – to remove the trailing comma, thereby removing a superfluous diff.

Copy link
Copy Markdown
Collaborator

richardlau added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Mar 4, 2020

MylesBorins 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

Copy link
Copy Markdown
Contributor

should this be fast-tracked?

MylesBorins added the fast-track PRs that do not need to wait for 48 hours to land. label Mar 4, 2020

Copy link
Copy Markdown
Contributor

@MylesBorins I guess it does break the GitHub action, so it's probably a good idea.

The ninja build places objects in a different directory.

Co-authored-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
Signed-off-by: Richard Lau <riclau@uk.ibm.com>

PR-URL: nodejs#32071
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>

Copy link
Copy Markdown
Member Author

Landed in de6cbd0.

richardlau merged commit de6cbd0 into nodejs:master Mar 4, 2020
richardlau deleted the largepages branch March 4, 2020 05:00
MylesBorins pushed a commit that referenced this pull request Mar 4, 2020
The ninja build places objects in a different directory.

Co-authored-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
Signed-off-by: Richard Lau <riclau@uk.ibm.com>

PR-URL: #32071
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
MylesBorins mentioned this pull request Mar 4, 2020
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this pull request Mar 6, 2020
The ninja build places objects in a different directory.

Co-authored-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
Signed-off-by: Richard Lau <riclau@uk.ibm.com>

PR-URL: nodejs#32071
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this pull request Apr 9, 2020
The ninja build places objects in a different directory.

Co-authored-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
Signed-off-by: Richard Lau <riclau@uk.ibm.com>

PR-URL: nodejs#32071
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>

targos commented Apr 20, 2020

Copy link
Copy Markdown
Member

Depends on #31981 to land on v12.x

targos added backported-to-v12.x and removed author ready PRs that have at least one approval, no outstanding review comments, and a CI started. backport-blocked-v12.x labels Apr 25, 2020
targos pushed a commit to targos/node that referenced this pull request Apr 25, 2020
The ninja build places objects in a different directory.

Co-authored-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
Signed-off-by: Richard Lau <riclau@uk.ibm.com>

Backport-PR-URL: nodejs#32092
PR-URL: nodejs#32071
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
targos pushed a commit that referenced this pull request Apr 28, 2020
The ninja build places objects in a different directory.

Co-authored-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
Signed-off-by: Richard Lau <riclau@uk.ibm.com>

Backport-PR-URL: #32092
PR-URL: #32071
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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. fast-track PRs that do not need to wait for 48 hours to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants


Back | FazBrowse Home | New Git URL