diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -318,8 +318,12 @@ # Older Clang may support -fno-semantic-interposition but it used local # aliases to optimize global variables, which is incompatible with copy # relocations due to -fno-pic. - if (CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND - CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 13)) + # GCC for SystemZ: Enable `-fno-semantic-interposition` when using + # GCC version >= 11 in MLIR build. Old versions of GCC seems to have bugs. + if ((CMAKE_COMPILER_IS_GNUCXX AND + NOT (LLVM_NATIVE_ARCH STREQUAL "SystemZ" AND "mlir" IN_LIST LLVM_ENABLE_PROJECTS + AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.3)) + OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 13)) add_flag_if_supported("-fno-semantic-interposition" FNO_SEMANTIC_INTERPOSITION) endif() endif()