-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Refactor native build to remove the compiler-override files #23897
Conversation
a6bd683
to
3fe5254
Compare
Move CMAKE_EXPORT_COMPILE_COMMANDS to top level instead of in gen-buildsys-*. Define the CMake install prefix in gen-buildsys-* instead of pulling from an environment variable. Define C++ standard as CMake property instead of as flag. Move CLR_DEFINES_*_INIT out of overrides and into configurecompiler.cmake Move flags that generate debug info into configurecompiler.cmake Remove the CMAKE_USER_RULES_OVERRIDE files. Add cmake version output for determining what cmake versions each CI system has. Fix syntax in gen-buildsys-clang. Change add_compile_definitions back to add_definitions Add -D prefix for adding definitions via add_definitions Remove extraneous double-quote Change default config definition adding to the syntax in master Switch back to old CMAKE_<LANG>_FLAGS way of setting the language standards and try to go back to 2.8.12 minimum Switch back setting compile definitions for non-Windows branch too. Use SET with CMAKE_<LANG>_FLAGS. Convert some usages of appending to CMAKE_<LANG>_FLAGS to add_compile_options where possible. Set CMAKE_<LANG>_FLAGS_INIT instead of CMAKE_<LANG>_FLAGS Make sure configureopimitzation.cmake is included correctly in test build. Try to add brackets to get the Linux ARM compilation working correctly. Define standard language version in configurecompiler.cmake instead of root CMakeLists (so tests get it) Try to move langauge standard check to configure.cmake define language standard in each root CMakeLists.txt Fix off-Windows test build. Set CMAKE_EXPORT_COMPILE_COMMANDS after the project() call
bf730d5
to
7bb015e
Compare
…lds after building on a branch that had it set to a path.
…about on C files.
…to add_compile_options
I think I want to do a build with gcc on this pull request when it comes to finalizing stage. Please let me know. |
@franksinankaya can you do a build with GCC? |
96% compiled successfully. "-Werror=conversion-null" doesn't seem to propagate for some reason. src/ToolBox/SOS/Strike/strike.cpp:14788:24: error: converting to non-pointer type ‘TADDR {aka long unsigned int}’ from NULL [-Werror=conversion-null] You can clone this repo and build with ./build.sh -gcc https://github.com/franksinankaya/coreclr/tree/cmake-cleanup to reproduce. |
@franksinankaya looks like that one was another precedence issue between CMAKE_CXX_FLAGS and add_compile_options. I've pushed out a fix. Let me know if it works for you. |
Thanks this version worked. |
@janvorli can you take another review pass? |
tests/CMakeLists.txt
Outdated
include(${CMAKE_CURRENT_SOURCE_DIR}/../configurecompiler.cmake) | ||
if (NOT WIN32) | ||
set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} -std=c++11" CACHE STRING "Flags used by the compiler during all build types.") | ||
set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -std=c11" CACHE STRING "Flags used by the compiler during all build types.") |
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 only C11 feature used in CoreCLR is _Static_assert
in src/corefx/System.Globalization.Native/pal_compiler.h
. The rest of libunwind, Globalization and few other C source files are gnu99 compatible (c99 plus GNU extensions: named variadic macros and statement expressions etc.). However, -pedantic
ally, I think we need -std=gnu11 -pedantic -Wno-gnu -Wno-variadic-macros -Wno-format-pedantic -Wno-pointer-arith -Wno-keyword-macro
for C in CoreCLR.
CoreFX uses gnu99 (the initial reason was: mono compatibility) but the code has C11's _Generic
as well as _Static_assert
, which makes it non-conforming to the compiler's -std
flag. IMO, we should select the minimal standard that is actually used by the code (-pedantic
highlights where we violate the conformance).
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 _Static_assert
is optional in both coreclr and corefx (we check if it exists and if not, we use another way). As for the _Generic
in corefx, you are right.
I would not change this stuff in this change though.
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.
Sure, btw I have this fixed in ongoing solaris port branch, I will rebase once this PR is merged.
gcc 7 on SmartOS amd64 throws the following error on building Globalization target with -std=c11
, which gets fixed with -std=gnu99
or -std=gnu11
flag (without changing the code or other flags):
/datadrive/projects/coreclr/src/corefx/System.Globalization.Native/pal_calendarData.c:84:9: error: implicit declaration of function 'strcasecmp'; did you mean 'u_strcasecmp'? [-Werror=implicit-function-declaration]
if (strcasecmp(calendarName, GREGORIAN_NAME) == 0)
^~~~~~~~~~
u_strcasecmp
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.
That warning I would think is actually a problem you should look at fixing (the declaration of strcasecmp
isn't found anywhere) even though the "implicit definition" behavior happens to match the signature.
… into cmake-cleanup
@janvorli any more feedback on this PR? |
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, thank you!
…oreclr#23897) * On systems that have both cmake 2 and cmake 3, use cmake 3. Move CMAKE_EXPORT_COMPILE_COMMANDS to top level instead of in gen-buildsys-*. Define the CMake install prefix in gen-buildsys-* instead of pulling from an environment variable. Define C++ standard as CMake property instead of as flag. Move CLR_DEFINES_*_INIT out of overrides and into configurecompiler.cmake Move flags that generate debug info into configurecompiler.cmake Remove the CMAKE_USER_RULES_OVERRIDE files. Add cmake version output for determining what cmake versions each CI system has. Fix syntax in gen-buildsys-clang. Change add_compile_definitions back to add_definitions Add -D prefix for adding definitions via add_definitions Remove extraneous double-quote Change default config definition adding to the syntax in master Switch back to old CMAKE_<LANG>_FLAGS way of setting the language standards and try to go back to 2.8.12 minimum Switch back setting compile definitions for non-Windows branch too. Use SET with CMAKE_<LANG>_FLAGS. Convert some usages of appending to CMAKE_<LANG>_FLAGS to add_compile_options where possible. Set CMAKE_<LANG>_FLAGS_INIT instead of CMAKE_<LANG>_FLAGS Make sure configureopimitzation.cmake is included correctly in test build. Try to add brackets to get the Linux ARM compilation working correctly. Define standard language version in configurecompiler.cmake instead of root CMakeLists (so tests get it) Try to move langauge standard check to configure.cmake define language standard in each root CMakeLists.txt Fix off-Windows test build. Set CMAKE_EXPORT_COMPILE_COMMANDS after the project() call * Set CMAKE_USER_MAKE_RULES_OVERRIDE to "" to not break incremental builds after building on a branch that had it set to a path. * Remove CMake version output. * Move comment outside of multiline command. * Retry setting CMAKE_USER_MAKE_RULES_OVERRIDE * Remove unnecessary variable wrappers. * Simplify cmake 3 resolution. * Explicitly use CMAKE_CXX_FLAGS for C++-only flags that GCC complains about on C files. * Set -Wall via CMAKE_<LANG>_FLAGS until we can move all flag settings to add_compile_options * Fix typos * Another temporary precedence issue. * include configureoptimization.cmake in configurecompiler.cmake * Move setting CMAKE_EXPORT_COMPILE_COMMANDS to configurecompiler.cmake. * Rename configure.cmake -> verify_lto.cmake. * Fix path to verify-lto * Try using CMAKE_<LANG>_FLAGS instead of CMAKE_<LANG>_FLAGS_INIT. * Revert name change to configure.camek Commit migrated from dotnet/coreclr@38f121b
CMAKE_USER_MAKE_RULES_OVERRIDE
to an empty string to update the CMake cache so CMake doesn't go looking for the compiler-override files.