-
Notifications
You must be signed in to change notification settings - Fork 3.7k
move -Werror to CI only 📦 #10957
move -Werror to CI only 📦 #10957
Conversation
.cicd/build.sh
Outdated
| mkdir -p "$BUILD_DIR" | ||
| [[ -z "$DCMAKE_BUILD_TYPE" ]] && export DCMAKE_BUILD_TYPE='Release' | ||
| CMAKE_EXTRAS="$CMAKE_EXTRAS -DCMAKE_BUILD_TYPE=\"$DCMAKE_BUILD_TYPE\" -DENABLE_MULTIVERSION_PROTOCOL_TEST=\"true\" -DAMQP_CONN_STR=\"amqp://guest:guest@localhost:5672\"" | ||
| CMAKE_EXTRAS="$CMAKE_EXTRAS -DCMAKE_CXX_FLAGS=\"-Werror\" -DCMAKE_BUILD_TYPE=\"$DCMAKE_BUILD_TYPE\" -DENABLE_MULTIVERSION_PROTOCOL_TEST=\"true\" -DAMQP_CONN_STR=\"amqp://guest:guest@localhost:5672\"" |
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.
We probably want Werror on both CXX_FLAGS and 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.
It doesn't work out of the box, see https://buildkite.com/EOSIO/eosio-build-unpinned/builds/9927#af15773f-5a88-4c25-984a-63586ce212e6.
There are a few options here:
- just don't use
CMAKE_C_FLAGS="-Werror" - convert "webassembly/runtimes/eos-vm-oc/gs_seg_helpers.c" into c++ and use
extern "C" - remove
target_compile_options( eos-vm INTERFACE "-Wno-register" )ineos-vm/CMakeLists.txtand then useset_source_files_propertiesto set-Wno-registeronly on c++ files.
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.
maybe you can do something like
target_compile_options(eos-vm INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-Wno-register>)
It also doesn't seem all that bad to propagate -Wno-register to the root CMakeLists
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.
@spoonincode can you elaborate the goal here and why this is needed?
I am worried about the scenario “Local builds work and then it fails mysteriously on CI due to -Werror only on CI”
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 problem is every compiler and version of the compiler has different warnings. And warnings are moved between Wall, Wextra, and Wpedantic between different versions. It's hard to predict what compiler users are going to use, and there are lot more combinations in the wild than our meager CI suite. As an example, I could no longer build eosio on my Linux box because both gcc 11 & clang 13 had warnings. clang 13 failed with,
libraries/abieos/include/eosio/name.hpp:21:14: error: definition of implicit copy assignment operator for 'name' is deprecated because it has a user-declared copy constructor [-Wdeprecated-copy,-Werror]
constexpr name(const name&) = default;
This is an interesting warning, but it's not worth shooting down some poor user's build due to a benign warning like this.
I am worried about the scenario “Local builds work and then it fails mysteriously on CI due to -Werror only on CI”
This is a problem regardless (well, except for the "mysteriously" part, as long as one bothers to actually read the output) -- local developers are probably going to only build on one compiler locally before pushing, not the handful that are in CI.
That said, personally I would have gone with a cmake option (defaulted to off) that enabled Werror, so a developer can easily toggle and leave this on locally. I'm indifferent on that aspect though.
| set(CMAKE_C_FLAGS_INIT "-D_FORTIFY_SOURCE=2 -fstack-protector-strong -fpie") | ||
| set(CMAKE_CXX_FLAGS_INIT "-nostdinc++ -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fpie") | ||
| set(CMAKE_EXE_LINKER_FLAGS_INIT "-stdlib=libc++ -nostdlib++ -pie") | ||
| set(CMAKE_POSITION_INDEPENDENT_CODE 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.
reason for this change?
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 -fpie would cause compiler warning in certain cases. See https://buildkite.com/EOSIO/eosio/builds/31652#96473ad1-aeb6-4b57-9827-0663654c7a86 which doesn’t have the change. Using CMAKE_POSITION_INDEPENDENT_CODE can make sure the cmake to use -fpic or -fpie correctly in all cases regardless building library or executable.
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.
[2021-12-14T18:25:31Z] /usr/bin/ld: CMakeFiles/test_abieos_reflect.dir/src/reflect_test.cpp.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
[2021-12-14T18:25:31Z] clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
That looks like a linker error 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.
The problem was cmake couldn't generate correct compile options. Here are the build.ninja snippets in both cases:
- with
CMAKE_POSITION_INDEPENDENT_CODE=ON
build libraries/abieos/CMakeFiles/test_abieos_reflect.dir/src/reflect_test.cpp.o: CXX_COMPILER__test_abieos_reflect ../libraries/abieos/src/reflect_test.cpp || cmake_object_order_depends_target_test_abieos_reflect
DEP_FILE = libraries/abieos/CMakeFiles/test_abieos_reflect.dir/src/reflect_test.cpp.o.d
FLAGS = -Werror -Wall -Wsign-compare -Wrange-loop-analysis -Wno-unused-command-line-argument -Wall -Wno-invalid-partial-specialization -O3 -DNDEBUG -fPIE -fdiagnostics-color=always -std=gnu++17
INCLUDES = -I../libraries/abieos/include -isystem /usr/local/include/c++/v1 -isystem /usr/local/include -isystem /usr/include
OBJECT_DIR = libraries/abieos/CMakeFiles/test_abieos_reflect.dir
OBJECT_FILE_DIR = libraries/abieos/CMakeFiles/test_abieos_reflect.dir/src
- With original CMAKE_C_FLAGS_INIT, CMAKE_CXX_FLAGS_INIT and CMAKE_EXE_LINKER_FLAGS_INIT
build libraries/abieos/CMakeFiles/test_abieos_reflect.dir/src/reflect_test.cpp.o: CXX_COMPILER__test_abieos_reflect ../libraries/abieos/src/reflect_test.cpp || cmake_object_order_depends_target_test_abieos_reflect
DEP_FILE = libraries/abieos/CMakeFiles/test_abieos_reflect.dir/src/reflect_test.cpp.o.d
FLAGS = -Werror -Wall -Wsign-compare -Wrange-loop-analysis -Wno-unused-command-line-argument -Wall -Wno-invalid-partial-specialization -O3 -DNDEBUG -fdiagnostics-color=always -std=gnu++17
INCLUDES = -I../libraries/abieos/include -isystem /usr/local/include/c++/v1 -isystem /usr/local/include -isystem /usr/include
OBJECT_DIR = libraries/abieos/CMakeFiles/test_abieos_reflect.dir
OBJECT_FILE_DIR = libraries/abieos/CMakeFiles/test_abieos_reflect.dir/src
TARGET_COMPILE_PDB = libraries/abieos/CMakeFiles/test_abieos_reflect.dir/
TARGET_PDB = libraries/abieos/test_abieos_reflect.pdb
|
what's the reason for the CMP0077 change in abieos? |
|
huangminghuang 12 seconds ago |
|
What are we doing that actually causes that warning though? It's not like cmake just always prints a warning now unless you dump that CMP0077 noise in the CMakeLists. A really basic CMakeLists cmake_minimum_required( VERSION 3.8 )
project(banana)
option(USE_PLANTAIN "intead of bananas, use plantains" OFF)Then |
Actually, it is only needed for 2.2.x and develop branches of eos and I just rebase all the changes from there. The problem stems from setting the option explicitly in parent project and then use |
|
Instead of set(ABIEOS_BUILD_SHARED_LIB OFF)Can use one of option(ABIEOS_BUILD_SHARED_LIB "" OFF)set(ABIEOS_BUILD_SHARED_LIB OFF CACHE BOOL "")I think I like the |
Change Description
This PR remove
-Werrorcompiler flag from the CMakeLists.txt and only use it for CI builds.Change Type
Select ONE:
Testing Changes
Select ANY that apply:
Consensus Changes
API Changes
Documentation Additions