From ad289015acb37d499a9262478846f4c39b085474 Mon Sep 17 00:00:00 2001 From: jif-oai Date: Fri, 20 Mar 2026 15:38:25 +0000 Subject: [PATCH] try to fix bazel 2 --- MODULE.bazel | 7 ++++ patches/BUILD.bazel | 1 + patches/llvm_macos_sdk_local_fallback.patch | 38 +++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 patches/llvm_macos_sdk_local_fallback.patch diff --git a/MODULE.bazel b/MODULE.bazel index f6f0fd0906..f2dd7d53bb 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -3,6 +3,13 @@ module(name = "codex") bazel_dep(name = "bazel_skylib", version = "1.8.2") bazel_dep(name = "platforms", version = "1.0.0") bazel_dep(name = "llvm", version = "0.6.7") +single_version_override( + module_name = "llvm", + patch_strip = 1, + patches = [ + "//patches:llvm_macos_sdk_local_fallback.patch", + ], +) register_toolchains("@llvm//toolchain:all") diff --git a/patches/BUILD.bazel b/patches/BUILD.bazel index 339c54a657..dd0a06c52f 100644 --- a/patches/BUILD.bazel +++ b/patches/BUILD.bazel @@ -1,5 +1,6 @@ exports_files([ "aws-lc-sys_memcmp_check.patch", + "llvm_macos_sdk_local_fallback.patch", "v8_bazel_rules.patch", "v8_module_deps.patch", "v8_source_portability.patch", diff --git a/patches/llvm_macos_sdk_local_fallback.patch b/patches/llvm_macos_sdk_local_fallback.patch new file mode 100644 index 0000000000..d86b064213 --- /dev/null +++ b/patches/llvm_macos_sdk_local_fallback.patch @@ -0,0 +1,38 @@ +diff --git a/http_pkg_archive.bzl b/http_pkg_archive.bzl +index 8822c51..a2c7f31 100644 +--- a/http_pkg_archive.bzl ++++ b/http_pkg_archive.bzl +@@ -1,9 +1,31 @@ + load("@bazel_tools//tools/build_defs/repo:utils.bzl", "get_auth") + load("@bazel_lib//lib:repo_utils.bzl", "repo_utils") + + def _http_pkg_archive_impl(rctx): +- rctx.download( +- url = rctx.attr.urls, ++ if repo_utils.platform(rctx).startswith("macos_"): ++ host_xcrun = rctx.which("xcrun") ++ if host_xcrun == None: ++ fail("xcrun is required to locate the local macOS SDK") ++ ++ res = rctx.execute([host_xcrun, "--show-sdk-path"]) ++ if res.return_code != 0: ++ fail("Failed to locate local macOS SDK: {}".format(res.stderr)) ++ ++ sdk_path = res.stdout.strip() ++ if not sdk_path: ++ fail("xcrun --show-sdk-path returned an empty SDK path") ++ ++ rctx.file(rctx.attr.dst + "/BUILD.bazel", rctx.read("//3rd_party/macos_sdk:CLTools_macOSNMOS_SDK.BUILD.bazel")) ++ rctx.symlink(sdk_path + "/System", rctx.attr.dst + "/System") ++ rctx.symlink(sdk_path + "/usr", rctx.attr.dst + "/usr") ++ rctx.symlink(sdk_path + "/Entitlements.plist", rctx.attr.dst + "/Entitlements.plist") ++ rctx.symlink(sdk_path + "/SDKSettings.json", rctx.attr.dst + "/SDKSettings.json") ++ rctx.symlink(sdk_path + "/SDKSettings.plist", rctx.attr.dst + "/SDKSettings.plist") ++ ++ return rctx.repo_metadata(reproducible = False) ++ ++ rctx.download( ++ url = rctx.attr.urls, + output = ".downloaded.pkg", + sha256 = rctx.attr.sha256, + canonical_id = " ".join(rctx.attr.urls),