-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically linked cc binary doesn't work in genrule with remote execution #14264
Comments
FYI @coeuvre @oquenchil |
Sounds like this might be the same case as #13819 ? |
@keith Yes, thanks for the link, looks like the same issue. |
I'm not sure this is the same issue... The problem there was missing rpath entries, whereas here it's about resolving the path of the tool to run. As far as I understand,
This leads me to think a general solution has to be something like putting a symlink to or a wrapper script outside the runfiles dir, pointing to or invoking the actual binary under the runfiles dir. This is obviously far from trivial. Not wanting to diverge too much from mainline Bazel, our solution so far was to do the former in packaging rules, and if we'd ever need to run dynamically linked binaries in genrules, I imagine we'd go with the manual wrapper script. |
another related issue: #10809 |
Any progress on this issue? I've been running |
No progress since I don't have capacity to work on this yet. PR is welcome. |
This is also an issue when executing a binary from a custom rule, using |
I created a |
@meteorcloudy Your example works with Bazel 6.0.0, presumably due to c7aa392. |
Good to know, I'm glad my bug lived long enough to be fixed. |
Consider the following example:
Under directory <workspace>/foo:
bazel build :run
will succeed locally but fail with remote execution with:The reason is that //:main is dynamically linked to foo.so, and the rpath is
../_solib_local/_U_S_Sfoo_Cfoo___Ufoo/foo.so
.Locally it works, because
bazel-out/k8-opt/_solib_local
is always created for all so libs.But with remote execution, the same relative path is not created. Therefore the foo.so cannot be found.
However, inside the runfiles tree of //:main, the so file exists (also in remote execution), but you'll have run the main binary from the runfiles tree to make it work. So in genrule, you can use
"$(location :main).runfiles/<workspace name>/foo/main > $@"
, but this is obviously a hack.Possible solutions:
$(rlocation //:foo)
linkopts = ["-Wl,-rpath,$$ORIGIN/main.runfiles/org_tensorflow/_solib_local/_U_S_Sfoo_Cfoo___Ufoo"],
The text was updated successfully, but these errors were encountered: