Skip to content

Commit

Permalink
python: hide symbols except for PyInit on macOS (#1506)
Browse files Browse the repository at this point in the history
Description: This PR modifies the build recipe for `envoy_engine.so` to hide all symbols except for `_PyInit_envoy_engine` by default on maOS, so that envoy_engine can be loaded alongside a [protobuf](http://pypi.org/project/protobuf) wheel without breaking.

Loading in protobuf alongside `envoy_engine.so` would register two sets of the same symbols and, on macOS, the runtime linker chooses the first symbol it finds causing problems. See the [similar protobuf change](protocolbuffers/protobuf#8346) and its [sister change in grpc](grpc/grpc#24992) for more information on what's going on.

Risk Level: Low
Testing: See the now-closed #1504 for how I've been testing this.
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: Cerek Hillen <[email protected]>
  • Loading branch information
crockeo authored Jun 8, 2021
1 parent 6c6685c commit 4ded40e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/python/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ pybind_extension(
srcs = [
"module_definition.cc",
],
linkopts = select({
"//bazel:darwin": ["-Wl,-exported_symbol,_PyInit_envoy_engine"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
":envoy_engine_lib",
Expand Down

0 comments on commit 4ded40e

Please sign in to comment.