diff --git a/bazel/include/llvm.MODULE.bazel b/bazel/include/llvm.MODULE.bazel index 800961be..ee899e74 100644 --- a/bazel/include/llvm.MODULE.bazel +++ b/bazel/include/llvm.MODULE.bazel @@ -1,143 +1,8 @@ -"LLVM configuration" - -bazel_dep(name = "toolchains_llvm", version = "1.3.0") -single_version_override( - module_name = "toolchains_llvm", - patch_strip = 1, - patches = [ - "//:patches/toolchains_llvm.patch", - ], -) +# LLVM toolchain required for compiling binary with cgo +bazel_dep(name = "toolchains_llvm", version = "1.5.0") llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") -llvm.toolchain( - name = "llvm_toolchain", - llvm_versions = { - # Default to version 16. Used for linux-aarch64 - "": "16.0.0", - "darwin-aarch64": "15.0.6", - "linux-x86_64": "14.0.0", - }, - sha256 = { - "darwin-aarch64": "32bc7b8eee3d98f72dd4e5651e6da990274ee2d28c5c19a7d8237eb817ce8d91", - "linux-x86_64": "564fcbd79c991e93fdf75f262fa7ac6553ec1dd04622f5d7db2a764c5dc7fac6", - }, - stdlib = { - "darwin-aarch64": "libc", - "linux-x86_64": "libc", - }, - strip_prefix = { - "darwin-aarch64": "clang+llvm-15.0.6-arm64-apple-darwin21.0", - "linux-x86_64": "clang+llvm-14.0.0-x86_64-linux-gnu", - }, - urls = { - "darwin-aarch64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.6/clang+llvm-15.0.6-arm64-apple-darwin21.0.tar.xz"], - "linux-x86_64": ["https://github.com/aspect-forks/llvm-project/releases/download/aspect-release-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu.tar.xz"], - }, -) -llvm.sysroot( - name = "llvm_toolchain", - label = "@org_chromium_sysroot_linux_x86_64//:sysroot", - targets = ["linux-x86_64"], -) -llvm.sysroot( - name = "llvm_toolchain", - label = "@org_chromium_sysroot_linux_arm64//:sysroot", - targets = ["linux-aarch64"], -) -llvm.sysroot( - name = "llvm_toolchain", - label = "@sysroot_darwin_universal//:sysroot", - targets = [ - "darwin-aarch64", - "darwin-x86_64", - ], -) +llvm.toolchain(llvm_version = "19.1.0") use_repo(llvm, "llvm_toolchain") -http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "org_chromium_sysroot_linux_arm64", - build_file_content = """ -filegroup( - name = "sysroot", - srcs = glob(["*/**"]), - visibility = ["//visibility:public"], -) -""", - sha256 = "cf2fefded0449f06d3cf634bfa94ffed60dbe47f2a14d2900b00eb9bcfb104b8", - urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/80fc74e431f37f590d0c85f16a9d8709088929e8/debian_bullseye_arm64_sysroot.tar.xz"], -) - -http_archive( - name = "org_chromium_sysroot_linux_x86_64", - build_file_content = """ -filegroup( - name = "sysroot", - srcs = glob(["*/**"]), - visibility = ["//visibility:public"], -) -""", - sha256 = "04b94ba1098b71f8543cb0ba6c36a6ea2890d4d417b04a08b907d96b38a48574", - urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/f5f68713249b52b35db9e08f67184cac392369ab/debian_bullseye_amd64_sysroot.tar.xz"], -) - -http_archive( - name = "sysroot_darwin_universal", - build_file_content = """ -filegroup( - name = "sysroot", - srcs = glob( - include = ["**"], - exclude = ["**/*:*"], - ), - visibility = ["//visibility:public"], -) -""", - # The ruby header has an infinite symlink that we need to remove. - patch_cmds = ["rm System/Library/Frameworks/Ruby.framework/Versions/Current/Headers/ruby/ruby"], - sha256 = "71ae00a90be7a8c382179014969cec30d50e6e627570af283fbe52132958daaf", - strip_prefix = "MacOSX11.3.sdk", - urls = ["https://s3.us-east-2.amazonaws.com/static.aspect.build/sysroots/MacOSX11.3.sdk.tar.xz"], -) - -execution_oses = [ - "macos", - "linux", -] - -execution_cpus = [ - "aarch64", - "x86_64", -] - -target_oses = [ - "macos", - "linux", -] - -target_cpus = [ - "aarch64", - "x86_64", -] - -platforms = [ - { - "exe_os": exe_os, - "exe_cpu": exe_cpu, - "tgt_os": tgt_os, - "tgt_cpu": tgt_cpu, - } - for exe_os in execution_oses - for exe_cpu in execution_cpus - for tgt_os in target_oses - for tgt_cpu in target_cpus -] - -[register_toolchains("//platforms/toolchains:{}_{}_{}_{}_llvm".format( - p["exe_os"], - p["exe_cpu"], - p["tgt_os"], - p["tgt_cpu"], -)) for p in platforms] +register_toolchains("@llvm_toolchain//:all") diff --git a/go.mod b/go.mod index 48833a61..ca4f4904 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/aspect-build/aspect-cli-legacy -go 1.24.9 +go 1.25.4 require ( github.com/alphadose/haxmap v1.4.1 diff --git a/patches/aspect-gazelle-runner.patch b/patches/aspect-gazelle-runner.patch deleted file mode 100644 index 639fbe59..00000000 --- a/patches/aspect-gazelle-runner.patch +++ /dev/null @@ -1,10 +0,0 @@ -diff --git a/runner/MODULE.bazel b/runner/MODULE.bazel -index edfb9dbf..45ed1f0a 100644 ---- a/runner/MODULE.bazel -+++ b/runner/MODULE.bazel -@@ -72,5 +72,3 @@ go_deps2.module_override( - path = "github.com/bazelbuild/bazel-gazelle", - ) - --# For cgo --include("//:llvm.MODULE.bazel") diff --git a/patches/toolchains_llvm.patch b/patches/toolchains_llvm.patch deleted file mode 100644 index ea81fe23..00000000 --- a/patches/toolchains_llvm.patch +++ /dev/null @@ -1,78 +0,0 @@ -diff --git a/toolchain/cc_toolchain_config.bzl b/toolchain/cc_toolchain_config.bzl -index 9dbb41d..12c4ccb 100644 ---- a/toolchain/cc_toolchain_config.bzl -+++ b/toolchain/cc_toolchain_config.bzl -@@ -168,11 +168,17 @@ def cc_toolchain_config( - archive_flags = [] - - # Linker flags: -- if exec_os == "darwin" and not is_xcompile: -- # lld is experimental for Mach-O, so we use the native ld64 linker. -- # TODO: How do we cross-compile from Linux to Darwin? -- use_lld = False -+ ld = "ld.lld" -+ if target_os == "darwin": -+ use_lld = True -+ -+ ld = "ld64.lld" -+ ld_path = toolchain_path_prefix + "/bin/" + ld -+ compile_flags.append("-mmacosx-version-min=12.0") - link_flags.extend([ -+ "-mmacosx-version-min=12.0", -+ "-Wl,-platform_version,macos,12.0,12.0", -+ "--ld-path=" + ld_path, - "-headerpad_max_install_names", - "-fobjc-link-runtime", - ]) -@@ -195,7 +201,9 @@ def cc_toolchain_config( - # not an option because it is not a cross-linker, so lld is the - # only option. - use_lld = True -+ ld_path = toolchain_path_prefix + "/bin/" + ld - link_flags.extend([ -+ "--ld-path=" + ld_path, - "-fuse-ld=lld", - "-Wl,--build-id=md5", - "-Wl,--hash-style=gnu", -@@ -228,10 +236,6 @@ def cc_toolchain_config( - if use_lld: - # For single-platform builds, we can statically link the bundled - # libraries. -- link_flags.extend([ -- "-l:libc++.a", -- "-l:libc++abi.a", -- ]) - compiler_rt_link_flags = ["-rtlib=compiler-rt"] - libunwind_link_flags = [ - "-l:libunwind.a", -@@ -283,9 +287,6 @@ def cc_toolchain_config( - "-stdlib=libstdc++", - ] - -- link_flags.extend([ -- "-l:libstdc++.a", -- ]) - elif stdlib == "libc": - cxx_flags = [ - "-std=" + cxx_standard, -@@ -323,7 +324,7 @@ def cc_toolchain_config( - "dwp": tools_path_prefix + "llvm-dwp", - "gcc": wrapper_bin_prefix + "cc_wrapper.sh", - "gcov": tools_path_prefix + "llvm-profdata", -- "ld": tools_path_prefix + "ld.lld" if use_lld else "/usr/bin/ld", -+ "ld": tools_path_prefix + ld if use_lld else "/usr/bin/ld", - "llvm-cov": tools_path_prefix + "llvm-cov", - "llvm-profdata": tools_path_prefix + "llvm-profdata", - "nm": tools_path_prefix + "llvm-nm", -diff --git a/toolchain/internal/common.bzl b/toolchain/internal/common.bzl -index 1feae98..6773380 100644 ---- a/toolchain/internal/common.bzl -+++ b/toolchain/internal/common.bzl -@@ -28,6 +28,7 @@ _toolchain_tools = { - for name in [ - "clang-cpp", - "ld.lld", -+ "ld64.lld", - "llvm-ar", - "llvm-dwp", - "llvm-profdata",