Skip to content

Commit 2d951b4

Browse files
authored
Enables runtime linking for darwin platforms (#766)
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.
1 parent 087bcab commit 2d951b4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rust/private/rustc.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,12 @@ def _compute_rpaths(toolchain, output_dir, dep_info):
735735
dylibs = [lib for lib in preferreds if lib.basename.endswith(toolchain.dylib_ext) or lib.basename.split(".", 2)[1] == toolchain.dylib_ext[1:]]
736736
if not dylibs:
737737
return depset([])
738-
if toolchain.os != "linux":
738+
739+
# For darwin, dylibs compiled by Bazel will fail to be resolved at runtime
740+
# without a version of Bazel that includes
741+
# https://github.com/bazelbuild/bazel/pull/13427. This is known to not be
742+
# included in Bazel 4.1 and below.
743+
if toolchain.os != "linux" and toolchain.os != "darwin":
739744
fail("Runtime linking is not supported on {}, but found {}".format(
740745
toolchain.os,
741746
dep_info.transitive_noncrates,

0 commit comments

Comments
 (0)