rules_perl icon indicating copy to clipboard operation
rules_perl copied to clipboard

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

Open PiotrSikora opened this issue 3 years ago • 2 comments

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.

PiotrSikora avatar Mar 24 '21 07:03 PiotrSikora

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.

skeletonkey avatar Mar 25 '21 04:03 skeletonkey

@skeletonkey friendly ping.

PiotrSikora avatar Jun 03 '21 18:06 PiotrSikora