-
Notifications
You must be signed in to change notification settings - Fork 63
cmake: unify GCC, Clang and PNaCl compiler configuration #1197
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
Conversation
- unify GCC, Clang and PNaCl compiler configuration - pass more build options to the sub-cmake game build - always set C standard, it will be required for building zlib with Saigo or Wasi - add options to not enforce C/C++ standards - move the target specific build options to another if/else block
Now PNaCl uses the same configuration as GCC and Clang, avoids discrepancies like this to be introduced: This also make possible to pass build options like LTO to the sub-cmake game call. I'm not sure it really does something with PNaCl as the produced files are the same size (and LTO usually makes our binaries much smaller), but the compiler accepts the option so, it's not bad to pass it. It will be ready for other compilers like Saigo or Wasi. The C standard is now always enforced, it was required for NaCl because NaCl uses some in-tree zlib source. It makes possible to use an in-tree zlib for things other than PNaCl, something we would want for Saigo or Wasi. And if we ship an own zlib, there is no reason to not build the engine against it. The usage or the in-tree zlib for every binary is not part of that PR, but this PR makes the CMake code ready for it. Also, for debugging purpose, one can disable the C/C++ standard enforcement with advanced |
28b8504
to
83e7281
Compare
I forgot to mention it, but this also makes explicit the optimization level used for the selected build profile. In the future I plan to make |
Well, this is probably a bad idea, even if someday we override them. The reason why I went this way was because the NaCl code path as doing it, so when I unified it with other compilers, I thought “why not?”. It happens the NaCl code path doing it is a workaround for CMake failing to detect that PNaCl is a clang-compatible compiler. We better want to rely on extensive compiler detection as implemented in #982 to set the fallbacks for every clang-compatible compiler we detect: So for now I'll revert the unconditional setting of compiler optimizations and keep the |
39c18bd
to
a4b5c8d
Compare
Why should there be an option not to use the appropriate language standard? I don't get it. Maybe it was useful one time, but not everything needs to be a checkbox option, if someone needs to do something really obscure they can edit the build system. |
a4b5c8d
to
5468d65
Compare
Generic answer: I like knobs. Specific answers:
|
cmake/DaemonFlags.cmake
Outdated
# || _BSD_SOURCE || _SVID_SOURCE || _GNU_SOURCE | ||
# isascii: | ||
# _XOPEN_SOURCE || _DEFAULT_SOURCE || _SVID_SOURCE | ||
add_definitions(-D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=500) |
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.
What platform is this stuff needed on?
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.
With -std=c++14
instead of -std=gnu++14
.
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 would understand -DUSE_RECOMMENDED_C_STANDARD=0 as telling the build system to get out of the way and not set any C standard flags. I oppose having it mean keep setting language standard flags, but it a different way.
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.
The code now only sets GNU dialects.
cmake/DaemonFlags.cmake
Outdated
if (USE_HARDENING) | ||
message(STATUS "Enabling hardening") | ||
|
||
# PNaCl accepts the flags bug do not define __stack_chk_guard and __stack_chk_fail. |
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.
Typos, but does not
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.
Fixed.
cmake/DaemonFlags.cmake
Outdated
|
||
# Link-time optimizations. | ||
if (USE_LTO) | ||
message(STATUS "Enabling link time optimizations") |
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.
The combination of adding these verbose messages, and passing unimplemented-in-NaCl build options such as USE_ARCH_INTRINSICS or USE_LTO to the NaCl build is unfortunate. It just causes the sub-build to lie with false messages such "Enabling link time optimizations"
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 removed the “Enabling link time optimizations” message, it was not saying the feature was enabled but the user asked for it so it was wrong anyway.
Passing the USE_LTO
option doesn't sound problematic. If the compiler lies about supporting LTO, it's not our fault. I also turned the flto
setting as a “try”, so even setting USE_LTO
on compilers that would reject the flag wouldn't break the build, and CMake will report the status. PNaCl will lie but that's not our problem.
The USE_ARCH_INTRINSICS
would make sense the day we use Wasm, as Wasm support some kind of SIMD. Right now it's a bit useless for PNaCL but PNaCl not doing anything with it doesn't mean it's wrong to pass the option, in case the toolchain can do something with it.
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.
USE_LTO
is not passed anymore to the NACL sub-cmake invocation, also the option is ignored if for some reason the option is passed (like doing some manual stuff). After investigation, it happens that neither PNaCl's underlying clang nor Saigo clang support the -flto
option. It happens that the pnacl-clang
wrapper accepts the option but I don't see how it would do something with it, and the produced binaries are the sames anyway. On Saigo side, clang accepts the option but the link fails (the LTO linker plugin probably doesn't support the NaCl bitcode to begin with).
Having a knob that makes the program fail to build kinda sucks. But on the other hand, it sucks that there is often no way to disable all the flags added by our build system, like you could with something like |
5468d65
to
a508b0a
Compare
a508b0a
to
d70ac44
Compare
I moved the setting of PNaCl default build flag to the PNaCl toolchain itself. It makes much sense like that. I haven't set the |
130a688
to
0a35127
Compare
7e0bf64
to
4fa40eb
Compare
This now looks ready to me. |
LGTM |
Uh oh!
There was an error while loading. Please reload this page.