From c2341ece47f994baec57296d7a08dcf6bf34f8e9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 21 Apr 2022 10:55:21 -0400 Subject: CheckLinkerFlag: Catch linker warning when the checked flag is ignored Prior to commit 219dde4ea8 (CheckPIESupported: now uses any SYSROOT settings, 2022-01-16, v3.23.0-rc1~110^2), the checks for `-pie` and `-no_pie` on macOS failed due to executing the compiler directly without any `-isysroot`, producing `ld: library not found for -lc++`. See issues #23053 and #19180. The failing check for `-pie` was a bug because it is supported on macOS, both for `x86_64` and `arm64`, and the commit fixed that check. However, `-no_pie` is not supported on macOS `arm64`. The above commit was only able to detect that due to commit f745e0497e (CheckCompilerFlags: Catch linker warning about ignored flags, 2022-01-03, v3.23.0-rc1~174^2), which we need to revert due to issue #23432. Instead, catch only the linker warning about the exact flag being checked. --- Modules/Internal/CheckLinkerFlag.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Modules/Internal/CheckLinkerFlag.cmake b/Modules/Internal/CheckLinkerFlag.cmake index 51d4225..7613105 100644 --- a/Modules/Internal/CheckLinkerFlag.cmake +++ b/Modules/Internal/CheckLinkerFlag.cmake @@ -25,6 +25,15 @@ function(CMAKE_CHECK_LINKER_FLAG _lang _flag _var) set(CMAKE_REQUIRED_LINK_OPTIONS "${_flag}") check_compiler_flag_common_patterns(_common_patterns) + + # Match linker warnings if the exact flag is ignored. + foreach(flag IN LISTS _flag) + string(REGEX REPLACE "([][+.*?()^$])" [[\\\1]] _flag_regex "${flag}") + list(APPEND _common_patterns + FAIL_REGEX "warning: .*${_flag_regex}.* ignored" + ) + endforeach() + cmake_check_source_compiles(${_lang} "${_lang_src}" ${_var} -- cgit v0.12 From 4941887d7defecb3016d2bd94d3a45754251ca56 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 20 Apr 2022 11:46:30 -0400 Subject: CheckCompilerFlags: Revert "Catch linker warning about ignored flags" Revert commit f745e0497e (CheckCompilerFlags: Catch linker warning about ignored flags, 2022-01-03, v3.23.0-rc1~174^2). It regressed cases where incidental linker warnings were previously tolerated. Revert the change pending further investigation. Fixes: #23432 Issue: #22961 --- Modules/CMakeCheckCompilerFlagCommonPatterns.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake index 8f59acd..bda1d71 100644 --- a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake +++ b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake @@ -13,7 +13,6 @@ macro (CHECK_COMPILER_FLAG_COMMON_PATTERNS _VAR) FAIL_REGEX "unknown .*option" # Clang FAIL_REGEX "optimization flag .* not supported" # Clang FAIL_REGEX "unknown argument ignored" # Clang (cl) - FAIL_REGEX "warning: .* ignored" # Clang (linker) FAIL_REGEX "ignoring unknown option" # MSVC, Intel FAIL_REGEX "warning D9002" # MSVC, any lang FAIL_REGEX "option.*not supported" # Intel -- cgit v0.12