tweag / clodl

Turn dynamically linked ELF binaries and libraries into self-contained closures.
BSD 3-Clause "New" or "Revised" License
164 stars 6 forks source link

Closures of binaries without runfiles fail to build #25

Closed facundominguez closed 5 years ago

facundominguez commented 5 years ago

The following example fails.

cc_binary(
  name = "hello-cc",
  srcs = ["main.c"],
  linkopts = ["-shared"],
)

binary_closure(
    name = "clotestbin",
    src = "hello-cc",
)

A rule we have to get the runfiles of a binary complains that it produces an empty output, and the rules that use it also don't like having a label producing no files.

ERROR: /home/facundo/tweag/clodl/BUILD:73:1: in _expose_runfiles rule //:clotestbin-closure-runfiles: 
Traceback (most recent call last):
    File "/home/facundo/tweag/clodl/BUILD", line 73
        _expose_runfiles(name = 'clotestbin-closure-runfiles')
    File "/tmp/bazel/_bazel_facundo/31d856e5632fce7175cf6a803d2d4fa7/external/io_tweag_clodl/clodl/clodl.bzl", line 179, in _expose_runfiles_impl
        ctx.actions.run_shell(outputs = output_libs_files, input..., <2 more arguments>)
action outputs may not be empty

And after some more hacking to workaround that

ERROR: /home/facundo/tweag/clodl/BUILD:73:1: in srcs attribute of cc_binary rule //:clotestbin-closure_wrapper: '//:clotestbin-closure-runfiles' does not produce any cc_binary srcs files (expected .cc, .cpp, .cxx, .c++, .C, .c, .h, .hh, .hpp, .ipp, .hxx, .inc, .S, .s, .asm, .a, .lib, .pic.a, .lo, .pic.lo, .so, .dylib, .dll, .o or .pic.o). Since this rule was created by the macro 'binary_closure', the error might have been caused by the macro implementation in /tmp/bazel/_bazel_facundo/31d856e5632fce7175cf6a803d2d4fa7/external/io_tweag_clodl/clodl/clodl.bzl:351:16