Skip to content

Bindgen should use a downloaded or compiled libstdc++ shared lib #741

@UebelAndre

Description

@UebelAndre

Currently the rust_bindgen (rust-bindgen) rule depends on a local_repository to make libstdc++ binaries available to the rule.

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")
repository_ctx.file("BUILD.bazel", _LIBSTDCPP_BUILD_FILE.format("libstdc++.so.6"))
elif os.startswith("mac"):
repository_ctx.symlink("/usr/lib/libstdc++.6.dylib", "libstdc++.6.dylib")
repository_ctx.file("BUILD.bazel", _LIBSTDCPP_BUILD_FILE.format("libstdc++.6.dylib"))
else:
fail(os + " is not supported.")
repository_ctx.file("WORKSPACE.bazel", _COMMON_WORKSPACE.format(repository_ctx.name))
_local_libstdcpp = repository_rule(
implementation = _local_libstdcpp_impl,
)

This is pretty non-hermetic and I believe is the reason why we can't use the bindgen rules on MacOS. Instead, the rule should build it's own version of libstdc++ or use a pre-compiled one that exists in a shared location (not something that is installed to the host).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions