bazelbuild / rules_proto

Protocol buffer rules for Bazel
Apache License 2.0
163 stars 70 forks source link

[Feature request] Allow users to recompile protoc #115

Open googleson78 opened 2 years ago

googleson78 commented 2 years ago

I would like to have some way to tell rules_proto "please recompile protoc".

I came upon this while trying to use rules_proto on nixos, which doesn't have ld in /lib64/ld-linux-x86-64.so.2, as is expected by the prebuilt binaries. If it's instead rebuilt, things work fine.

I've implemented some solution in #114

comius commented 2 years ago

Isn't it enough to set --proto_compiler=@com_github_protocolbuffers_protobuf//:protoc?

googleson78 commented 2 years ago

I didn't know that flag exists. Thanks :). But it still seems to not work for some reason - I get a binary that still depends on the linker in the usual place

raider :: » file ./bazel-out/k8-opt-exec-FFB32019/bin/external/com_google_protobuf_protoc_linux_x86_64/protoc.exe  

./bazel-out/k8-opt-exec-FFB32019/bin/external/com_google_protobuf_protoc_linux_x86_64/protoc.exe: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.18, BuildID[sha1]=1b078080620f7b15
0ba8d0a195d68275b03d075e, stripped

I think this forces bazel to recompile protoc, but rules_bazel still depends on the prebuilt version :thinking:

Yannic commented 2 years ago

Most Starlark rules hardcode @com_google_protobuf//:protoc because the flag is not exposed, so I'm not super surprised that doesn't work.

Can you share which language/<lang>_proto_library rule this is please?

googleson78 commented 2 years ago

go_proto_library and ts_proto_library both fail.

Yannic commented 2 years ago

As expected, go_proto_library hardcodes it: https://github.com/bazelbuild/rules_go/blob/8553d97674742ad4c110cffa999017db21052b97/proto/compiler.bzl#L218

comius commented 2 years ago

This is a problem of go_proto_library and ts_proto_library. I'm working on proposal that will expose the right functionality so those implementations can be fixed (but they can't be fixed at the moment).

https://docs.google.com/document/d/1dY_jfRvnH8SjRXGIfg8av-vquyWsvIZydXJOywvaR1A/edit