Skip to content

Commit

Permalink
Remove unnecessary rpath special handling on macOS
Browse files Browse the repository at this point in the history
Based on
bazelbuild/bazel#10254 (comment)
and bazelbuild/bazel#12304 being fixed, this
special handling of rpaths on macOS appears to be unnecessary.

This cleanup ensures that Bazel sets the correct metadata for the exec
location of Go libraries linked in c-shared mode, which in turn allows
to not include them in the runfiles of all dependents - cc_* targets
depending on them will now generate the correct rpath entries to find
the libraries at runtime at the usual position.
  • Loading branch information
fmeum committed May 12, 2022
1 parent 498d6ce commit e26eda6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
8 changes: 0 additions & 8 deletions go/private/actions/link.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ load(
)
load(
"//go/private:mode.bzl",
"LINKMODE_C_SHARED",
"LINKMODE_NORMAL",
"LINKMODE_PLUGIN",
"extld_from_cc_toolchain",
Expand Down Expand Up @@ -108,13 +107,6 @@ def emit_link(
if go.mode.link == LINKMODE_PLUGIN:
tool_args.add("-pluginpath", archive.data.importpath)

# TODO: Rework when https://github.com/bazelbuild/bazel/pull/12304 is mainstream
if go.mode.link == LINKMODE_C_SHARED and (go.mode.goos in ["darwin", "ios"]):
extldflags.extend([
"-install_name",
rpath.install_name(executable),
])

arcs = _transitive_archives_without_test_archives(archive, test_archives)
arcs.extend(test_archives)
if (go.coverage_enabled and go.coverdata and
Expand Down
6 changes: 0 additions & 6 deletions go/private/rules/binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ load(
"LINKMODE_PLUGIN",
"LINKMODE_SHARED",
)
load(
"//go/private:rpath.bzl",
"rpath",
)

_EMPTY_DEPSET = depset([])

Expand All @@ -69,8 +65,6 @@ def new_cc_import(
static_library = None,
alwayslink = False,
linkopts = []):
if dynamic_library:
linkopts = linkopts + rpath.flags(go, dynamic_library)
return CcInfo(
compilation_context = cc_common.create_compilation_context(
defines = defines,
Expand Down

0 comments on commit e26eda6

Please sign in to comment.