bazel-central-registry icon indicating copy to clipboard operation
bazel-central-registry copied to clipboard

[Bug]: Many modules add `-lrt` as a linkopt, which only works on Linux

Open eyebrowsoffire opened this issue 1 year ago • 1 comments

What happened?

It appears many of the module definitions add the -lrt linkopt explicitly in their BUILD file definition. See for example https://github.com/bazelbuild/bazel-central-registry/blob/8645666979c124eb30d1b20d85f0040b9f0d7b38/modules/websocketpp/0.8.2/patches/add_build_file.patch#L16

This link option is only valid on Linux. Other platforms, such as macOS, this just causes a link failure.

Version

Development (host) and target OS/architectures: macOS 13.6.6 (22G630)

Output of bazel --version: bazel 7.1.2

How to reproduce

Just create a simple hello world that links on `websocketpp` as an example.

Build file:


cc_binary(
    name = "hello_world",
    srcs = [
        "main.cpp",
    ],
    deps = [
        "@websocketpp",
    ],
)

In the MODULE.bazel file:

bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "websocketpp", version = "0.8.2")


### Any other information?

I'm guessing probably this linkopt should be gated on a platform configuration so it is only added on linux.

eyebrowsoffire avatar May 12 '24 22:05 eyebrowsoffire

You could submit a new version (with a customary .bcr.1 suffix) and e.g. add a select based on the target platform.

fmeum avatar May 16 '24 06:05 fmeum

Please feel free to sent PRs! As the module contents aren't maintained centrally, this bug isn't going to be actionable. I'll go ahead and close it.

Wyverald avatar Jul 23 '24 22:07 Wyverald