-
Notifications
You must be signed in to change notification settings - Fork 520
Description
I've made this minimum working example Bazel workspace (.zip) to demonstrate the problem I'm having building rust_bindgen_library targets on ArchLinux.
It just has a rust_bindgen_library rule pointing to a trivial cc_library and its header file. bindgen_toolchain resolves to the example-bindgen-toolchain (i.e. the one registered while calling the rust_bindgen_repositories() workspace rule).
I cannot bazel build //... this workspace on my ArchLinux system. I get the following error.
ERROR: missing input file '@local_libstdcpp//:libstdc++.so.6'
ERROR: /home/dwtj/.cache/bazel/_bazel_dwtj/b8ac5acf45adefed9426377fa8b7244a/external/local_libstdcpp/BUILD.bazel:2:1: @local_libstdcpp//:libstdc++: missing input file '@local_libstdcpp//:libstdc++.so.6'
ERROR: /home/dwtj/.cache/bazel/_bazel_dwtj/b8ac5acf45adefed9426377fa8b7244a/external/local_libstdcpp/BUILD.bazel:2:1 1 input file(s) do not exist
The problem appears to be that @local_libstdcpp's symlink to libstdc++.so is broken.
lrwxrwxrwx 1 dwtj dwtj 40 Sep 19 15:37 /home/dwtj/.cache/bazel/_bazel_dwtj/b8ac5acf45adefed9426377fa8b7244a/external/local_libstdcpp/libstdc++.so.6 -> /usr/lib/x86_64-linux-gnu/libstdc++.so.6
But libstdc++.so.6 is not located at that location on my ArchLinux system. It is at /usr/lib/libstdc++.so.6.
I think that the problem stems from assumption about Linux made here:
rules_rust/bindgen/repositories.bzl
Lines 76 to 79 in f727669
| def _local_libstdcpp_impl(repository_ctx): | |
| os = repository_ctx.os.name.lower() | |
| if os == "linux": | |
| repository_ctx.symlink("/usr/lib/x86_64-linux-gnu/libstdc++.so.6", "libstdc++.so.6") |
Presumably this is the usual location of libstdc++.so.6 on other distros.
I realize that I can work around this issue by creating and registering my own bindgen_toolchain instance, following example-bindgen-toolchain as a guide. That's my next move.
The current example-bindgen-toolchain implementation seems a bit brittle in how it creates this symlink. But I'm afraid that I don't know enough Bazel-fu to immediately recommend some way to make it less brittle.