From 2b239ba1a0870cb3de15c199464429ecc3e69ca4 Mon Sep 17 00:00:00 2001 From: Jamie Snape Date: Thu, 3 Dec 2026 22:20:28 -0500 Subject: [PATCH 1/2] Port hermetic_cc_toolchain Bazel setup from RVO2 Signed-off-by: Jamie Snape --- .bazelrc | 13 +++++-- .github/workflows/bazel.yml | 71 +++++++++++++++++++++++++------------ BUILD.bazel | 6 +--- MODULE.bazel | 26 +++++++++----- examples/BUILD.bazel | 7 +--- src/BUILD.bazel | 7 +--- 6 files changed, 80 insertions(+), 50 deletions(-) diff --git a/.bazelrc b/.bazelrc index 0179a67..01e3b6f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,13 +36,20 @@ build --incompatible_default_to_explicit_init_py=true build --remote_upload_local_results=false build --sandbox_default_allow_network=false +build:alpine --@rules_python//python/config_settings:py_linux_libc=musl +build:alpine --platforms=@zig_sdk//libc_aware/platform:linux_amd64_musl + +build:linux --dynamic_mode=off build:linux --force_pic=true +build:linux --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 +build:linux --sandbox_add_mount_pair=/tmp -build:macos --apple_generate_dsym=true -build:macos --apple_crosstool_top=@local_config_apple_cc//:toolchain -build:macos --apple_platform_type=macos +build:macos --dynamic_mode=off build:macos --force_pic=true +build:macos --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 +build:macos --sandbox_add_mount_pair=/var/tmp +build:windows --extra_toolchains=@local_config_cc//:all build:windows --linkopt=/IGNORE:4315 common --enable_platform_specific_config=true diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index efcaeea..eec4a0f 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -63,12 +63,10 @@ jobs: id: setup run: | dnf makecache -q --refresh || (sleep 15; dnf makecache -q --refresh) - dnf upgrade -q -y dnf install -q -y \ ca-certificates \ - gcc-c++ \ git \ - python3 \ + glibc-devel \ wget \ which dnf clean all @@ -86,7 +84,7 @@ jobs: uses: actions/checkout@v7.0.1 with: persist-credentials: false - - name: cache bazel + - name: cache uses: actions/cache@v6.1.0 with: path: | @@ -102,6 +100,43 @@ jobs: ... shell: bash + bazel-alpine: + name: bazel alpine linux amd64 + runs-on: ubuntu-latest + container: alpine:3 + timeout-minutes: 30 + steps: + - name: setup + id: setup + run: | + echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing" \ + >> /etc/apk/repositories + apk add --no-cache \ + bazel \ + ca-certificates \ + git + . /etc/os-release + echo "os=${ID}-${VERSION_ID}" >> "$GITHUB_OUTPUT" + shell: sh + - name: checkout + uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + - name: cache + uses: actions/cache@v6.1.0 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.setup.outputs.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'MODULE.bazel', '**/*.bazel', '**/*.bzl') }} # yamllint disable-line rule:line-length + restore-keys: ${{ runner.os }}-${{ runner.arch }}-${{ steps.setup.outputs.os }}-bazel- # yamllint disable-line rule:line-length + - name: build test package + run: | + bazel test \ + --config=alpine \ + --features=treat_warnings_as_errors \ + --flaky_test_attempts=3 \ + ... + shell: sh + bazel-arch: name: bazel arch linux amd64 runs-on: ubuntu-latest @@ -113,9 +148,7 @@ jobs: run: | pacman --needed --noconfirm --noprogressbar -S -u -y \ ca-certificates \ - gcc \ git \ - python \ wget \ which rm -rf \ @@ -134,7 +167,7 @@ jobs: uses: actions/checkout@v7.0.1 with: persist-credentials: false - - name: cache bazel + - name: cache uses: actions/cache@v6.1.0 with: path: | @@ -160,12 +193,10 @@ jobs: id: setup run: | dnf makecache -q --refresh || (sleep 15; dnf makecache -q --refresh) - dnf upgrade -q -y dnf install -q -y \ ca-certificates \ - gcc-c++ \ git \ - python3 \ + glibc-devel \ wget \ which dnf clean all @@ -183,7 +214,7 @@ jobs: uses: actions/checkout@v7.0.1 with: persist-credentials: false - - name: cache bazel + - name: cache uses: actions/cache@v6.1.0 with: path: | @@ -220,7 +251,7 @@ jobs: uses: actions/checkout@v7.0.1 with: persist-credentials: false - - name: cache bazel + - name: cache uses: actions/cache@v6.1.0 with: path: | @@ -247,12 +278,10 @@ jobs: id: setup run: | zypper -n -q ref || (sleep 15; zypper -n -q ref) - zypper -n -q up zypper -n -q in --no-recommends \ ca-certificates \ - gcc-c++ \ git \ - python3 \ + glibc-devel \ wget \ which zypper -n -q cc -a @@ -269,7 +298,7 @@ jobs: uses: actions/checkout@v7.0.1 with: persist-credentials: false - - name: cache bazel + - name: cache uses: actions/cache@v6.1.0 with: path: | @@ -303,7 +332,6 @@ jobs: ca-certificates \ g++ \ git \ - python-is-python3 \ wget apt-get -qq -o Dpkg::Use-Pty=0 autoremove rm -rf /var/lib/apt/lists/* @@ -322,7 +350,7 @@ jobs: uses: actions/checkout@v7.0.1 with: persist-credentials: false - - name: cache bazel + - name: cache uses: actions/cache@v6.1.0 with: path: | @@ -356,7 +384,6 @@ jobs: ca-certificates \ g++ \ git \ - python-is-python3 \ wget apt-get -qq -o Dpkg::Use-Pty=0 autoremove rm -rf /var/lib/apt/lists/* @@ -375,7 +402,7 @@ jobs: uses: actions/checkout@v7.0.1 with: persist-credentials: false - - name: cache bazel + - name: cache uses: actions/cache@v6.1.0 with: path: | @@ -469,7 +496,7 @@ jobs: uses: actions/checkout@v7.0.1 with: persist-credentials: false - - name: cache bazel + - name: cache uses: actions/cache@v6.1.0 with: path: | @@ -560,7 +587,7 @@ jobs: uses: actions/checkout@v7.0.1 with: persist-credentials: false - - name: cache bazel + - name: cache uses: actions/cache@v6.1.0 with: path: | diff --git a/BUILD.bazel b/BUILD.bazel index 365015e..33a5842 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -181,11 +181,7 @@ pkg_deb( no_match_error = "Unsupported CPU for //:deb. Supported CPUs: aarch64, x86_64.", ), data = ":tar", - depends = [ - "libc6", - "libgcc-s1", - "libstdc++6", - ], + depends = ["libc6"], description = "Reciprocal Collision Avoidance with Acceleration-Velocity Obstacles", homepage = "https://gamma.cs.unc.edu/AVO/", license = "Apache-2", diff --git a/MODULE.bazel b/MODULE.bazel index 7f92d17..8590d8e 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -39,20 +39,30 @@ module( version = "1.0.1", ) -bazel_dep( - name = "apple_support", - version = "2.13.0", +bazel_dep(name = "hermetic_cc_toolchain", version = "4.3.0", dev_dependency = True) + +hermetic_cc_toolchain = use_extension( + "@hermetic_cc_toolchain//toolchain:ext.bzl", + "toolchains", dev_dependency = True, - repo_name = "build_bazel_apple_support", ) +use_repo(hermetic_cc_toolchain, "zig_sdk") -apple_cc_configure = use_extension( - "@build_bazel_apple_support//crosstool:setup.bzl", - "apple_cc_configure_extension", +register_toolchains( + "@zig_sdk//libc_aware/toolchain:all", + "@zig_sdk//toolchain:all", + dev_dependency = True, ) -use_repo(apple_cc_configure, "local_config_apple_cc") bazel_dep(name = "rules_cc", version = "0.2.29") + +cc_configure = use_extension( + "@rules_cc//cc:extensions.bzl", + "cc_configure_extension", + dev_dependency = True, +) +use_repo(cc_configure, "local_config_cc", "local_config_cc_toolchains") + bazel_dep(name = "rules_license", version = "1.0.0") bazel_dep(name = "rules_python", version = "2.5.2", dev_dependency = True) diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel index b9c20cc..527b622 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -91,14 +91,9 @@ cc_test( "/W4", ], "//conditions:default": [], - }) + select({ - "//conditions:linux_opt": [ - "-U_FORTIFY_SOURCE", - "-D_FORTIFY_SOURCE=3", - ], - "//conditions:default": [], }), defines = ["AVO_OUTPUT_TIME_AND_POSITIONS=0"] + select({ + "//conditions:linux_opt": ["_FORTIFY_SOURCE=3"], "//conditions:macos_opt": ["_FORTIFY_SOURCE=3"], "//conditions:default": [], }), diff --git a/src/BUILD.bazel b/src/BUILD.bazel index 1983593..e93e49f 100644 --- a/src/BUILD.bazel +++ b/src/BUILD.bazel @@ -126,12 +126,6 @@ cc_library( "/W4", ], "//conditions:default": [], - }) + select({ - "//conditions:linux_opt": [ - "-U_FORTIFY_SOURCE", - "-D_FORTIFY_SOURCE=3", - ], - "//conditions:default": [], }), linkopts = select({ "@platforms//os:linux": [ @@ -143,6 +137,7 @@ cc_library( "//conditions:default": [], }), local_defines = select({ + "//conditions:linux_opt": ["_FORTIFY_SOURCE=3"], "//conditions:macos_opt": ["_FORTIFY_SOURCE=3"], "@platforms//os:windows": ["AVO_EXPORTS"], "//conditions:default": [], From 66767ca23c08c4c43fdb405c19651558006aa491 Mon Sep 17 00:00:00 2001 From: Jamie Snape Date: Fri, 4 Dec 2026 21:27:31 -0500 Subject: [PATCH 2/2] Install GNU tar for Alpine cache and pass --copt=-Werror to Zig Bazel CI Signed-off-by: Jamie Snape --- .github/workflows/bazel.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index eec4a0f..8b59126 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -95,6 +95,7 @@ jobs: - name: build test package run: | bazel test \ + --copt=-Werror \ --features=treat_warnings_as_errors \ --flaky_test_attempts=3 \ ... @@ -114,7 +115,8 @@ jobs: apk add --no-cache \ bazel \ ca-certificates \ - git + git \ + tar . /etc/os-release echo "os=${ID}-${VERSION_ID}" >> "$GITHUB_OUTPUT" shell: sh @@ -132,6 +134,7 @@ jobs: run: | bazel test \ --config=alpine \ + --copt=-Werror \ --features=treat_warnings_as_errors \ --flaky_test_attempts=3 \ ... @@ -178,6 +181,7 @@ jobs: - name: build test package run: | bazel test \ + --copt=-Werror \ --features=treat_warnings_as_errors \ --flaky_test_attempts=3 \ ... @@ -225,6 +229,7 @@ jobs: - name: build test package run: | bazel test \ + --copt=-Werror \ --features=treat_warnings_as_errors \ --flaky_test_attempts=3 \ ... @@ -263,6 +268,7 @@ jobs: - name: build test package run: | bazel test \ + --copt=-Werror \ --features=treat_warnings_as_errors \ --flaky_test_attempts=3 \ ... @@ -309,6 +315,7 @@ jobs: - name: build test package run: | bazel test \ + --copt=-Werror \ --features=treat_warnings_as_errors \ --flaky_test_attempts=3 \ ... @@ -361,6 +368,7 @@ jobs: - name: build test package run: | bazel test \ + --copt=-Werror \ --features=treat_warnings_as_errors \ --flaky_test_attempts=3 \ ... @@ -413,6 +421,7 @@ jobs: - name: build test package run: | bazel test \ + --copt=-Werror \ --features=treat_warnings_as_errors \ --flaky_test_attempts=3 \ ...