bazelbuild / bazelbuild/rules_rust
The provided `example-bindgen-toolchain` rule does not find `libstdc++.so.6` on ArchLinux because of a broken symlink
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
I've made [this minimum working example Bazel workspace](https://github.com/bazelbuild/rules_rust/files/3634145/bazel_rust_bindgen.zip) (`.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:
https://github.com/bazelbuild/rules_rust/blob/f727669b8ac3c9d237ed9bc7833b8e1eeec90506/bindgen/repositories.bzl#L76-L79
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.
Contributor guide
Assessment
This issue has not been assessed yet.