[protobuf] Skip sanitizers on protoc-gen-upbdefs

Fuchsia's ASan and HWASan builders enable `host_asan-ubsan`, which
instruments host `executable()` targets with LeakSanitizer. In upstream
protobuf (https://github.com/protocolbuffers/protobuf/issues/31490),
`GenerateReflectionHeader()` and `GenerateReflectionSource()` in
`upb_generator/reflection` do not delete the `ZeroCopyOutputStream*`
returned by `GeneratorContext::Open()`. That 32-byte leak fails
`protoc-gen-upbdefs` at build time under LeakSanitizer and blocks
https://fuchsia-review.googlesource.com/c/fuchsia/+/1953775. Upstream
Bazel `--config=asan` misses this because `proto_lang_toolchain` builds
plugins in the un-instrumented `exec` configuration.

Set `exclude_toolchain_tags = [ "instrumented" ]` on
`protoc-gen-upbdefs` when `is_fuchsia_tree` is true until a
`third_party/protobuf` roll includes the upstream fix.

Bug: 364925797
Test: fx --dir out/host_asan_test test --host tp_shell_test
Test: fx --dir out/host_asan_test test --host trace_importing_fxt_test
Change-Id: I7f27a93fe6169adf19fcaeda2bd09077bd5d2ef0
Reviewed-on: https://fuchsia-review.googlesource.com/c/protobuf-gn/+/1962671
Lint: android-build-ayeaye@system.gserviceaccount.com <android-build-ayeaye@system.gserviceaccount.com>
Reviewed-by: Anivia Li <aniviali@google.com>
2 files changed
tree: 543878a28c58152f616046c01ba503cb249ad612
  1. upb_generator/
  2. AUTHORS
  3. BUILD.gn
  4. BUILD.input.gn
  5. CONTRIBUTING.md
  6. gen.py
  7. LICENSE
  8. OWNERS
  9. PATENTS
  10. proto_library.gni
  11. protoc_wrapper.py
  12. README.md
README.md

Protocol Buffers GN Build Support

This repository contains GN build system support for Protocol Buffers. It's in its own repository because it needs to be shared by Fuchsia and Cobalt.

This repo should be checked out such that:

  • It is in //build/secondary/third_party/protobuf.
  • Protobuf is in //third_party/protobuf/src.
  • //.gn contains secondary_source = "//build/secondary/"

See the GN documentation on secondary_source.

Updating Build Files

WARNING: DO NOT MODIFY THE BUILD.gn FILE DIRECTLY!

The BUILD.gn file in this directory is generated automatically. Any manual changes will be overwritten.

To make changes to the build configuration:

  1. Edit the BUILD.input.gn file to suit your needs, for example managing visibility, suppressing warnings, etc.
  2. Run the gen.py script located in this directory to regenerate the BUILD.gn file:
    ./gen.py [commit_hash]
    
    If no commit hash is specified, it defaults to HEAD of //third_party/protobuf/src.
  3. Commit both the updated BUILD.input.gn and the newly generated BUILD.gn file.

Failing to modify BUILD.input.gn will result in your changes being lost the next time the build file is regenerated.