-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix some clang-cl warnings regarding unused parameters #8
Conversation
occur because we try to compile C code as C++17.
@@ -18,14 +18,15 @@ | |||
'conditions': [ | |||
['target_arch in "ia32 x64" and OS!="ios"', { | |||
'defines': [ 'ADLER32_SIMD_SSSE3' ], | |||
'cflags': [ '-mssse3' ], |
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.
@anonrig Would you happen to know why these variables (cflags, cflags_cpp) don't take hold here even though we are building under Windows with x64.
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.
I think it's a GYP issue. It was never meant to support Clang on Windows AFAIK and cflags are passed differently for it. See c1d1878
@@ -78,6 +78,7 @@ | |||
'include_dirs': [ 'base64/include', 'base64/lib' ], | |||
'sources': [ 'base64/lib/arch/ssse3/codec.c' ], | |||
'defines': [ 'BASE64_STATIC_DEFINE', 'HAVE_SSSE3=1' ], | |||
'cflags_cpp': [], |
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.
Do these work? What are the fixed warnings?
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.
Without these, you are passing-std=c++17 to clang-cl when compiling C code. The better solution would be for the build engine to recognize that it is compiling C code, and not pass the C++ flags.
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.
I'm surprised that it works because I don't see any occurence of cflags_cpp
in the code base (including the source code of GYP)
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.
You are correct. It should be cflags_cc.
I think this comes from common.gypi: |
Yes. And that flag looks fine to me. The issue is that it gets applied when clang-cl builds C code. Node has several C dependencies and they are the ones that appear most broken right now. Short of making the build engine smarter, I propose to clear the C++ flags when within a C dependency. It does not quite work perfectly because, as we have observed, some flags do not get applied under clang-cl when it seems they should. This issue leads to breakage having to do with SIMD instructions. The better solution would be to fix the build engine so that it actually supports clang-cl as a first class compiler. |
Basically this PR gets you closer to building under clang-cl without warnings and errors because it manually removes the unnecessary C++ flags within C projects. I think that you pretty much need to do this if fixing GYP is not an option. |
I understand what you're trying to do but what I understand of GYP is that it ignores |
Checkout my PR and run it. It will take you a minute. It works! It drastically reduces the volume of warnings. It is a verifiable statement, you can check. |
To put it another way, GYP does not ignore all of these changes, just a couple. |
First warning I see (clean clone with this patch applied):
Then a lot more in uvwasi and zlib |
With a fresh build? That's intriguing. |
Please see nodejs#35433 (comment) I think that there is a fundamental problem that should be solved and that what I am proposing here is wrong. Closing. |
@targos Note that the approach illustrated by this PR does work. You do get rid of the warnings when setting It is a hack, however. I don't recommend it. |
They occur because we try to compile C code as C++17. The
-std=c++17
flag should not be used when compiling C code. A quickfix is to setcflags_cc=[]
in C dependencies. It clears the C++ flags.Interestingly, it illustrates that the following configuration...
is not triggered. So you get both a build error because you are missing SSSE3, but also a visible warning.
I am sure that it is quite trivial.