Skip to content

Commit

Permalink
Enables runtime linking for darwin platforms (#766)
Browse files Browse the repository at this point in the history
Runtime linking with rpaths works correctly on darwin with only this
change, for dylibs that have the correct extension (dylib) and the
correct rpath configuration. Runtime linking against dynamic libraries
created by bazel targets remains broken, due to them not having install
names set correctly. That is fixed by using
--incompatible_macos_set_install_name after
bazelbuild/bazel#13427.
  • Loading branch information
csmulhern committed Jun 14, 2021
1 parent 087bcab commit 2d951b4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,12 @@ def _compute_rpaths(toolchain, output_dir, dep_info):
dylibs = [lib for lib in preferreds if lib.basename.endswith(toolchain.dylib_ext) or lib.basename.split(".", 2)[1] == toolchain.dylib_ext[1:]]
if not dylibs:
return depset([])
if toolchain.os != "linux":

# For darwin, dylibs compiled by Bazel will fail to be resolved at runtime
# without a version of Bazel that includes
# https://github.com/bazelbuild/bazel/pull/13427. This is known to not be
# included in Bazel 4.1 and below.
if toolchain.os != "linux" and toolchain.os != "darwin":
fail("Runtime linking is not supported on {}, but found {}".format(
toolchain.os,
dep_info.transitive_noncrates,
Expand Down

0 comments on commit 2d951b4

Please sign in to comment.