Skip to content

Commit ea331e4

Browse files
committed
add mac flags for making extension
1 parent 438076b commit ea331e4

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tests/venv_site_packages_libs/ext_with_libs/BUILD.bazel

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,24 @@ cc_library(
3636
# todo: copy more from py_extension in local_toolchains
3737
cc_shared_library(
3838
name = "adder",
39+
# Necessary for several reasons:
40+
# 1. Ensures the output doesn't include increment itself (avoids ODRs)
41+
# 2. Adds -lincrement (DT_NEEDED for libincrement.so)
42+
# 3. Ensures libincrement.so is available at link time to satisfy (2)
3943
dynamic_deps = [":increment"],
40-
shared_lib_name = select({
41-
"//conditions:default": "adder.so",
42-
}),
44+
shared_lib_name = "adder.so",
4345
user_link_flags = [
4446
# NOTE: cc_shared_library adds Bazelized rpath entries, too.
4547
"-Wl,-rpath,$ORIGIN/libs",
46-
],
48+
] + select({
49+
"@platforms//os:osx": [
50+
"-undefined",
51+
"dynamic_lookup",
52+
"-Wl,-exported_symbol",
53+
"-Wl,_PyInit_adder",
54+
],
55+
"//conditions:default": [],
56+
}),
4757
deps = [":adder_impl"],
4858
)
4959

0 commit comments

Comments
 (0)