-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Support building with win-clang #19630
Comments
/cc @targos |
/cc @nodejs/platform-windows |
How can we solve this? |
Good question. One of the reasons for moving off gyp is scenarios like this where new toolchains are not supported. I guess implementing support for ninja with clang on Windows would be a way. It might be not all that complicated, if clang on Windows works the same way as clang on linux. |
You mean implementing it in gyp? |
I suspect this already works when you use clang-cl, the cl.exe compatible driver. Untested, but # ...
'make_global_settings': {
'CC': '/path/to/clang-cl', # or just 'clang-cl' if it's on the path
'CXX': '/path/to/clang-cl', # ditto
}
# ... |
bnoordhuis's comment is correct, except you don't need to set CXX since the ninja generator doesn't look at that in msvc compat mode (cf https://chromium.googlesource.com/external/gyp/+/e540e6ab6291d4e63f262c8169ef0d0aae11dbec / https://codereview.chromium.org/147083011 for how we hooked up clang-cl in the Chromium gyp win build back in the day). |
The amazing @agrieve from the Chrome team has come up with this PR (against the fork of Node.js that V8 is maintaining) to make building with Clang on Windows work! We could use some feedback on whether this way to build works well for everyone, similar to when I initially implemented the |
Although as @bnoordhuis mentions there are workarounds for cmake/ninja/GYP/Windows, I'll look into getting that to work out of the box.
|
My interpretation is that having alternatives is always great :) |
So if this doesn't remove the dependency on Visual Studio, the only benefit would be that we'd have to do this at some point if V8 drop support for MSVC? |
FWIW we have a fork of Node that can fully build with It still requires Visual Studio and some dependencies to be installed. The benefit of that build is that the gyp-gn bridge works on that build. I.e. gyp files do not need to be maintained when updated to a new V8 version. It is also guaranteed to build if V8 decides to deprecate MSVC support in the future. This is relevant when MSVC and Clang differ in how they interpret C++ syntax. Dependencies:
Build steps:
There is obviously still a bit of a way to go here. What also doesn't work is that add-on tests do not have a ninja target, and Edit: missing dependency. |
The list of dependencies seems incomplete. I'm getting the following error:
I'm also getting a warning on every file, is that a known issue?
|
That might indeed by true. I've seen that error too and solved it by following the hint in the error log, and installed Debugging Tools for Windows. I've seen the same warning too. The issue here is that Clang does not support the whole program optimization flag. V8 files are not affected by this. |
Getting the following error now:
|
Thanks for making it this far! That's the last remaining issue. The fix is here. I wasn't sure whether it's the right fix, which is why I haven't landed it yet. |
It builds now. A few questions:
|
Yup. It's not perfect yet. I'm working on making all of this smoother. You should be able to run tests by using the test script in tools directly. |
NodeCounterProvider is declared as extern but defined as EXTERN_C. This confuses clang-cl. PR-URL: #20436 Refs: #19630 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
NodeCounterProvider is declared as extern but defined as EXTERN_C. This confuses clang-cl. PR-URL: #20436 Refs: #19630 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
NodeCounterProvider is declared as extern but defined as EXTERN_C. This confuses clang-cl. PR-URL: #20436 Refs: #19630 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
NodeCounterProvider is declared as extern but defined as EXTERN_C. This confuses clang-cl. PR-URL: #20436 Refs: #19630 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
So what's the plan now? Are you going to create a PR here? |
I want to figure out how far we can go with reducing the dependencies before upstreaming anything. Also, this is not particularly urgent. |
This is an interesting issue, I'll try to pick it... |
IIUC non googlers can't do that. The docs say "install MSVS and set DEPOT_TOOLS_WIN_TOOLCHAIN=0" But I'm making progress using the "official" prebuilt llvm binaries, and the |
found a bug in V8's |
Original commit message: undef min,max macros on windows This blocks building with official clang-cl and Windows SDK Refs: nodejs#19630 Change-Id: I41fdf934f486c660df7a9e0dd284f6eb3c294dd4 Reviewed-on: https://chromium-review.googlesource.com/c/1297479 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#57053} PR-URL: nodejs#23985 Refs: v8/v8@dc70449 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Original commit message: undef min,max macros on windows This blocks building with official clang-cl and Windows SDK Refs: #19630 Change-Id: I41fdf934f486c660df7a9e0dd284f6eb3c294dd4 Reviewed-on: https://chromium-review.googlesource.com/c/1297479 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#57053} PR-URL: #23985 Refs: v8/v8@dc70449 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This blocks building with official clang-cl and Windows SDK Refs: nodejs/node#19630 Change-Id: I41fdf934f486c660df7a9e0dd284f6eb3c294dd4 Reviewed-on: https://chromium-review.googlesource.com/c/1297479 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#57053}
There's been no further activity on this and it's not clear if it's going to move forward. Closing but we can reopen if necessary |
This is a very necessary feature. MSVC is not an optimized compiler. Can we open this again? |
Chrome and V8 support building with Clang on windows. Node.js should include support for this too.
Benefits:
Blockers:
configure
.ninja
. However,gyp
backend forninja
only supports MSVC.openssl.gyp
requiresllvm_version
to be set.python .\deps\v8\tools\clang\scripts\update.py
.clang-cl.exe
.The text was updated successfully, but these errors were encountered: