From ebc11bc74c4717197df38a037089b656c55a316d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 2 Sep 2025 12:59:05 +0200 Subject: [PATCH] [maccatalyst] Check for -Wno-overriding-option for compatibility with clang in Xcode 16.3+ https://github.com/llvm/llvm-project/commit/1c66d08b0137cef7761b8220d3b7cb7833f57cdb renamed the option `-Wno-overriding-t-option` to `-Wno-overriding-option`. This caused some configure time checks in CMake to fail because of hitting an unknown compiler option. --- eng/native/configurecompiler.cmake | 18 +++++++++++++++--- src/mono/CMakeLists.txt | 21 +++++++++++++++++++++ src/mono/mono.proj | 2 -- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 3c15b9ff389f27..1431234350ae24 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -676,9 +676,21 @@ if (CLR_CMAKE_HOST_UNIX) # a value for mmacosx-version-min (blank CMAKE_OSX_DEPLOYMENT_TARGET gets # replaced with a default value, and always gets expanded to an OS version. # https://gitlab.kitware.com/cmake/cmake/-/issues/20132 - # We need to disable the warning that -tagret replaces -mmacosx-version-min - set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-t-option) - add_link_options(-Wno-overriding-t-option) + # We need to disable the warning that -target replaces -mmacosx-version-min + # + # With https://github.com/llvm/llvm-project/commit/1c66d08b0137cef7761b8220d3b7cb7833f57cdb clang renamed the option so we need to check for both + check_c_compiler_flag("-Wno-overriding-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION) + if (COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION) + set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-option) + else() + check_c_compiler_flag("-Wno-overriding-t-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION) + if (COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION) + set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-t-option) + else() + message(FATAL_ERROR "Compiler does not support -Wno-overriding-option or -Wno-overriding-t-option, needed for Mac Catalyst builds.") + endif() + endif() + add_link_options(${DISABLE_OVERRIDING_MIN_VERSION_ERROR}) if(CLR_CMAKE_HOST_ARCH_ARM64) set(CLR_CMAKE_MACCATALYST_COMPILER_TARGET "arm64-apple-ios15.0-macabi") add_link_options(-target ${CLR_CMAKE_MACCATALYST_COMPILER_TARGET}) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index b5dc8acebadc7a..38768df87b4adf 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -545,6 +545,27 @@ if(GCC) set(WARNINGS "${WARNINGS} -Qunused-arguments -Wno-tautological-compare -Wno-parentheses-equality -Wno-self-assign -Wno-return-stack-address -Wno-constant-logical-operand -Wno-zero-length-array -Wno-asm-operand-widths") endif() + if (HOST_MACCAT) + # Somewhere between CMake 3.17 and 3.19.4, it became impossible to not pass + # a value for mmacosx-version-min (blank CMAKE_OSX_DEPLOYMENT_TARGET gets + # replaced with a default value, and always gets expanded to an OS version. + # https://gitlab.kitware.com/cmake/cmake/-/issues/20132 + # We need to disable the warning that -target replaces -mmacosx-version-min + # + # With https://github.com/llvm/llvm-project/commit/1c66d08b0137cef7761b8220d3b7cb7833f57cdb clang renamed the option so we need to check for both + check_c_compiler_flag("-Wno-overriding-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION) + if (COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION) + set(WARNINGS "${WARNINGS} -Wno-overriding-option") + else() + check_c_compiler_flag("-Wno-overriding-t-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION) + if (COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION) + set(WARNINGS "${WARNINGS} -Wno-overriding-t-option") + else() + message(FATAL_ERROR "Compiler does not support -Wno-overriding-option or -Wno-overriding-t-option, needed for Mac Catalyst builds.") + endif() + endif() + endif() + check_c_compiler_flag("-Werror=incompatible-pointer-types" WERROR_INCOMPATIBLE_POINTER_TYPES) if(WERROR_INCOMPATIBLE_POINTER_TYPES) set(WERROR_C "${WERROR_C} -Werror=incompatible-pointer-types") diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 7f79cb409cd3fb..9b3fd3582098bf 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -530,8 +530,6 @@ JS_ENGINES = [NODE_JS] <_MonoCMakeArgs Include="-DCMAKE_SYSTEM_VARIANT=maccatalyst" /> <_MonoCMakeArgs Include="-DBUILD_DARWIN_FRAMEWORKS=1" /> - - <_MonoCPPFLAGS Include="-Wno-overriding-t-option" /> <_MonoCFlags Condition="'$(TargetArchitecture)' == 'arm64'" Include="-target arm64-apple-ios$(MacCatalystVersionMin)-macabi" /> <_MonoCFlags Condition="'$(TargetArchitecture)' == 'x64'" Include="-target x86_64-apple-ios$(MacCatalystVersionMin)-macabi" /> <_MonoCFLAGS Condition="'$(TargetArchitecture)' == 'arm64'" Include="-arch arm64" />