From 6dd97f507312125274e155e309f61464b1308f99 Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Thu, 21 Nov 2019 01:36:09 -0800 Subject: [PATCH] Move dependency on libdl into build defs, like CMake PiperOrigin-RevId: 281699435 Change-Id: Iced13e98578b2c36a1eeac71fd02a6d7ed87a8fb --- sandboxed_api/BUILD.bazel | 4 ---- sandboxed_api/bazel/sapi.bzl | 13 +++++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/sandboxed_api/BUILD.bazel b/sandboxed_api/BUILD.bazel index ab456fc..b32dcba 100644 --- a/sandboxed_api/BUILD.bazel +++ b/sandboxed_api/BUILD.bazel @@ -161,10 +161,6 @@ cc_library( name = "client", srcs = ["client.cc"], copts = sapi_platform_copts(), - # TODO(124852776): investigate whether this is necessary - linkopts = [ - "-Wl,-ldl", - ], visibility = ["//visibility:public"], deps = [ ":call", diff --git a/sandboxed_api/bazel/sapi.bzl b/sandboxed_api/bazel/sapi.bzl index 2cc9f3c..25e72ea 100644 --- a/sandboxed_api/bazel/sapi.bzl +++ b/sandboxed_api/bazel/sapi.bzl @@ -205,9 +205,12 @@ def sapi_library( native.cc_binary( name = name + ".bin", linkopts = [ - # The sandboxing client must have access to all - "-Wl,-E", # symbols used in the sandboxed library, so these - ] + exported_funcs, # must be both referenced, and exported + "-ldl", # For dlopen(), dlsym() + # The sandboxing client must have access to all symbols used in + # the sandboxed library, so these must be both referenced, and + # exported + "-Wl,-E", + ] + exported_funcs, deps = [ ":" + name + ".lib", rprefix + "//sandboxed_api:client", @@ -217,9 +220,7 @@ def sapi_library( native.cc_library( name = name + ".lib", - deps = [ - lib, - ], + deps = [lib], alwayslink = 1, # All functions are linked into depending binaries **common )