-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[compiler-rt] Fix detection of warnings flags #125602
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
base: main
Are you sure you want to change the base?
[compiler-rt] Fix detection of warnings flags #125602
Conversation
Created using spr 1.3.6-beta.1
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, but maybe let's do the other one case too:
compiler-rt/cmake/crt-config-ix.cmake:9:builtin_check_c_compiler_flag(-Wno-pedantic COMPILER_RT_HAS_WNO_PEDANTIC)
Created using spr 1.3.6-beta.1
project('testflags', 'c')
cc = meson.get_compiler('c')
args = cc.get_supported_arguments('-Wno-forgotten-towel', '-Wno-pednatic', '-Wthingy',
'-Wbuiltin-declaration-mismatch', '-flto')
message('supported args', args)
Was interested to see how this gets handled, as I had a dim memory that meson went to some lengths to work around compiler-specific weirdnesses here. It turns out that for:
I wonder, if it would be a good idea to instead have llvm-project/compiler-rt/cmake/Modules/BuiltinTests.cmake Lines 112 to 123 in d810c74
|
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 appears that these checks report true without -Werror since they only
trigger a -Wunknown-warning-option that does not fail the check.
Hold on,
I modified the test to use ECHO_OUTPUT_VARIABLE so as to get actual logging of what is happening. This is with clang.
-- Performing Test COMPILER_RT_HAS_WBUILTIN_DECLARATION_MISMATCH_FLAG
warning: unknown warning option '-Wbuiltin-declaration-mismatch'; did you mean '-Wmissing-declarations'? [-Wunknown-warning-option]
1 warning generated.
-- Performing Test COMPILER_RT_HAS_WBUILTIN_DECLARATION_MISMATCH_FLAG - Failed
The check is failing as it should, because:
llvm-project/compiler-rt/cmake/Modules/BuiltinTests.cmake
Lines 90 to 99 in d810c74
CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCCompilerFlag_COMMON_PATTERNS) | |
set(ERRORS_FOUND OFF) | |
foreach(var ${_CheckCCompilerFlag_COMMON_PATTERNS}) | |
if("${var}" STREQUAL "FAIL_REGEX") | |
continue() | |
endif() | |
if("${TEST_ERROR}" MATCHES "${var}" OR "${TEST_OUTPUT}" MATCHES "${var}") | |
set(ERRORS_FOUND ON) | |
endif() | |
endforeach() |
This yanks out some regex patterns from cmake internals and does string matching, one of which is:
FAIL_REGEX "unknown .*option" # Clang
that does manage to successfully match here.
So it's not clear to me under what circumstances this check should ever detect success in COMPILER_RT_HAS_WBUILTIN_DECLARATION_MISMATCH_FLAG. I can't manage it myself, at least.
I've just tested the current version of this MR, unfortunately it doesn't fix #72413 yet. |
In that case I have no idea how you are seeing this warning. During CMake time your compiler claims to support it (is it running with gcc for some reason?) but then when compiling it doesn't work which indicates a different compiler is being used. I do wonder if this is some weirdness of the LLVM_ENABLE_PROJECTS=compiler-rt build vs. LLVM_ENABLE_RUNTIMES. |
Thanks to the help of Google Gemini 2.0 EXP, I am proposing this patch instead that I've tested to fix my reported issue locally:
|
That certainly isn't a correct fix. The flag would never be added. All that does is create a list and populate it. It's never referenced again, nor is the flag actually used anywhere. |
It appears that these checks report true without -Werror since they only
trigger a -Wunknown-warning-option that does not fail the check.
See also commit bfa6444 (#83779)
Fixes: #72413