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]>
Signed-off-by: JP Simard <[email protected]>
  • Loading branch information
crockeo authored and jpsim committed Nov 29, 2022
1 parent 2beb367 commit e4d4127
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mobile/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 e4d4127

Please sign in to comment.