Closed daviddrysdale closed 4 years ago
WDYT @tiziano88 @ipetr0v @anghelcovici (as folk who've fought build systems in the past)
Thanks for writing this down @daviddrysdale .
I think part of the complication here is trying to keep all the examples and the tests working while we switch language underneath them.
IIRC:
All in all, I feel more and more strongly that we are not too far off from a pure cargo-buildable binary with no C++ dependencies; if others think that that is at least plausible, I think we should aim for that and cut down the extra complexity of maintaining the dual language split within the same binary.
cc @project-oak/core
I agree that we may need to move towards pure Rust build, because currently it looks like cargo raze
supports only basic features and is still in the early stages of development. Thus ring
may not be the last problematic library we encounter.
Also a random thought: C++ Nodes (such as a TPU wrapper, i.e. Nodes that will be much easier to implement in C++) probably don't have to be a part of the Oak process. Instead they may be implemented as separate services that will use gRPC to communicate with Oak and attest to it. This might be useful, because in this case we will define an external ABI that then will be used to communicate between different Oak instances.
Regarding roughenough, I had a look at it previously. It seems to have a fully functional client, but most of the client functionality is built directly into the binary rather than a reusable lib. So we would need to vendor it into third_party
to change the client to a library. It should not be too much work though.
Indeed there is not much logic to the roughtime client after all, it's just doing requests and parsing responses, it is only a few dozens lines, it's not even worth vendoring IMO, we should be able to re-implement it ourselves: https://github.com/int08h/roughenough/blob/master/src/bin/roughenough-client.rs .
@ipetr0v : that's right, in fact I think when @rbehjati explored the TPU options, we also discussed that the simplest solution would be to just externalize it as a stand-alone gRPC server.
all considered, my proposal is:
@daviddrysdale sorry I realize I missed one of the points you were trying to make in this issue, that is, IIUC, having cargo invoke bazel as part of the build process (perhaps via a build.rs file) to build any remaining C++ code that we have, and then convince cargo to link that in the final binary. I think this would be a nice solution, but I still think that we are not too far off from being able to migrate (at least in principle) all the remaining C++ code to Rust, at which point I personally don't think there would be much value in keeping around the cargo to bazel part of the workflow just in case we come up with some other C++ dependency (which I don't think it's likely in the short-medium term, but also definitely not impossible).
Done in #1016.
We currently have Bazel as our primary build system, which builds a C++
main
, C++ libraries, and includes Rust libraries that are invoked over FFI.We're expecting to move
main
over to Rust under #724, and the obvious initial way to do this is with arust_binary
target in Bazel, keeping the rest of the build system roughly as-is1.However, we could consider moving the primary build system across to be Cargo. That would still require some way of building the C++ code and its dependencies, presumably still Bazel. So:
build.rs
script would invoke Bazel and ensure that a gianteverything-cpp.a
thing got linked in a known place.The following issues should all evaporate if we moved away from Bazel:
851: Remove Bazel warnings about canonical reproducible forms for Cargo crates
850 : Get Prost-built code auto-generating in Bazel
944: Make Bazel-built binaries fully static
875: Rust dependencies not synced between Cargo and Bazel
(and in fact we could presumably lose
//cargo/
andcargo raze
altogether)1: Aside: it's not that simple.
2: Useful phrase from https://github.com/bazelbuild/rules_rust/issues/78 : "underlinking" seems to mean leaving resolution of undefined symbols until final link of the binary.