-
Notifications
You must be signed in to change notification settings - Fork 30k
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, windows: ignore C4251 & C4275 #15570
Conversation
/cc @nodejs/build @nodejs/platform-windows |
common.gypi
Outdated
# | ||
# Disable "warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'" | ||
# Disable "warning C4275: non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'" | ||
# Many V8 method do not comply with the requirements to be dll exported, |
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.
methods
common.gypi
Outdated
# Disable "warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'" | ||
# Disable "warning C4275: non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'" | ||
# Many V8 method do not comply with the requirements to be dll exported, | ||
# which result in these warnings reported several 1000s times. |
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.
which results in these warnings being reported several thousands of times
Not against doing it, although wouldn't the ideal solution be for the V8 methods to comply with said requirement? Not sure how feasible that is, I guess cc/ @nodejs/v8? |
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.
It would be better to fix the warnings rather than suppress them.
In fact, I suspect they are our own fault. Right now, we unconditionally set BUILDING_V8_SHARED=1
all throughout the build but we should probably define it only while building V8 and define USING_V8_SHARED=1
while building node/cctest/addons.
common.gypi
Outdated
# Disable "warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'" | ||
# Disable "warning C4275: non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'" | ||
# Many V8 methods do not comply with the requirements to be DLL exportable, | ||
# which results in these warnings reported thousands of times. |
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.
Long lines, try to keep them <= 80 columns.
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 with @bnoordhuis' nits fixed
@refack would you want to try to fix this with the suggestion from @bnoordhuis? I think it would be pretty nice to fix the issues instead of skipping those but I am also fine with this as a intermediate step if you do not have the time for that right now. |
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.
Either the warnings should be fixed as @bnoordhuis said, or the comment should explain why we can't (or don't want to) fix them.
Can't use Anyway, I decided to get to the root of this. C4251 is emitted when an exported class has a non-static data member of a non-exported class type. The rationale, as I understand it, is that the user of the exported class could attempt to access (directly, or via an inline member function) a static data member or a non-inline member function of the data member, resulting in a linker error. However, CL.exe's analysis is lacking. I've looked at a dozen instances of C4251 emitted when building node, and all of them were noise. Moreover, fixing them on V8's side would result in boilerplate and/or pointless exports. Examples: Line 4191 in dcb24e3
received_buffers_ is private. It is accessed in the constructor, but it's private. Fixing this would require explicitly instantiating and exporting std::vector<Buffer> .
unused_segments_mutex_ is private and isn't accessed in any inline member functions. Fixing this would require exporting base::Mutex when BUILDING_V8_SHARED is defined (now it's exported when BUILDING_V8_BASE_SHARED is defined).
memory_pressure_level_ is private and isn't accessed in any inline member functions. Fixing this would require explicitly instantiating and exporting base::AtomicValue<MemoryPressureLevel> .Line 224 in fca7e49
thread_local_ is private. It's referenced in several public inline member functions, but only its inline member functions and non-static data members are accessed.
If we want to fix this at the root, then we should get Microsoft to stop emitting C4251 when the data member is private and none of its non-inline member functions or static data members are accessed from any public inline member functions. @refack since you seem to have connections with Microsoft, perhaps you could suggest a preferable route to submit this request? Or if there are any C++ gurus here who can show that the warnings are actually meaningful, I'll be glad to be proven wrong. |
Me? I just have a contact. We have actual MS employees here :) |
Hi @refack ! |
3ac36e0
to
eeda0e5
Compare
re C4251 ... there's only one place that uses NODE_EXTERN in the class definiton, and no other classes use it. Probably the class definition just needs to be fixed? ie remove NODE_EXTERN? |
@solodon4 did you have the chance to look into this any further? @refack @seishun @bnoordhuis even if this gets fixed in Visual Studio 2017 15.6 we should think about maybe suppressing the warnings for older versions. Not everyone is going to use the newest version. What do you think? |
Not opposed. |
It's reasonable to expect an up-to-date toolchain. Plus in this case it's just warnings, it doesn't prevent node from building. |
Personally I wish the headers would just get fixed instead of hiding it with warning disables. |
@BridgeAR it didn't get in with the main train as I was busy with getting the warning level for external headers feature in - I'll post a blog about it in the coming days. This new feature might help you guys with the suppression if you treat V8 headers where the warning happens as external/system. That said - we are still trying to get a couple more bugs fixed in escrow mode for 15.6, so i'll try to sneak it in, but can't promise. Voting on feedback ticket would certainly help bringing it to attention of higher ups and would justify getting it in while in escrow. |
@solodon4 Is there a feedback ticket for this? |
@solodon4 is there anything besides the references issue where feedback could be provided? |
@BridgeAR, the issue is currently tracked by an internal ticket for 15.7. Unfortunately, it didn't get high-enough on the management's radar to be considered for late stages of 15.6. That said, if you'd like to be able to provide an additional information on the issue or be able to vote on it, we'd need a feedback item created on Developer Community's C++ section. Please post the link here if you create the feedback item yourself, otherwise I'll post it when I get around to creating it myself. |
I am closing this due to no further progress and because I doubt that we get to a conclusion. Let us hope this is going to be fixed in 15.7. If others think this should stay open, please leave a comment to reopen / reopen directly. |
Compiling node with vcbuild generates 10,000s of these warnings, originating from v8.h. This makes it impossible to read any other diagnostic messages. Refs: nodejs#15570 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> PR-URL: nodejs#20958
Compiling node with vcbuild generates 10,000s of these warnings, originating from v8.h. This makes it impossible to read any other diagnostic messages. PR-URL: #20958 Refs: #15570 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Compiling node with vcbuild generates 10,000s of these warnings, originating from v8.h. This makes it impossible to read any other diagnostic messages. PR-URL: #20958 Refs: #15570 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Many V8 methods do not comply with the requirements to be DLL-exportable,
which results in these warnings reported several 1000s times during build.
CI: https://ci.nodejs.org/job/node-test-commit/12552/
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
build,windows