From a41fefa1a8b35e16c27d6876c29c54c03a80f159 Mon Sep 17 00:00:00 2001 From: mustiikhalil <26250654+mustiikhalil@users.noreply.github.com> Date: Wed, 29 May 2024 02:29:41 +0200 Subject: [PATCH] Trying to fix bazel on macOS and Xcode 14.3 (#8304) * Fixes Bazel issues for windows and ci Fetching boringssl within the flatbuffers repository, to patch the issues of not being able to upgrade to Xcode 14.3 due to buildkite throwing errors. The patch was inspired by the tenserflow patch https://github.com/tensorflow/tensorflow/issues/60191#issuecomment-1496073147 Removes references of swift from the windows pipeline for bazel Sets github actions to use xcode 14.3 for kotlin and sets the macOS build for intel cpus. * Update build.yml Remove comment that is not relevant any longer. --------- Co-authored-by: Derek Bailey --- .bazelci/presubmit.yml | 2 +- .bazelrc | 8 ++++++ .github/workflows/build.yml | 46 +++++++++++++++++--------------- WORKSPACE | 22 +++++++++++++++ grpc/boringssl.patch | 28 +++++++++++++++++++ grpc/build_grpc_with_cxx14.patch | 7 +++-- 6 files changed, 89 insertions(+), 24 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index bcab65430..1dcf09d23 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -31,7 +31,7 @@ platforms: test_targets: - "//..." macos: - xcode_version: "14.2" + xcode_version: "14.3" build_targets: - "//..." test_targets: diff --git a/.bazelrc b/.bazelrc index fe25c51e0..813fce99f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -2,3 +2,11 @@ # --deleted_packages. We need to specify it for both build and query instead. build --deleted_packages=tests/bazel_repository_test_dir,tests/ts/bazel_repository_test_dir query --deleted_packages=tests/bazel_repository_test_dir,tests/ts/bazel_repository_test_dir +# Point tools such as coursier (used in rules_jvm_external) to Bazel's internal JDK +# suggested in https://github.com/bazelbuild/rules_jvm_external/issues/445 +common --repo_env=JAVA_HOME=../bazel_tools/jdk +common --action_env=JAVA_HOME=../bazel_tools/jdk +# Workaround "Error: need --enable_runfiles on Windows for to support rules_js" +common:windows --enable_runfiles +# Swift is not required on Windows +common:windows --deleted_packages=swift \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 088819161..cfa56a8c8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -224,7 +224,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: cmake - run: cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . + run: cmake -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . - name: build run: xcodebuild -toolchain clang -configuration Release -target flattests - name: check that the binary is x86_64 @@ -377,26 +377,30 @@ jobs: working-directory: java run: mvn test - # Renable - # build-kotlin-macos: - # name: Build Kotlin MacOS - # runs-on: macos-latest-large - # steps: - # - name: Checkout - # uses: actions/checkout@v3 - # - uses: gradle/wrapper-validation-action@v1.0.5 - # - uses: actions/setup-java@v3 - # with: - # distribution: 'temurin' - # java-version: '11' - # - name: Build flatc - # run: | - # cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . - # make -j - # echo "${PWD}" >> $GITHUB_PATH - # - name: Build - # working-directory: kotlin - # run: ./gradlew clean iosSimulatorArm64Test macosX64Test macosArm64Test + build-kotlin-macos: + name: Build Kotlin MacOS + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + # Force Xcode 14.3 since Xcode 15 doesnt support older versions of + # kotlin. For Xcode 15, kotlin should be bumpped to 1.9.10 + # https://stackoverflow.com/a/77150623 + - name: Set up Xcode version + run: sudo xcode-select -s /Applications/Xcode_14.3.app/Contents/Developer + - uses: gradle/wrapper-validation-action@v1.0.5 + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '11' + - name: Build flatc + run: | + cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . + make -j + echo "${PWD}" >> $GITHUB_PATH + - name: Build + working-directory: kotlin + run: ./gradlew clean iosSimulatorArm64Test macosX64Test macosArm64Test build-kotlin-linux: name: Build Kotlin Linux diff --git a/WORKSPACE b/WORKSPACE index 730217e47..772dc018e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -83,6 +83,28 @@ http_archive( ], ) +#### Building boring ssl +# Fetching boringssl within the flatbuffers repository, to patch the issue +# of not being able to upgrade to Xcode 14.3 due to buildkite throwing errors +# which was patched in the following below. +# https://github.com/google/flatbuffers/commit/67eb95de9281087ccbba9aafd6e8ab1958d12045 +# The patch was copied from the following comment on the same issue within tensorflow +# and fixed to adapt the already existing patch for boringssl. +# https://github.com/tensorflow/tensorflow/issues/60191#issuecomment-1496073147 +http_archive( + name = "boringssl", + patch_args = ["-p1"], + patches = ["//grpc:boringssl.patch"], + # Use github mirror instead of https://boringssl.googlesource.com/boringssl + # to obtain a boringssl archive with consistent sha256 + sha256 = "534fa658bd845fd974b50b10f444d392dfd0d93768c4a51b61263fd37d851c40", + strip_prefix = "boringssl-b9232f9e27e5668bc0414879dcdedb2a59ea75f2", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/boringssl/archive/b9232f9e27e5668bc0414879dcdedb2a59ea75f2.tar.gz", + "https://github.com/google/boringssl/archive/b9232f9e27e5668bc0414879dcdedb2a59ea75f2.tar.gz", + ], +) + ##### GRPC _GRPC_VERSION = "1.49.0" # https://github.com/grpc/grpc/releases/tag/v1.48.0 diff --git a/grpc/boringssl.patch b/grpc/boringssl.patch index 632499e28..a8768927a 100644 --- a/grpc/boringssl.patch +++ b/grpc/boringssl.patch @@ -11,3 +11,31 @@ index 1645a264a..12f8ca999 100644 add_executable( bssl +diff --git a/src/crypto/x509/t_x509.c b/src/crypto/x509/t_x509.c +index 7c32a8798..6e50d040e 100644 +--- a/src/crypto/x509/t_x509.c ++++ b/src/crypto/x509/t_x509.c +@@ -318,9 +318,7 @@ int X509_signature_print(BIO *bp, const X509_ALGOR *sigalg, + int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase) + { + char *s, *c, *b; +- int ret = 0, l, i; +- +- l = 80 - 2 - obase; ++ int ret = 0, i; + + b = X509_NAME_oneline(name, NULL, 0); + if (!b) +@@ -347,12 +345,10 @@ int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase) + if (BIO_write(bp, ", ", 2) != 2) + goto err; + } +- l--; + } + if (*s == '\0') + break; + s++; +- l--; + } + + ret = 1; diff --git a/grpc/build_grpc_with_cxx14.patch b/grpc/build_grpc_with_cxx14.patch index 38cdfe993..b5900af5b 100644 --- a/grpc/build_grpc_with_cxx14.patch +++ b/grpc/build_grpc_with_cxx14.patch @@ -2,9 +2,12 @@ diff --git a/bazel/copts.bzl b/bazel/copts.bzl index 10be944f25..879518b92f 100644 --- a/bazel/copts.bzl +++ b/bazel/copts.bzl -@@ -59,4 +59,4 @@ GRPC_LLVM_WARNING_FLAGS = [ +@@ -59,4 +59,7 @@ GRPC_LLVM_WARNING_FLAGS = [ GRPC_DEFAULT_COPTS = select({ "//:use_strict_warning": GRPC_LLVM_WARNING_FLAGS + ["-DUSE_STRICT_WARNING=1"], "//conditions:default": [], -}) -+}) + ["-std=c++14"] ++}) + select({ ++ "@bazel_tools//src/conditions:windows": ["/std:c++14"], ++ "//conditions:default": ["-std=c++14"], ++})