Skip to content

Commit f08548f

Browse files
committed
[maccatalyst] Check for -Wno-overriding-option for compatibility with clang in Xcode 16.3+ (dotnet#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. (cherry picked from commit 4b8a478)
1 parent 76ece90 commit f08548f

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
@@ -666,9 +666,21 @@ if (CLR_CMAKE_HOST_UNIX)
666666
# a value for mmacosx-version-min (blank CMAKE_OSX_DEPLOYMENT_TARGET gets
667667
# replaced with a default value, and always gets expanded to an OS version.
668668
# https://gitlab.kitware.com/cmake/cmake/-/issues/20132
669-
# We need to disable the warning that -tagret replaces -mmacosx-version-min
670-
set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-t-option)
671-
add_link_options(-Wno-overriding-t-option)
669+
# We need to disable the warning that -target replaces -mmacosx-version-min
670+
#
671+
# With https://github.com/llvm/llvm-project/commit/1c66d08b0137cef7761b8220d3b7cb7833f57cdb clang renamed the option so we need to check for both
672+
check_c_compiler_flag("-Wno-overriding-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION)
673+
if (COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION)
674+
set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-option)
675+
else()
676+
check_c_compiler_flag("-Wno-overriding-t-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION)
677+
if (COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION)
678+
set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-t-option)
679+
else()
680+
message(FATAL_ERROR "Compiler does not support -Wno-overriding-option or -Wno-overriding-t-option, needed for Mac Catalyst builds.")
681+
endif()
682+
endif()
683+
add_link_options(${DISABLE_OVERRIDING_MIN_VERSION_ERROR})
672684
if(CLR_CMAKE_HOST_ARCH_ARM64)
673685
set(CLR_CMAKE_MACCATALYST_COMPILER_TARGET "arm64-apple-ios15.0-macabi")
674686
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
@@ -552,6 +552,27 @@ if(GCC)
552552
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")
553553
endif()
554554

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

0 commit comments

Comments
 (0)