From e26eda6667f97e39df4b95faff7607783e83757e Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Thu, 12 May 2022 17:56:58 +0200 Subject: [PATCH] Remove unnecessary rpath special handling on macOS Based on https://github.com/bazelbuild/bazel/issues/10254#issuecomment-1125218345 and https://github.com/bazelbuild/bazel/pull/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. --- go/private/actions/link.bzl | 8 -------- go/private/rules/binary.bzl | 6 ------ 2 files changed, 14 deletions(-) diff --git a/go/private/actions/link.bzl b/go/private/actions/link.bzl index 1a2e680004..3acbccbf80 100644 --- a/go/private/actions/link.bzl +++ b/go/private/actions/link.bzl @@ -20,7 +20,6 @@ load( ) load( "//go/private:mode.bzl", - "LINKMODE_C_SHARED", "LINKMODE_NORMAL", "LINKMODE_PLUGIN", "extld_from_cc_toolchain", @@ -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 diff --git a/go/private/rules/binary.bzl b/go/private/rules/binary.bzl index 8d95020ef9..8211b43aa4 100644 --- a/go/private/rules/binary.bzl +++ b/go/private/rules/binary.bzl @@ -40,10 +40,6 @@ load( "LINKMODE_PLUGIN", "LINKMODE_SHARED", ) -load( - "//go/private:rpath.bzl", - "rpath", -) _EMPTY_DEPSET = depset([]) @@ -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,