Skip to content

Commit 4b8a478

Browse files
authored
[maccatalyst] Check for -Wno-overriding-option for compatibility with clang in Xcode 16.3+ (#119260)
llvm/llvm-project@1c66d08 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.
1 parent 1f8428d commit 4b8a478

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

eng/native/configurecompiler.cmake

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -676,9 +676,21 @@ if (CLR_CMAKE_HOST_UNIX)
676676
# a value for mmacosx-version-min (blank CMAKE_OSX_DEPLOYMENT_TARGET gets
677677
# replaced with a default value, and always gets expanded to an OS version.
678678
# https://gitlab.kitware.com/cmake/cmake/-/issues/20132
679-
# We need to disable the warning that -tagret replaces -mmacosx-version-min
680-
set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-t-option)
681-
add_link_options(-Wno-overriding-t-option)
679+
# We need to disable the warning that -target replaces -mmacosx-version-min
680+
#
681+
# With https://github.com/llvm/llvm-project/commit/1c66d08b0137cef7761b8220d3b7cb7833f57cdb clang renamed the option so we need to check for both
682+
check_c_compiler_flag("-Wno-overriding-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION)
683+
if (COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION)
684+
set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-option)
685+
else()
686+
check_c_compiler_flag("-Wno-overriding-t-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION)
687+
if (COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION)
688+
set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-t-option)
689+
else()
690+
message(FATAL_ERROR "Compiler does not support -Wno-overriding-option or -Wno-overriding-t-option, needed for Mac Catalyst builds.")
691+
endif()
692+
endif()
693+
add_link_options(${DISABLE_OVERRIDING_MIN_VERSION_ERROR})
682694
if(CLR_CMAKE_HOST_ARCH_ARM64)
683695
set(CLR_CMAKE_MACCATALYST_COMPILER_TARGET "arm64-apple-ios15.0-macabi")
684696
add_link_options(-target ${CLR_CMAKE_MACCATALYST_COMPILER_TARGET})

src/mono/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,27 @@ if(GCC)
545545
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")
546546
endif()
547547

548+
if (HOST_MACCAT)
549+
# Somewhere between CMake 3.17 and 3.19.4, it became impossible to not pass
550+
# a value for mmacosx-version-min (blank CMAKE_OSX_DEPLOYMENT_TARGET gets
551+
# replaced with a default value, and always gets expanded to an OS version.
552+
# https://gitlab.kitware.com/cmake/cmake/-/issues/20132
553+
# We need to disable the warning that -target replaces -mmacosx-version-min
554+
#
555+
# With https://github.com/llvm/llvm-project/commit/1c66d08b0137cef7761b8220d3b7cb7833f57cdb clang renamed the option so we need to check for both
556+
check_c_compiler_flag("-Wno-overriding-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION)
557+
if (COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION)
558+
set(WARNINGS "${WARNINGS} -Wno-overriding-option")
559+
else()
560+
check_c_compiler_flag("-Wno-overriding-t-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION)
561+
if (COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION)
562+
set(WARNINGS "${WARNINGS} -Wno-overriding-t-option")
563+
else()
564+
message(FATAL_ERROR "Compiler does not support -Wno-overriding-option or -Wno-overriding-t-option, needed for Mac Catalyst builds.")
565+
endif()
566+
endif()
567+
endif()
568+
548569
check_c_compiler_flag("-Werror=incompatible-pointer-types" WERROR_INCOMPATIBLE_POINTER_TYPES)
549570
if(WERROR_INCOMPATIBLE_POINTER_TYPES)
550571
set(WERROR_C "${WERROR_C} -Werror=incompatible-pointer-types")

src/mono/mono.proj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,6 @@ JS_ENGINES = [NODE_JS]
530530
<ItemGroup Condition="'$(TargetsMacCatalyst)' == 'true'">
531531
<_MonoCMakeArgs Include="-DCMAKE_SYSTEM_VARIANT=maccatalyst" />
532532
<_MonoCMakeArgs Include="-DBUILD_DARWIN_FRAMEWORKS=1" />
533-
<!-- https://gitlab.kitware.com/cmake/cmake/-/issues/20132 -->
534-
<_MonoCPPFLAGS Include="-Wno-overriding-t-option" />
535533
<_MonoCFlags Condition="'$(TargetArchitecture)' == 'arm64'" Include="-target arm64-apple-ios$(MacCatalystVersionMin)-macabi" />
536534
<_MonoCFlags Condition="'$(TargetArchitecture)' == 'x64'" Include="-target x86_64-apple-ios$(MacCatalystVersionMin)-macabi" />
537535
<_MonoCFLAGS Condition="'$(TargetArchitecture)' == 'arm64'" Include="-arch arm64" />

0 commit comments

Comments
 (0)