From e0e7a4ca461bee7eb3cfe638323a61cf522bb6f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Fri, 21 Apr 2023 17:00:03 +0300 Subject: [PATCH] Rename bazel-zig-cc to hermetic_cc_toolchain (#36) As it says on the tin. Long live hermetic_cc_toolchain! --- .gitignore | 2 +- BUILD | 2 +- LICENSE | 1 + README.md | 66 ++++++++++++++-------------- WORKSPACE | 2 +- ci/launcher | 2 +- ci/release | 2 +- ci/test | 2 +- go.mod | 2 +- rules/rules_go.bzl | 4 +- test/c/BUILD | 2 +- test/cgo/BUILD | 4 +- test/glibc_hacks/BUILD | 2 +- test/gorace/BUILD | 2 +- test/gorace/main.go | 2 +- test/windows/BUILD | 2 +- toolchain/BUILD.sdk.bazel | 4 +- toolchain/defs.bzl | 19 ++++---- toolchain/launcher.zig | 10 ++--- toolchain/libc/BUILD | 2 +- toolchain/libc/defs.bzl | 2 +- toolchain/libc_aware/platform/BUILD | 2 +- toolchain/libc_aware/toolchain/BUILD | 2 +- toolchain/platform/BUILD | 2 +- toolchain/platform/defs.bzl | 2 +- toolchain/private/cc_toolchains.bzl | 2 +- toolchain/toolchain/BUILD | 2 +- toolchain/toolchain/defs.bzl | 2 +- tools/releaser/BUILD | 2 +- tools/releaser/WORKSPACE | 2 +- tools/releaser/main.go | 16 +++---- 31 files changed, 85 insertions(+), 85 deletions(-) diff --git a/.gitignore b/.gitignore index 9cfbf7f..6ff1580 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ *~ *.sw[op] -/bazel-bazel-zig-cc +/bazel-hermetic_cc_toolchain /bazel-bin /bazel-out /bazel-testlogs diff --git a/BUILD b/BUILD index 89e74b0..24209a3 100644 --- a/BUILD +++ b/BUILD @@ -6,7 +6,7 @@ load("@bazel_gazelle//:def.bzl", "gazelle") # gazelle:map_kind go_binary go_binary //rules:rules_go.bzl # gazelle:build_file_name BUILD -# gazelle:prefix github.com/uber/bazel-zig-cc +# gazelle:prefix github.com/uber/hermetic_cc_toolchain # gazelle:exclude tools.go gazelle(name = "gazelle") diff --git a/LICENSE b/LICENSE index e650850..2e2cc5e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,5 @@ Copyright 2021-2022 bazel-zig-cc contributors +Copyright 2023 hermetic_cc_toolchain contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index 709279d..7857518 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,17 @@ -[![builds.sr.ht status](https://builds.sr.ht/~motiejus/bazel-zig-cc.svg)](https://builds.sr.ht/~motiejus/bazel-zig-cc) +# Hermetic CC toolchain -# Bazel zig cc toolchain - -This is a C/C++ toolchain that can (cross-)compile C/C++ programs. It contains -clang-15, musl, glibc 2-2.34, all in a ~40MB package. Read +This is a C/C++ toolchain that can (cross-)compile C/C++ programs on top of +`zig cc`. It contains clang-16, musl, glibc 2-2.34, all in a ~40MB package. +Read [here](https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html) about zig-cc; the rest of the README will present how to use this toolchain from Bazel. Configuring toolchains in Bazel is complex, under-documented, and fraught with -peril. I, the co-author of bazel-zig-cc, am still confused on how this all -works, and often wonder why it works at all. That aside, we made the our best -effort to make bazel-zig-cc usable for your C/C++/CGo projects, with as many -guardrails as we could install. +peril. I, the co-author of `hermetic_cc_toolchain`, am still confused on how +this all works, and often wonder why it works at all. That aside, we made the +our best effort to make `hermetic_cc_toolchain` usable for your C/C++/CGo +projects, with as many guardrails as we could install. While copy-pasting the code in your project, attempt to read and understand the text surrounding the code snippets. This will save you hours of head @@ -20,10 +19,12 @@ scratching, I promise. # Project Origin -This repository is based on Adam Bouhenguel's [bazel-zig-cc][ajbouh], then -developed at `sr.ht/~motiejus/bazel-zig-cc` and finally moved to -[github.com/uber](https://github.com/uber). Many thanks to Adam who built the -very first functional version of Bazel and Zig integration. +This repository is based on Adam Bouhenguel's [bazel-zig-cc][ajbouh], later +developed at `sr.ht/~motiejus/bazel-zig-cc`. After a while it was moved to +[github.com/uber](https://github.com/uber) and renamed to +`hermetic_cc_toolchain`. Our special thanks to Adam for creating the original +version and publishing it, his contribution helped make the idea to use Zig +with Bazel at Uber a reality; now we all can benefit from it. Previously communications were done in an email list; the past archive is in `mailing-list-archive.mbox`. It can be accessed like this: @@ -35,19 +36,19 @@ Previously communications were done in an email list; the past archive is in Add this to your `WORKSPACE`: ``` -BAZEL_ZIG_CC_VERSION = "v1.0.1" +HERMETIC_CC_TOOLCHAIN_VERSION = "v1.0.1" http_archive( - name = "bazel-zig-cc", + name = "hermetic_cc_toolchain", sha256 = "e9f82bfb74b3df5ca0e67f4d4989e7f1f7ce3386c295fd7fda881ab91f83e509", - strip_prefix = "bazel-zig-cc-{}".format(BAZEL_ZIG_CC_VERSION), + strip_prefix = "bazel-zig-cc-{}".format(HERMETIC_CC_TOOLCHAIN_VERSION), urls = [ - "https://mirror.bazel.build/github.com/uber/bazel-zig-cc/releases/download/{0}/{0}.tar.gz".format(BAZEL_ZIG_CC_VERSION), - "https://github.com/uber/bazel-zig-cc/releases/download/{0}/{0}.tar.gz".format(BAZEL_ZIG_CC_VERSION), + "https://mirror.bazel.build/github.com/uber/hermetic_cc_toolchain/releases/download/{0}/{0}.tar.gz".format(HERMETIC_CC_TOOLCHAIN_VERSION), + "https://github.com/uber/hermetic_cc_toolchain/releases/download/{0}/{0}.tar.gz".format(HERMETIC_CC_TOOLCHAIN_VERSION), ], ) -load("@bazel-zig-cc//toolchain:defs.bzl", zig_toolchains = "toolchains") +load("@hermetic_cc_toolchain//toolchain:defs.bzl", zig_toolchains = "toolchains") # version, url_formats and host_platform_sha256 are optional for those who # want to control their Zig SDK version. @@ -70,13 +71,13 @@ The snippets above will download the zig toolchain and make the bazel toolchains available for registration and usage. If you do nothing else, this may work. The `.bazelrc` snippet instructs Bazel to use the registered "new kinds of toolchains". All above are required regardless of how wants to use it. -The next steps depend on how one wants to use bazel-zig-cc. The descriptions +The next steps depend on how one wants to use `hermetic_cc_toolchain`. The descriptions below is a gentle introduction to C++ toolchains from "user's perspective" too. ## Use case: manually build a single target with a specific zig cc toolchain This option is least disruptive to the workflow compared to no hermetic C++ -toolchain, and works best when trying out or getting started with bazel-zig-cc +toolchain, and works best when trying out or getting started with `hermetic_cc_toolchain` for a subset of targets. To request Bazel to use a specific toolchain (compatible with the specified @@ -180,7 +181,7 @@ build --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 From Bazel's perspective, this is almost equivalent to always specifying `--extra_toolchains` on every `bazel <...>` command-line invocation. It also means there is no way to disable the toolchain with the command line. This is -useful if you find bazel-zig-cc useful enough to compile for all of your +useful if you find `hermetic_cc_toolchain` useful enough to compile for all of your targets and tools. With `BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1` Bazel stops detecting the default @@ -304,9 +305,9 @@ SIGILL: illegal instruction This flag encourages program authors to fix the undefined behavior. There are [many ways][ubsan2] to find the undefined behavior. -# Known Issues In bazel-zig-cc +# Known Issues In `hermetic_cc_toolchain` -These are the things you may stumble into when using bazel-zig-cc. I am +These are the things you may stumble into when using `hermetic_cc_toolchain`. I am unlikely to implement them any time soon, but patches implementing those will be accepted. See [Questions & Contributions](#questions-amp-contributions) on how to contribute. @@ -341,7 +342,7 @@ currently targets the lowest version, without ability to change it. # Known Issues In Upstream This section lists issues that I've stumbled into when using `zig cc`, and is -outside of bazel-zig-cc's control. +outside of `hermetic_cc_toolchain`'s control. ## using glibc 2.27 or older @@ -400,7 +401,7 @@ The tests are running (CId) on linux-amd64. ## Transient docker environment -A standalone Docker environment to play with bazel-zig-cc: +A standalone Docker environment to play with `hermetic_cc_toolchain`: ``` $ docker run -e CC=/usr/bin/false -ti --rm -v "$PWD:/x" -w /x debian:bullseye-slim @@ -418,7 +419,7 @@ We maintain two channels for comms: # Maintainers -This section lists the driving forces behind bazel-zig-cc. Committers have push +This section lists the driving forces behind `hermetic_cc_toolchain`. Committers have push access, maintainers have their areas. Should make it easier to understand our interests when reading patches or mailing lists. @@ -432,16 +433,17 @@ You may find contact information of the individuals in the commit logs. # Publicity -This section lists notable uses or mentions of bazel-zig-cc. +This section lists notable uses or mentions of `bazel-zig-cc` (before the +rename) and afterwards of the `hermetic_cc_toolchain`. -- 2023-01-24 [bazel-zig-cc v1.0.0][bazel-zig-cc-v1]: releasing bazel-zig-cc and - admitting that bazel-zig-cc is used in production to compile all of Uber's - [Go Monorepo][go-monorepo]. +- 2023-01-24 [bazel-zig-cc v1.0.0][bazel-zig-cc-v1]: + releasing `bazel-zig-cc` and telling that `bazel-zig-cc` + is used in production to compile all of Uber's [Go Monorepo][go-monorepo]. - 2022-11-18 [BazelCon 2022: Making Uber's hermetic C++ toolchain][bazelcon2022]: Laurynas Lubys presents the story of how this repository came into being and how it was used (as of the conference). - 2022-05-23 [How Zig is used at Uber (youtube)][yt-how-zig-is-used-at-uber]: - Yours Truly (the author) talks about how bazel-zig-cc came to existence and + Yours Truly (the author) talks about how `bazel-zig-cc` came to existence and how it's used at Uber in Milan Zig Meetup. - 2022-05-23 [How Uber uses Zig][how-uber-uses-zig]: text version of the above. - 2022-03-30 [Google Open Source Peer Bonus Program][google-award] awarded the diff --git a/WORKSPACE b/WORKSPACE index e1b4454..ad683cf 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,5 +1,5 @@ workspace( - name = "bazel-zig-cc", + name = "hermetic_cc_toolchain", ) load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") diff --git a/ci/launcher b/ci/launcher index ee9a757..d35696a 100755 --- a/ci/launcher +++ b/ci/launcher @@ -23,5 +23,5 @@ echo "--- zig fmt --check toolchain/launcher.zig" $ZIG fmt --check toolchain/launcher.zig echo "--- zig test toolchain/launcher.zig" -# until bazel-zig-cc gets a zig toolchain, run launcher's unit tests here. +# until hermetic_cc_toolchain gets a zig toolchain, run launcher's unit tests here. $ZIG test toolchain/launcher.zig diff --git a/ci/release b/ci/release index db37c21..5b299a0 100755 --- a/ci/release +++ b/ci/release @@ -12,4 +12,4 @@ tools/bazel run //tools/releaser -- -tag v99.0.0 cleanup() { git tag -d v99.0.0; git reset --hard "$prev_ref"; } trap cleanup EXIT -file bazel-zig-cc-v99.0.0.tar.gz | grep -q 'gzip compressed data' +file hermetic_cc_toolchain-v99.0.0.tar.gz | grep -q 'gzip compressed data' diff --git a/ci/test b/ci/test index fe426b8..7b1befd 100755 --- a/ci/test +++ b/ci/test @@ -5,7 +5,7 @@ set -xeuo pipefail -cache_prefix="${BAZEL_ZIG_CC_CACHE_PREFIX:-/tmp/bazel-zig-cc}" +cache_prefix="${HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX:-/tmp/hermetic_cc_toolchain}" # check a very hermetic setup with a single target. Re-building all of # them takes a long time, so using only one. If we ever decide to build all diff --git a/go.mod b/go.mod index 0c9effb..4751d3d 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/uber/bazel-zig-cc +module github.com/uber/hermetic_cc_toolchain go 1.19 diff --git a/rules/rules_go.bzl b/rules/rules_go.bzl index abbbb6e..a830248 100644 --- a/rules/rules_go.bzl +++ b/rules/rules_go.bzl @@ -9,9 +9,9 @@ gc_linkopts values that are needed to compile for macos target. To use it, add this map_kind gazelle directive to your BUILD.bazel files where target binary needs to be compiled with zig toolchain. -Example: if this toolchain is registered as bazel-zig-cc in your WORKSPACE, add this to +Example: if this toolchain is registered as hermetic_cc_toolchain in your WORKSPACE, add this to your root BUILD file -# gazelle:map_kind go_binary go_binary @bazel-zig-cc//rules:rules_go.bzl +# gazelle:map_kind go_binary go_binary @hermetic_cc_toolchain//rules:rules_go.bzl """ _MACOS_GC_LINKOPTS = ["-s", "-w", "-buildmode=pie"] diff --git a/test/c/BUILD b/test/c/BUILD index a91459f..bfabbf4 100644 --- a/test/c/BUILD +++ b/test/c/BUILD @@ -1,4 +1,4 @@ -load("@bazel-zig-cc//rules:platform.bzl", "platform_binary") +load("@hermetic_cc_toolchain//rules:platform.bzl", "platform_binary") cc_binary( name = "which_libc", diff --git a/test/cgo/BUILD b/test/cgo/BUILD index 04c0881..b362c6e 100644 --- a/test/cgo/BUILD +++ b/test/cgo/BUILD @@ -3,13 +3,13 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") load("//rules:rules_go.bzl", "go_binary") -load("@bazel-zig-cc//rules:platform.bzl", "platform_binary", "platform_test") +load("@hermetic_cc_toolchain//rules:platform.bzl", "platform_binary", "platform_test") go_library( name = "cgo_lib", srcs = ["cgo.go"], cgo = True, - importpath = "github.com/uber/bazel-zig-cc/test/cgo", + importpath = "github.com/uber/hermetic_cc_toolchain/test/cgo", visibility = ["//visibility:private"], ) diff --git a/test/glibc_hacks/BUILD b/test/glibc_hacks/BUILD index 03bbc8c..2d72db8 100644 --- a/test/glibc_hacks/BUILD +++ b/test/glibc_hacks/BUILD @@ -1,7 +1,7 @@ # Copyright 2023 Uber Technologies, Inc. # Licensed under the MIT License -load("@bazel-zig-cc//rules:platform.bzl", "platform_binary") +load("@hermetic_cc_toolchain//rules:platform.bzl", "platform_binary") cc_binary( name = "main", diff --git a/test/gorace/BUILD b/test/gorace/BUILD index b40d777..402cc5a 100644 --- a/test/gorace/BUILD +++ b/test/gorace/BUILD @@ -9,7 +9,7 @@ go_library( srcs = ["main.go"], # keep cgo = True, - importpath = "github.com/uber/bazel-zig-cc/test/gorace", + importpath = "github.com/uber/hermetic_cc_toolchain/test/gorace", visibility = ["//visibility:private"], ) diff --git a/test/gorace/main.go b/test/gorace/main.go index 831c41e..ca7c36b 100644 --- a/test/gorace/main.go +++ b/test/gorace/main.go @@ -9,7 +9,7 @@ // More context: https://github.com/ziglang/zig/issues/11398 // // This fails, because `zig cc` adds `--gc-sections` to the linker -// flag by default, which is incompatible with cgo. bazel-zig-cc +// flag by default, which is incompatible with cgo. hermetic_cc_toolchain // adds a workaround for it. package main diff --git a/test/windows/BUILD b/test/windows/BUILD index 25356fd..e48de62 100644 --- a/test/windows/BUILD +++ b/test/windows/BUILD @@ -1,7 +1,7 @@ # Copyright 2023 Uber Technologies, Inc. # Licensed under the MIT License -load("@bazel-zig-cc//rules:platform.bzl", "platform_binary", "platform_test") +load("@hermetic_cc_toolchain//rules:platform.bzl", "platform_binary", "platform_test") cc_binary( name = "winver", diff --git a/toolchain/BUILD.sdk.bazel b/toolchain/BUILD.sdk.bazel index 245c237..de92402 100644 --- a/toolchain/BUILD.sdk.bazel +++ b/toolchain/BUILD.sdk.bazel @@ -1,8 +1,8 @@ # Copyright 2023 Uber Technologies, Inc. # Licensed under the MIT License -load("@bazel-zig-cc//toolchain:defs.bzl", "declare_files") -load("@bazel-zig-cc//toolchain/private:cc_toolchains.bzl", "declare_cc_toolchains") +load("@hermetic_cc_toolchain//toolchain:defs.bzl", "declare_files") +load("@hermetic_cc_toolchain//toolchain/private:cc_toolchains.bzl", "declare_cc_toolchains") package( default_visibility = ["//visibility:public"], diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl index 80f3dd7..8b119b5 100644 --- a/toolchain/defs.bzl +++ b/toolchain/defs.bzl @@ -1,7 +1,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "read_user_netrc", "use_netrc") -load("@bazel-zig-cc//toolchain/private:defs.bzl", "target_structs", "zig_tool_path") +load("@hermetic_cc_toolchain//toolchain/private:defs.bzl", "target_structs", "zig_tool_path") # Directories that `zig c++` includes behind the scenes. _DEFAULT_INCLUDE_DIRECTORIES = [ @@ -13,11 +13,8 @@ _DEFAULT_INCLUDE_DIRECTORIES = [ # Official recommended version. Should use this when we have a usable release. URL_FORMAT_RELEASE = "https://ziglang.org/download/{version}/zig-{host_platform}-{version}.{_ext}" -# Caution: nightly releases are purged from ziglang.org after ~90 days. A real -# solution would be to allow the downstream project specify their own mirrors. -# This is explained in -# https://sr.ht/~motiejus/bazel-zig-cc/#alternative-download-urls and is -# awaiting my attention or your contribution. +# Caution: nightly releases are purged from ziglang.org after ~90 days. Use the +# Bazel mirror or your own. URL_FORMAT_NIGHTLY = "https://ziglang.org/builds/zig-{host_platform}-{version}.{_ext}" # Official Bazel's mirror with selected Zig SDK versions. Bazel community is @@ -176,19 +173,19 @@ def _zig_repository_impl(repository_ctx): sha256 = zig_sha256, ) - cache_prefix = repository_ctx.os.environ.get("BAZEL_ZIG_CC_CACHE_PREFIX", "") + cache_prefix = repository_ctx.os.environ.get("HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX", "") if cache_prefix == "": if os == "windows": - cache_prefix = "C:\\\\Temp\\\\bazel-zig-cc" + cache_prefix = "C:\\\\Temp\\\\hermetic_cc_toolchain" else: - cache_prefix = "/tmp/bazel-zig-cc" + cache_prefix = "/tmp/hermetic_cc_toolchain" repository_ctx.template( "tools/launcher.zig", Label("//toolchain:launcher.zig"), executable = False, substitutions = { - "{BAZEL_ZIG_CC_CACHE_PREFIX}": cache_prefix, + "{HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX}": cache_prefix, }, ) @@ -244,7 +241,7 @@ zig_repository = repository_rule( "url_formats": attr.string_list(allow_empty = False), "host_platform_ext": attr.string_dict(), }, - environ = ["BAZEL_ZIG_CC_CACHE_PREFIX"], + environ = ["HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX"], implementation = _zig_repository_impl, ) diff --git a/toolchain/launcher.zig b/toolchain/launcher.zig index 6e7c790..4b2f078 100644 --- a/toolchain/launcher.zig +++ b/toolchain/launcher.zig @@ -36,14 +36,14 @@ // complain that the compiler is using undeclared directories on the host file // system. We do not declare prerequisites using absolute paths, because that // busts Bazel's remote cache. -// * BAZEL_ZIG_CC_CACHE_PREFIX is configurable per toolchain instance, and +// * HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX is configurable per toolchain instance, and // ZIG_GLOBAL_CACHE_DIR and ZIG_LOCAL_CACHE_DIR must be set to its value for // all `zig` invocations. // // Originally this was a Bash script, then a POSIX shell script, then two -// scripts (one with pre-defined BAZEL_ZIG_CC_CACHE_PREFIX, one without). Then -// Windows came along with two PowerShell scripts (ports of the POSIX shell -// scripts), which I kept breaking. Then Bazel 6 came with +// scripts (one with pre-defined HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX, one +// without). Then Windows came along with two PowerShell scripts (ports of the +// POSIX shell scripts), which I kept breaking. Then Bazel 6 came with // `--experimental_use_hermetic_linux_sandbox`, which hermetizes the sandbox to // the extreme: the sandbox has nothing that is not declared. /bin/sh and its // dependencies (/lib/x86_64-linux-gnu/libc.so.6 on my system) are obviously @@ -67,7 +67,7 @@ const EXE = switch (builtin.target.os.tag) { else => "", }; -const CACHE_DIR = "{BAZEL_ZIG_CC_CACHE_PREFIX}"; +const CACHE_DIR = "{HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX}"; const usage_cpp = \\ diff --git a/toolchain/libc/BUILD b/toolchain/libc/BUILD index 6b56057..984caff 100644 --- a/toolchain/libc/BUILD +++ b/toolchain/libc/BUILD @@ -1,7 +1,7 @@ # Copyright 2023 Uber Technologies, Inc. # Licensed under the MIT License -load("@bazel-zig-cc//toolchain/libc:defs.bzl", "declare_libcs") +load("@hermetic_cc_toolchain//toolchain/libc:defs.bzl", "declare_libcs") package( default_visibility = ["//visibility:public"], diff --git a/toolchain/libc/defs.bzl b/toolchain/libc/defs.bzl index d55d072..230c9f8 100644 --- a/toolchain/libc/defs.bzl +++ b/toolchain/libc/defs.bzl @@ -1,7 +1,7 @@ # Copyright 2023 Uber Technologies, Inc. # Licensed under the MIT License -load("@bazel-zig-cc//toolchain/private:defs.bzl", "LIBCS") +load("@hermetic_cc_toolchain//toolchain/private:defs.bzl", "LIBCS") def declare_libcs(): for libc in LIBCS: diff --git a/toolchain/libc_aware/platform/BUILD b/toolchain/libc_aware/platform/BUILD index 386f7df..d4ae626 100644 --- a/toolchain/libc_aware/platform/BUILD +++ b/toolchain/libc_aware/platform/BUILD @@ -1,7 +1,7 @@ # Copyright 2023 Uber Technologies, Inc. # Licensed under the MIT License -load("@bazel-zig-cc//toolchain/platform:defs.bzl", "declare_libc_aware_platforms") +load("@hermetic_cc_toolchain//toolchain/platform:defs.bzl", "declare_libc_aware_platforms") package( default_visibility = ["//visibility:public"], diff --git a/toolchain/libc_aware/toolchain/BUILD b/toolchain/libc_aware/toolchain/BUILD index 18f5a46..8c6370f 100644 --- a/toolchain/libc_aware/toolchain/BUILD +++ b/toolchain/libc_aware/toolchain/BUILD @@ -1,7 +1,7 @@ # Copyright 2023 Uber Technologies, Inc. # Licensed under the MIT License -load("@bazel-zig-cc//toolchain/toolchain:defs.bzl", "declare_libc_aware_toolchains") +load("@hermetic_cc_toolchain//toolchain/toolchain:defs.bzl", "declare_libc_aware_toolchains") package( default_visibility = ["//visibility:public"], diff --git a/toolchain/platform/BUILD b/toolchain/platform/BUILD index f43b852..9d779b4 100644 --- a/toolchain/platform/BUILD +++ b/toolchain/platform/BUILD @@ -1,4 +1,4 @@ -load("@bazel-zig-cc//toolchain/platform:defs.bzl", "declare_platforms") +load("@hermetic_cc_toolchain//toolchain/platform:defs.bzl", "declare_platforms") package( default_visibility = ["//visibility:public"], diff --git a/toolchain/platform/defs.bzl b/toolchain/platform/defs.bzl index 07e69a6..a2a37c5 100644 --- a/toolchain/platform/defs.bzl +++ b/toolchain/platform/defs.bzl @@ -1,4 +1,4 @@ -load("@bazel-zig-cc//toolchain/private:defs.bzl", "LIBCS") +load("@hermetic_cc_toolchain//toolchain/private:defs.bzl", "LIBCS") _CPUS = (("x86_64", "amd64"), ("aarch64", "arm64")) _OS = { diff --git a/toolchain/private/cc_toolchains.bzl b/toolchain/private/cc_toolchains.bzl index a9c0fba..43d6a99 100644 --- a/toolchain/private/cc_toolchains.bzl +++ b/toolchain/private/cc_toolchains.bzl @@ -1,5 +1,5 @@ load(":defs.bzl", "target_structs", "zig_tool_path") -load("@bazel-zig-cc//toolchain:zig_toolchain.bzl", "zig_cc_toolchain_config") +load("@hermetic_cc_toolchain//toolchain:zig_toolchain.bzl", "zig_cc_toolchain_config") DEFAULT_TOOL_PATHS = { "ar": "ar", diff --git a/toolchain/toolchain/BUILD b/toolchain/toolchain/BUILD index 7192d86..552fcaa 100644 --- a/toolchain/toolchain/BUILD +++ b/toolchain/toolchain/BUILD @@ -1,4 +1,4 @@ -load("@bazel-zig-cc//toolchain/toolchain:defs.bzl", "declare_toolchains") +load("@hermetic_cc_toolchain//toolchain/toolchain:defs.bzl", "declare_toolchains") package( default_visibility = ["//visibility:public"], diff --git a/toolchain/toolchain/defs.bzl b/toolchain/toolchain/defs.bzl index 24a90cc..50cc881 100644 --- a/toolchain/toolchain/defs.bzl +++ b/toolchain/toolchain/defs.bzl @@ -1,4 +1,4 @@ -load("@bazel-zig-cc//toolchain/private:defs.bzl", "target_structs") +load("@hermetic_cc_toolchain//toolchain/private:defs.bzl", "target_structs") def declare_toolchains(): for target_config in target_structs(): diff --git a/tools/releaser/BUILD b/tools/releaser/BUILD index d02b63b..028926c 100644 --- a/tools/releaser/BUILD +++ b/tools/releaser/BUILD @@ -7,7 +7,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "releaser_lib", srcs = ["main.go"], - importpath = "github.com/uber/bazel-zig-cc/tools/releaser", + importpath = "github.com/uber/hermetic_cc_toolchain/tools/releaser", visibility = ["//visibility:private"], ) diff --git a/tools/releaser/WORKSPACE b/tools/releaser/WORKSPACE index 92be942..430beed 100644 --- a/tools/releaser/WORKSPACE +++ b/tools/releaser/WORKSPACE @@ -1 +1 @@ -workspace(name = "bazel-zig-cc") +workspace(name = "hermetic_cc_toolchain") diff --git a/tools/releaser/main.go b/tools/releaser/main.go index 159e855..5707190 100644 --- a/tools/releaser/main.go +++ b/tools/releaser/main.go @@ -1,7 +1,7 @@ // Copyright 2023 Uber Technologies, Inc. // Licensed under the MIT License -// releaser is a tool for managing part of the process to release a new version of bazel-zig-cc. +// releaser is a tool for managing part of the process to release a new version of hermetic_cc_toolchain. package main import ( @@ -50,7 +50,7 @@ func run() (_err error) { tag string ) - flag.StringVar(&repoRoot, "repo_root", os.Getenv("BUILD_WORKSPACE_DIRECTORY"), "root directory of bazel-zig-cc repo") + flag.StringVar(&repoRoot, "repo_root", os.Getenv("BUILD_WORKSPACE_DIRECTORY"), "root directory of hermetic_cc_toolchain repo") flag.StringVar(&tag, "tag", "", "tag for this release") flag.Usage = func() { @@ -93,7 +93,7 @@ This utility is intended to handle many of the steps to release a new version. } } - fpath := path.Join(repoRoot, fmt.Sprintf("bazel-zig-cc-%s.tar.gz", tag)) + fpath := path.Join(repoRoot, fmt.Sprintf("hermetic_cc_toolchain-%s.tar.gz", tag)) tgz, err := os.Create(fpath) if err != nil { return err @@ -119,7 +119,7 @@ This utility is intended to handle many of the steps to release a new version. "archive", "--format=tar", // WORKSPACE in the resulting tarball needs to be much - // smaller than of bazel-zig-cc. See #15. + // smaller than of hermetic_cc_toolchain. See #15. "--add-file=tools/releaser/WORKSPACE", tag, }, _paths...)..., @@ -151,15 +151,15 @@ func genBoilerplate(version, shasum string) string { return fmt.Sprintf(`load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( - name = "bazel-zig-cc", + name = "hermetic_cc_toolchain", sha256 = "%[2]s", urls = [ - "https://mirror.bazel.build/github.com/uber/bazel-zig-cc/releases/download/%[1]s/bazel-zig-cc-%[1]s.tar.gz", - "https://github.com/uber/bazel-zig-cc/releases/download/%[1]s/bazel-zig-cc-%[1]s.tar.gz", + "https://mirror.bazel.build/github.com/uber/hermetic_cc_toolchain/releases/download/%[1]s/hermetic_cc_toolchain-%[1]s.tar.gz", + "https://github.com/uber/hermetic_cc_toolchain/releases/download/%[1]s/hermetic_cc_toolchain-%[1]s.tar.gz", ], ) -load("@bazel-zig-cc//toolchain:defs.bzl", zig_toolchains = "toolchains") +load("@hermetic_cc_toolchain//toolchain:defs.bzl", zig_toolchains = "toolchains") # plain zig_toolchains() will pick reasonable defaults. See # toolchain/defs.bzl:toolchains on how to change the Zig SDK path and version.