From 468538e60e25ad5972d8edac849d08d19610703c Mon Sep 17 00:00:00 2001 From: Son Luong Ngoc Date: Thu, 11 Jan 2024 17:38:36 +0100 Subject: [PATCH 1/5] Revert "macos: rollback linkopt flag (#5684)" This reverts commit 8bfb1c6d6f31f8013a5cefed9ec51bfacc584544. --- .bazelrc | 10 ++++-- ...ld-mac-intel-github-release-artifacts.yaml | 36 ++++--------------- platform_mapping | 5 +++ 3 files changed, 19 insertions(+), 32 deletions(-) create mode 100644 platform_mapping diff --git a/.bazelrc b/.bazelrc index 0c107602be2..ed914519f00 100644 --- a/.bazelrc +++ b/.bazelrc @@ -168,8 +168,6 @@ common --nolegacy_important_outputs # Use a static PATH variable to prevent unnecessary rebuilds of dependencies like protobuf. common --incompatible_strict_action_env -common:macos --action_env=DEVELOPER_DIR -common:macos --host_action_env=DEVELOPER_DIR # rules_nodejs needs runfiles to be explicitly enabled. common:linux --enable_runfiles @@ -209,6 +207,14 @@ common:macos --cxxopt=-std=c++17 common:windows --host_cxxopt=/std:c++17 common:windows --cxxopt=/std:c++17 +# Starting from Xcode 15, the linker will warn about duplicate flags. +# This is currently not avoidable with the current way the local cc toolchain is configured +# as well as how linkopts are propagated through the dependency graph between libraries. +# This flag is a workaround to silence the linker warnings. +# common:macos --linkopt="-Wl,-no_warn_duplicate_libraries" +# common:macos --host_linkopt="-Wl,-no_warn_duplicate_libraries" +common:macos --platform_mappings=platform_mapping + # Ensure that we don't use the apple_support cc_toolchain common:macos --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1 diff --git a/.github/workflows/build-mac-intel-github-release-artifacts.yaml b/.github/workflows/build-mac-intel-github-release-artifacts.yaml index 23528981835..965e8ebf83e 100644 --- a/.github/workflows/build-mac-intel-github-release-artifacts.yaml +++ b/.github/workflows/build-mac-intel-github-release-artifacts.yaml @@ -1,27 +1,9 @@ name: "Build Mac-Intel Github Release Artifacts" on: - workflow_dispatch: - inputs: - release_branch: - description: "Git branch to checkout." - required: true - default: "master" - type: string - version_tag: - description: "Version to tag release artifacts." - required: true - type: string - workflow_call: - inputs: - release_branch: - description: "Git branch to checkout." - required: true - type: string - version_tag: - description: "Version to tag release artifacts." - required: true - type: string + pull_request: + branches: + - master jobs: build: @@ -31,9 +13,6 @@ jobs: uses: actions/checkout@v3 with: ref: ${{ inputs.release_branch }} - # We need to fetch git tags to obtain the latest version tag to report - # the version of the running binary. - fetch-depth: 0 - name: Install bazelisk run: | @@ -45,10 +24,7 @@ jobs: - name: Build and Upload Artifacts env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DEVELOPER_DIR: "/Library/Developer/CommandLineTools" run: | - export DEVELOPER_DIR=/Library/Developer/CommandLineTools - "${GITHUB_WORKSPACE}/bin/bazel" build --config=release-mac --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_ORG_API_KEY }} //server/cmd/buildbuddy:buildbuddy //enterprise/server/cmd/server:buildbuddy //enterprise/server/cmd/executor:executor - cp bazel-bin/server/cmd/**/**/buildbuddy buildbuddy-darwin-amd64 - cp bazel-bin/enterprise/server/cmd/**/**/buildbuddy buildbuddy-enterprise-darwin-amd64 - cp bazel-bin/enterprise/server/cmd/**/**/executor executor-enterprise-darwin-amd64 - gh release upload ${{ inputs.version_tag }} buildbuddy-darwin-amd64 buildbuddy-enterprise-darwin-amd64 executor-enterprise-darwin-amd64 --clobber + env + "${GITHUB_WORKSPACE}/bin/bazel" build --toolchain_resolution_debug='@bazel_tools//tools/cpp:toolchain_type' --config=release-mac --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_ORG_API_KEY }} //server/cmd/buildbuddy:buildbuddy //enterprise/server/cmd/server:buildbuddy //enterprise/server/cmd/executor:executor diff --git a/platform_mapping b/platform_mapping new file mode 100644 index 00000000000..ea3e9e9e082 --- /dev/null +++ b/platform_mapping @@ -0,0 +1,5 @@ +platforms: + @local_config_platform//:host + --action_env=DEVELOPER_DIR=/Library/Developer/CommandLineTools + --host_action_env=DEVELOPER_DIR=/Library/Developer/CommandLineTools + --host_linkopt="-Wl,-v" From 51754cac0b72fc9a6533c8cf8a9a1f533ebac63c Mon Sep 17 00:00:00 2001 From: Son Luong Ngoc Date: Thu, 25 Jan 2024 16:46:26 +0100 Subject: [PATCH 2/5] upgrade Bazel --- .bazelversion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelversion b/.bazelversion index 66ce77b7ead..9fe9ff9d996 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -7.0.0 +7.0.1 From 4f3c2d1aba087a4dab554a617305d28288a5a5c0 Mon Sep 17 00:00:00 2001 From: Son Luong Ngoc Date: Thu, 25 Jan 2024 17:07:04 +0100 Subject: [PATCH 3/5] patch rules_go --- WORKSPACE | 4 ++++ buildpatches/rules_go.patch | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 buildpatches/rules_go.patch diff --git a/WORKSPACE b/WORKSPACE index 697ac40a460..e31673034d7 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -19,6 +19,10 @@ http_archive( http_archive( name = "io_bazel_rules_go", + patch_args = ["-p1"], + patches = [ + "//buildpatches:rules_go.patch", + ], sha256 = "7c76d6236b28ff695aa28cf35f95de317a9472fd1fb14ac797c9bf684f09b37c", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.44.2/rules_go-v0.44.2.zip", diff --git a/buildpatches/rules_go.patch b/buildpatches/rules_go.patch new file mode 100644 index 00000000000..37c20b501f5 --- /dev/null +++ b/buildpatches/rules_go.patch @@ -0,0 +1,12 @@ +diff --git a/go/private/actions/link.bzl b/go/private/actions/link.bzl +index 32286416..c4ede25e 100644 +--- a/go/private/actions/link.bzl ++++ b/go/private/actions/link.bzl +@@ -210,6 +210,7 @@ def emit_link( + executable = go.toolchain._builder, + arguments = [builder_args, "--", tool_args], + env = go.env, ++ use_default_shell_env = True, + toolchain = GO_TOOLCHAIN_LABEL, + ) + From fe6b86c7a1b8befaecf61992129da3161bc7d8e8 Mon Sep 17 00:00:00 2001 From: Son Luong Ngoc Date: Thu, 25 Jan 2024 17:07:55 +0100 Subject: [PATCH 4/5] enable remote cache --- .bazelrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.bazelrc b/.bazelrc index ed914519f00..5f403f354ae 100644 --- a/.bazelrc +++ b/.bazelrc @@ -124,6 +124,7 @@ common:release --remote_download_toplevel # Configuration used for release-mac workflow common:release-mac --config=release-shared +common:release-mac --config=cache # Configuration used for release-m1 workflow common:release-m1 --config=release-shared From 9ffdad7beabb1de632092fd98259ae612ebb8d65 Mon Sep 17 00:00:00 2001 From: Son Luong Ngoc Date: Thu, 25 Jan 2024 18:02:25 +0100 Subject: [PATCH 5/5] patch GoLink --- buildpatches/rules_go.patch | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/buildpatches/rules_go.patch b/buildpatches/rules_go.patch index 37c20b501f5..90bac7a4290 100644 --- a/buildpatches/rules_go.patch +++ b/buildpatches/rules_go.patch @@ -1,12 +1,12 @@ -diff --git a/go/private/actions/link.bzl b/go/private/actions/link.bzl -index 32286416..c4ede25e 100644 ---- a/go/private/actions/link.bzl -+++ b/go/private/actions/link.bzl -@@ -210,6 +210,7 @@ def emit_link( - executable = go.toolchain._builder, - arguments = [builder_args, "--", tool_args], - env = go.env, -+ use_default_shell_env = True, - toolchain = GO_TOOLCHAIN_LABEL, - ) - +diff --git a/go/platform/apple.bzl b/go/platform/apple.bzl +index 45c62d6c..f2d8f836 100644 +--- a/go/platform/apple.bzl ++++ b/go/platform/apple.bzl +@@ -41,6 +41,7 @@ def apple_ensure_options(ctx, env, _tags, compiler_option_lists, linker_option_l + if not platform: + return + env.update(_apple_env(ctx, platform)) ++ env.update({"DEVELOPER_DIR": "/Library/Developer/CommandLineTools"}) + min_version = _apple_version_min(ctx, platform, platform_type) + for compiler_options in compiler_option_lists: + compiler_options.append(min_version)