Skip to content

Bring the CMake build up to date and add C and Rust output - #22

Open
dallison wants to merge 1 commit into
mainfrom
cmake-plugins-and-c-frontend
Open

dallison wants to merge 1 commit into
mainfrom
cmake-plugins-and-c-frontend

Conversation

@dallison

@dallison dallison commented Nov 6, 2026

Copy link
Copy Markdown
Owner

The CMake build had fallen behind the Bazel one, so phaser 3.1.1 cannot be built with CMake. Subspace's CMake CI fails on it: protoc-gen-phaser does not compile (phaser/plugins/ros/ros_codegen_helpers.h: No such file or directory).

What was missing

  • Plugin: the plugin sources (generator_plugin.cc, the C and Python emitters, and the Arrow, Avro, Parquet, protobuf and ROS codegen). Also the include paths that Bazel remaps with strip_include_prefix/include_prefix.
  • Runtime: payload_buffer.cc and message_property.cc.
  • Generated libraries: they did not link the descriptor bank or the Arrow, Avro and Parquet runtimes that generated code calls.
  • Frontends: there was no C frontend or Rust output.

Changes

  • Build the full plugin, with forwarding headers for the remapped include paths.
  • Add the phaser_bank_protobuf, phaser_arrow, phaser_avro, phaser_parquet and phaser_c libraries, and link them into generated libraries.
  • phaser_add_library takes FRONTEND c, and RUST for the Rust bindings over the C API. The bindings' source file is in the library's PHASER_RUST_SOURCE property.
  • Move the crate attributes out of rust_support.rs into rust_crate_attributes.rs, so that a Cargo crate can include!() the bindings. The Bazel rule prepends them, and its crate is unchanged.
  • Fetch protobuf whenever libprotobuf is missing, since phaser_bank_protobuf needs it in cross-compiles too.
  • Add a CMake smoke test project (cmake/smoke_test), and a CI job for it on Linux and macOS. It generates a library with each frontend, compiles the Rust bindings, and runs a program that reads a C++ message's native payload through the C API.

Testing

  • The smoke test builds and passes standalone on macOS, with phaser's own Abseil 20250814.1 and protobuf v34.1.
  • Subspace's CMake build passes on macOS with Abseil 20240722 and its protobuf. That includes the Rust client, which builds its bindings with RUST, and its Cargo tests.
  • Subspace's Android x86_64 cross-compile passes with a host plugin.
  • bazel test //phaser/testdata:phaser_rust_test passes, and the assembled crate is unchanged.

The CMake build had fallen behind the Bazel one. protoc-gen-phaser did not
compile, because the plugin sources and the include paths Bazel remaps were
missing. The runtime lacked payload_buffer.cc and message_property.cc, and
generated libraries did not link the descriptor bank or the Arrow, Avro and
Parquet runtimes that generated code calls.

- Build the full plugin, with forwarding headers for the remapped include
  paths.
- Add the phaser_bank_protobuf, phaser_arrow, phaser_avro, phaser_parquet and
  phaser_c libraries, and link them into generated libraries.
- phaser_add_library takes FRONTEND c, and RUST for the Rust bindings over the
  C API. Their source file is in the library's PHASER_RUST_SOURCE property.
- Move the crate attributes out of rust_support.rs into
  rust_crate_attributes.rs, so that a Cargo crate can include!() the bindings.
  The Bazel rule prepends them, and its crate is unchanged.
- Add a CMake smoke test project and a CI job that builds it, compiles the
  Rust bindings and runs a program that reads a C++ message through the C API.
dallison added a commit to dallison/subspace that referenced this pull request Nov 6, 2026
- crc32.cc included <nmmintrin.h> inside namespace subspace, which broke
  libc++ on Android x86_64, where SSE4.2 is on by default.
- The ASIL oversized response test bound a filesystem socket, but
  Connect() uses the abstract namespace on Linux.  On a failed connect it
  also hung, as closing a socket does not wake accept() on Linux.
- The CMake build of the Rust client had no Phaser bindings.  It now
  generates them with phaser's C frontend and links their C++ code into
  one shared library for Cargo.  The new phaser_c crate includes them.
- Pin phaser to dallison/phaser#22, which brings phaser's CMake build up
  to date and adds the C and Rust output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant