From 5dbc3130c7828edb637f7eb264b68efa90d1d3c5 Mon Sep 17 00:00:00 2001
From: Adam Farley <adfarley@redhat.com>
Date: Tue, 12 Dec 2023 12:55:41 +0000
Subject: [PATCH] Exclude excessive build warnings on mac for jdk11 and jdk17

Also included some aggregate logic to avoid cflags overriding other
cflags unintentionally

Signed-off-by: Adam Farley <adfarley@redhat.com>
---
 .../platform-specific-configurations/mac.sh   | 20 ++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/build-farm/platform-specific-configurations/mac.sh b/build-farm/platform-specific-configurations/mac.sh
index 7283ceb82..661576fdd 100755
--- a/build-farm/platform-specific-configurations/mac.sh
+++ b/build-farm/platform-specific-configurations/mac.sh
@@ -22,6 +22,9 @@ source "$SCRIPT_DIR/../../sbin/common/constants.sh"
 export MACOSX_DEPLOYMENT_TARGET=10.9
 export BUILD_ARGS="${BUILD_ARGS}"
 
+c_flags_bucket=""
+cxx_flags_bucket=""
+
 ## JDK8 only: If, at this point in the build, the architecure of the machine is arm64 while the ARCHITECTURE variable
 ## is x64 then we need to add the cross compilation option --openjdk-target=x86_64-apple-darwin
 MACHINEARCHITECTURE=$(uname -m)
@@ -51,6 +54,13 @@ else
     # JDK17 requires metal (included in full xcode) as does JDK11 on aarch64
     # JDK11 on x64 is matched for consistency
     XCODE_SWITCH_PATH="/Applications/Xcode.app"
+    # JDK11 and 17 on Mac (x86 and aarch) has excessive warnings.
+    # This is due to a harfbuzz fix which is pending backport.
+    # Suppressing the warnings for now to aid triage.
+    if [[ "$JAVA_FEATURE_VERSION" -le 17 ]]; then
+      export cxx_flags_bucket="${cxx_flags_bucket} -Wno-deprecated-builtins -Wno-deprecated-declarations -Wno-deprecated-non-prototype"
+      export c_flags_bucket="${c_flags_bucket} -Wno-deprecated-builtins -Wno-deprecated-declarations -Wno-deprecated-non-prototype"
+    fi
   else
     # Command line tools used from JDK9-JDK10
     XCODE_SWITCH_PATH="/";
@@ -61,7 +71,7 @@ else
   else
     if [ "${ARCHITECTURE}" == "x64" ]; then
       # We can only target 10.9 on intel macs
-      export CONFIGURE_ARGS_FOR_ANY_PLATFORM="${CONFIGURE_ARGS_FOR_ANY_PLATFORM} --with-extra-cxxflags=-mmacosx-version-min=10.9"
+      export cxx_flags_bucket="${cxx_flags_bucket} -mmacosx-version-min=10.9"
     elif [ "${ARCHITECTURE}" == "aarch64" ]; then
       export CONFIGURE_ARGS_FOR_ANY_PLATFORM="${CONFIGURE_ARGS_FOR_ANY_PLATFORM} --openjdk-target=aarch64-apple-darwin"
     fi
@@ -156,3 +166,11 @@ if [ "${VARIANT}" == "${BUILD_VARIANT_OPENJ9}" ]; then
     export SDKPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
   fi
 fi
+
+if [ ! "${c_flags_bucket}" = "" ]; then
+  export CONFIGURE_ARGS_FOR_ANY_PLATFORM="${CONFIGURE_ARGS_FOR_ANY_PLATFORM} --with-extra-cflags='${c_flags_bucket}'"
+fi
+
+if [ ! "${cxx_flags_bucket}" = "" ]; then
+  export CONFIGURE_ARGS_FOR_ANY_PLATFORM="${CONFIGURE_ARGS_FOR_ANY_PLATFORM} --with-extra-cxxflags='${cxx_flags_bucket}'"
+fi
\ No newline at end of file