Skip to content

Commit 7442eca

Browse files
authored
[maccatalyst] Check for -Wno-overriding-option for compatibility with clang in Xcode 16.3+ (#119260) (#119303)
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. (cherry picked from commit 4b8a478) (cherry picked from commit f08548f)
1 parent 1d346eb commit 7442eca

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
@@ -635,9 +635,21 @@ if (CLR_CMAKE_HOST_UNIX)
635635
# a value for mmacosx-version-min (blank CMAKE_OSX_DEPLOYMENT_TARGET gets
636636
# replaced with a default value, and always gets expanded to an OS version.
637637
# https://gitlab.kitware.com/cmake/cmake/-/issues/20132
638-
# We need to disable the warning that -tagret replaces -mmacosx-version-min
639-
set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-t-option)
640-
add_link_options(-Wno-overriding-t-option)
638+
# We need to disable the warning that -target replaces -mmacosx-version-min
639+
#
640+
# With https://github.com/llvm/llvm-project/commit/1c66d08b0137cef7761b8220d3b7cb7833f57cdb clang renamed the option so we need to check for both
641+
check_c_compiler_flag("-Wno-overriding-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION)
642+
if (COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION)
643+
set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-option)
644+
else()
645+
check_c_compiler_flag("-Wno-overriding-t-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION)
646+
if (COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION)
647+
set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-t-option)
648+
else()
649+
message(FATAL_ERROR "Compiler does not support -Wno-overriding-option or -Wno-overriding-t-option, needed for Mac Catalyst builds.")
650+
endif()
651+
endif()
652+
add_link_options(${DISABLE_OVERRIDING_MIN_VERSION_ERROR})
641653
if(CLR_CMAKE_HOST_ARCH_ARM64)
642654
set(MACOS_VERSION_MIN_FLAGS "-target arm64-apple-ios14.2-macabi")
643655
add_link_options(-target arm64-apple-ios14.2-macabi)

src/mono/CMakeLists.txt

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

554+
if (HOST_MACCAT)
555+
# Somewhere between CMake 3.17 and 3.19.4, it became impossible to not pass
556+
# a value for mmacosx-version-min (blank CMAKE_OSX_DEPLOYMENT_TARGET gets
557+
# replaced with a default value, and always gets expanded to an OS version.
558+
# https://gitlab.kitware.com/cmake/cmake/-/issues/20132
559+
# We need to disable the warning that -target replaces -mmacosx-version-min
560+
#
561+
# With https://github.com/llvm/llvm-project/commit/1c66d08b0137cef7761b8220d3b7cb7833f57cdb clang renamed the option so we need to check for both
562+
check_c_compiler_flag("-Wno-overriding-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION)
563+
if (COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION)
564+
set(WARNINGS "${WARNINGS} -Wno-overriding-option")
565+
else()
566+
check_c_compiler_flag("-Wno-overriding-t-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION)
567+
if (COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION)
568+
set(WARNINGS "${WARNINGS} -Wno-overriding-t-option")
569+
else()
570+
message(FATAL_ERROR "Compiler does not support -Wno-overriding-option or -Wno-overriding-t-option, needed for Mac Catalyst builds.")
571+
endif()
572+
endif()
573+
endif()
574+
554575
check_c_compiler_flag("-Werror=incompatible-pointer-types" WERROR_INCOMPATIBLE_POINTER_TYPES)
555576
if(WERROR_INCOMPATIBLE_POINTER_TYPES)
556577
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
@@ -392,8 +392,6 @@
392392
<!-- Mac Catalyst specific options -->
393393
<ItemGroup Condition="'$(TargetsMacCatalyst)' == 'true'">
394394
<_MonoCMakeArgs Include="-DCMAKE_SYSTEM_VARIANT=maccatalyst" />
395-
<!-- https://gitlab.kitware.com/cmake/cmake/-/issues/20132 -->
396-
<_MonoCPPFLAGS Include="-Wno-overriding-t-option" />
397395
<_MonoCFlags Condition="'$(TargetArchitecture)' == 'arm64'" Include="-target arm64-apple-ios14.2-macabi" />
398396
<_MonoCFlags Condition="'$(TargetArchitecture)' == 'x64'" Include="-target x86_64-apple-ios13.5-macabi" />
399397
<_MonoCFLAGS Condition="'$(TargetArchitecture)' == 'arm64'" Include="-arch arm64" />

0 commit comments

Comments
 (0)