bazelbuild / rules_perl

Perl rules for Bazel
Apache License 2.0
25 stars 38 forks source link

C/C++ dependencies are completely ignored in "perl_xs" targets. #24

Open PiotrSikora opened 3 years ago

PiotrSikora commented 3 years ago

I expect those BUILD rules to work:

perl_xs(
    name = "CacheMemcachedFastXS",
    srcs = ["Fast.xs"],
    defines = [
        "VERSION=\"0.26\"",
        "XS_VERSION=\"0.26\"",
    ],
    output_loc = "arch/auto/Cache/Memcached/Fast/Fast.so",
    textual_hdrs = ["ppport.h"],
    typemaps = ["typemap"],
    deps = [":libclient"],
)

cc_library(
    name = "libclient",
    srcs = [
        "src/array.c",
        "src/array.h",
        "src/client.c",
        "src/compute_crc32.c",
        "src/compute_crc32.h",
        "src/connect.c",
        "src/connect.h",
        "src/dispatch_key.c",
        "src/dispatch_key.h",
        "src/parse_keyword.c",
        "src/parse_keyword.h",
        "src/socket_posix.c",
        "src/socket_posix.h",
    ],
    hdrs = [
        "src/client.h",
    ],
    copts = ["-I."],
    defines = [
        "HAVE_POLL_H",
    ],
    includes = [
        ".",
        "src",
    ],
)

(The complete example is available here: cache_memcached_fast.BUILD)

However, the :libclient dependency is completely ignored, and produced Fast.so is failing at runtime due to missing symbols. I'm not sure why Bazel doesn't pick up this dependency, since CcInfos are merged in perl.bzl.

I've spent more time looking into this that I'm willing to admit, but I couldn't make it work. Any ideas, @skeletonkey?

I can workaround this issue by pulling :libclient sources into :CacheMemcachedFastXS using #23 (see: diff), but that's literally a workaround and not a proper solution.

skeletonkey commented 3 years ago

Just want to let you know that I'm looking at this. This is a crazy week for me so I hope I can put some real time into this weekend.

PiotrSikora commented 3 years ago

@skeletonkey friendly ping.