CMakeDetermineCompilerABI: Strip -pipe from compile flags
When `-pipe` is enabled, GCC passes data among its different executables
using pipes instead of temporary files. This leads to issues when cmake
attempts to infer compiler internals via the `-v` flag as each
executable will print to `stderr` in parallel. Avoid this by stripping
`-pipe` from the compilation flags during compiler inspection.
This extends commit d5895f50c3 (CMakeDetermineCompilerABI: Avoid failing
on warnings with -Werror, 2020-01-30, v3.17.0-rc1~32^2).
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake
index 4a75e25..806f0b7 100644
--- a/Modules/CMakeDetermineCompilerABI.cmake
+++ b/Modules/CMakeDetermineCompilerABI.cmake
@@ -52,14 +52,21 @@
__TestCompiler_setTryCompileTargetType()
- # Avoid failing ABI detection on warnings.
+ # Avoid failing ABI detection caused by non-functionally relevant
+ # compiler arguments
if(CMAKE_TRY_COMPILE_CONFIGURATION)
string(TOUPPER "${CMAKE_TRY_COMPILE_CONFIGURATION}" _tc_config)
else()
set(_tc_config "DEBUG")
endif()
foreach(v CMAKE_${lang}_FLAGS CMAKE_${lang}_FLAGS_${_tc_config})
+ # Avoid failing ABI detection on warnings.
string(REGEX REPLACE "(^| )-Werror([= ][^-][^ ]*)?( |$)" " " ${v} "${${v}}")
+ # Avoid passing of "-pipe" when determining the compiler internals. With
+ # "-pipe" GCC will use pipes to pass data between the involved
+ # executables. This may lead to issues when their stderr output (which
+ # contains the relevant compiler internals) becomes interweaved.
+ string(REGEX REPLACE "(^| )-pipe( |$)" " " ${v} "${${v}}")
endforeach()
# Save the current LC_ALL, LC_MESSAGES, and LANG environment variables