Skip to content

The provided example-bindgen-toolchain rule does not find libstdc++.so.6 on ArchLinux because of a broken symlink #251

@dwtj

Description

@dwtj

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions