Subject: bazel-zig-cc v0.4.0-rc1

From: Motiejus Jakštys <[email-masked]>
Date: Mon, 13 Dec 2021 04:38:16 +0200

Hi folks,

I released v0.4.0-rc1; notable changes from v0.3.4:

- upgrade to zig 0.9.0-dev.1950+a76910b69. Now compilation on Darwin
  will fail if `-framework` was specified, but wasn't able to be
  linked[1]. This happens on darwin/arm64, which I had to disable CI
  for. A patch that passes `zig cc --sysroot=/path/to/sdk` is sought
  for, if you care about darwin/arm64 (or darwin in general).
- remove default `-O3`[2]. This now re-enables UBSAN by default, which
  is an important default in upstream[3].

v0.4.0 will be released when zig 0.9.0 is released, which is scheduled
for Dec 20.

About undefined behavior (removal of `-O3`)
-------------------------------------------

The second change broke my use of brotli, which relies on undefined
behaior[4]. This is my ugly way to mitigate it:

Project's WORKSPACE
```
BROTLI_COMMIT = "4ec67035c0d97c270c1c73038cc66fc5fcdfc120"

http_archive(
    name = "brotli",
    sha256 = "9f57c32e5903768a03900366d8a055d49c01ecbbded046dce47eae24115b58b8",
    strip_prefix = "brotli-%s" % BROTLI_COMMIT,
    urls = ["https://github.com/google/brotli/archive/%s.zip" % BROTLI_COMMIT],
    patch_args = ["-p1"],
    patches = [
        "//patches:brotli-disable-undefined-behavior.patch",
    ],
)
```

And the patch:
```
diff --git a/BUILD b/BUILD
index 07a6793..2b4d1c1 100644
--- a/BUILD
+++ b/BUILD
@@ -43,7 +43,7 @@ config_setting(
 
 create_msvc_config()
 
-STRICT_C_OPTIONS = select({
+STRICT_C_OPTIONS = ["-DBROTLI_BUILD_PORTABLE"] + select({
     ":msvc": [],
     "//conditions:default": [
         "--pedantic-errors",
```

If anyone has a better idea how to append a COPT to a downstream Bazel
project, I would be happy to learn from you.

Motiejus

[1]: https://github.com/ziglang/zig/pull/10312/
[2]: https://git.sr.ht/~motiejus/bazel-zig-cc/commit/985e26b474fb7594bb385ce9382def7c95373ca9
[3]: https://github.com/ziglang/zig/issues/4830#issuecomment-605491606
[4]: https://github.com/google/brotli/blob/ce222e317e36aa362e83fc50c7a6226d238e03fd/CMakeLists.txt#L104-L108