-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[compiler-rt] Fix incorrect usages of check_cxx_compiler_flag #83779
[compiler-rt] Fix incorrect usages of check_cxx_compiler_flag #83779
Conversation
Created using spr 1.3.6-beta.1
check_cxx_compiler_flag(-Werror -Wformat-security COMPILER_RT_HAS_BUILTIN_FORMAL_SECURITY_FLAG) | ||
check_cxx_compiler_flag(-Werror -Wsizeof-array-div COMPILER_RT_HAS_SIZEOF_ARRAY_DIV_FLAG) | ||
check_cxx_compiler_flag(-Werror -Wsizeof-pointer-div COMPILER_RT_HAS_SIZEOF_POINTER_DIV_FLAG) | ||
check_cxx_compiler_flag("-Werror -Warray-bounds" COMPILER_RT_HAS_ARRAY_BOUNDS_FLAG) |
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 sounds like we might be able to drop the -Werror from some of these but that might be better as a separate change to not break buildbots.
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.
This patch somehow breaks
https://lab.llvm.org/buildbot/#/builders/18/builds/15660
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 guess no -ftrivial-auto-var-init=pattern is enabled and triggers crash as intended :)
I'll try to fix
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.
Thanks for looking into this. I tried x86 and aarch64 and didn't see any problems so assumed this was safe. Maybe related to big endian?
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 crash looks bogus, I don't see how this can get uninitialized. Trying 6f7ebcb
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
Actually, they have been broken since f051c1d. My previous attempts to land this patch were unsuccessful. @nikic does this patch work for you now? |
These checks have been broken since 6afe972. The check_cxx_compiler_flag macro only takes two arguments and passing three to it ends up calling `cmake_check_compiler_flag(CXX "${_FLAG}" ${_RESULT})` with ${_FLAG} equal to `-Werror` and the result variable being the actually tested compiler flag. I noticed this because some of the flags that I know should be supported were being flagged as not supported. `--debug-trycompile` shows the following surprising line in the generated CMakeLists.txt: `add_definitions([==[-D-Wempty-body]==] [==[-Werror]==])` which then results in the following error while running the check: ``` FAILED: CMakeFiles/cmTC_72736.dir/src.cxx.o tmp/upstream-llvm-readonly/bin/clang++ -nodefaultlibs -std=c++17 -fcolor-diagnostics -D-Wempty-body -Werror -MD -MT CMakeFiles/cmTC_72736.dir/src.cxx.o -MF CMakeFiles/cmTC_72736.dir/src.cxx.o.d -o CMakeFiles/cmTC_72736.dir/src.cxx.o -c .../cmake-build-all-sanitizers/CMakeFiles/CMakeScratch/TryCompile-nyh3QR/src.cxx In file included from <built-in>:450: <command line>:1:9: error: macro name must be an identifier 1 | #define -Wempty-body 1 | ^ 1 error generated. ``` It would be great if CMake could be a bit more helpful here so I've filed https://gitlab.kitware.com/cmake/cmake/-/issues/25735. Pull Request: llvm#83779
This patch seems to break the build :(
|
GCC complains if we pass -Werror=format-security without -Wformat. Reported at #83779 (comment)
Thanks for the report, I managed to reproduce it with GCC and it should be fixed by 80a9574 |
These checks have been broken since 6afe972.
The check_cxx_compiler_flag macro only takes two arguments and passing
three to it ends up calling
cmake_check_compiler_flag(CXX "${_FLAG}" ${_RESULT})
with ${_FLAG}equal to
-Werror
and the result variable being the actually testedcompiler flag.
I noticed this because some of the flags that I know should be supported
were being flagged as not supported.
--debug-trycompile
shows thefollowing surprising line in the generated CMakeLists.txt:
add_definitions([==[-D-Wempty-body]==] [==[-Werror]==])
which thenresults in the following error while running the check:
It would be great if CMake could be a bit more helpful here so I've
filed https://gitlab.kitware.com/cmake/cmake/-/issues/25735.
See also https://reviews.llvm.org/D146920.