-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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,win: configuration tweaks for faster build with MSVC #25931
Conversation
P.S. this also reduce divergence between "dev" builds (no LTCG) and "release" builds (with LTCG), as now they both use pch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was not using PCH by default as it carries some risk. It makes the build very different from other platforms (the headers are the same for all files, ignoring defines) and gives the compiler different opportunities for optimization. Since now it has been in use for some time, it's probably a good time to make it default.
src/node_pch.h
Outdated
@@ -0,0 +1,15 @@ | |||
#pragma once | |||
#define NAPI_EXPERIMENTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this always safe? I see in some files where this is defined other headers are included before. With this here, NAPI_EXPERIMENTAL
will always be defined, can probably be removed from everywhere in the code.
There is also NODE_WANT_INTERNALS
. There is and explicit define in inspector_socket.cc
which will be ignored by all headers pulled by these here.
This might be safe, but is not obvious to me. Might also become difficult to maintain, since anyone not using Windows will only see errors when running CI (if at all).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
This should probably be semver major to be safe. I don't expect anything to break, but wouldn't be surprised if there were differences compiling modules or with performance. In my benchmarking of the PCH we have now, I noticed somethings were faster and some slower, by small margins, and I'm not sure how conclusive that was. @bzoz can you take a look at the linking changes here? |
395d5a1
to
cfbde88
Compare
So on windows run |
🤞 that's the dream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but it'd be good to have confirmation that there's no issue with the NODE_WANT_INTERNALS
define in inspector_socket.cc
. Thanks @refack!
Since there should not be any explicit breaking changes, maybe we can commute the /CC @nodejs/tsc tl;dr this cuts build time on Windows by ~70% |
SGTM |
SGTM. I added it, so I went ahead and changed it. Actually only the commit |
cfbde88
to
86c985d
Compare
* ASCIIbetize directives * Merge duplicate directives from 'conditions' PR-URL: nodejs#25931 Reviewed-By: João Reis <[email protected]>
* Use relative path for easy reuse in other projects PR-URL: nodejs#25931 Reviewed-By: João Reis <[email protected]>
* rename files to represent reuse PR-URL: nodejs#25931 Reviewed-By: João Reis <[email protected]>
PR-URL: nodejs#25931 Reviewed-By: João Reis <[email protected]>
PR-URL: nodejs#25931 Reviewed-By: João Reis <[email protected]>
PR-URL: nodejs#25931 Reviewed-By: João Reis <[email protected]>
PR-URL: nodejs#25931 Reviewed-By: João Reis <[email protected]>
86c985d
to
2ffd20b
Compare
@refack this change moved the configuration of Without ltcg (current change): With ltcg added to node-gyp addon.gypi: Would it make sense to add this definition to node-gyp rather than common.gypi so that even Electron and other embedders could benefit from this ? Thanks! This was found while investigating electron/electron#18670 |
@nodejs/platform-windows @nodejs/node-gyp @nodejs/embedders |
Discussion is in #29501. |
Several optimization to reduce build time on Windows.
node.exe
target..h
files to pch for V8IIUC the reason not to build V8 with pch was as not to diverge, but V8 is anyway built with clang_cl and not with the MSVC compiler, so divergence exists anyway.
Total build time on https://ci.nodejs.org/computer/test-rackspace-win2008r2-x64-3/:
/CC @nodejs/build-files @nodejs/platform-windows @nodejs/v8-update
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes