diff --git a/.bazelrc b/.bazelrc index 286ffcb4..a74f3894 100644 --- a/.bazelrc +++ b/.bazelrc @@ -32,8 +32,6 @@ build --host_cxxopt=-std=c++17 build --define absl=1 build:macos --macos_minimum_os=10.15 -# For compatible behavior on weak symbols. -build:macos --linkopt=-Wl,-undefined,dynamic_lookup # To create this file, please run: # diff --git a/centipede/BUILD b/centipede/BUILD index def96cd5..d657ad31 100644 --- a/centipede/BUILD +++ b/centipede/BUILD @@ -1034,7 +1034,10 @@ RUNNER_LINKOPTS = [ "-ldl", # for dlsym "-lpthread", # for pthread_once ] + select({ - "@platforms//os:macos": [], + "@platforms//os:macos": [ + # For compatible behavior on weak symbols. + "-Wl,-undefined,dynamic_lookup", + ], "//conditions:default": [ "-lrt", # for shm_open ], diff --git a/centipede/testing/BUILD b/centipede/testing/BUILD index 991b3e47..d3c17982 100644 --- a/centipede/testing/BUILD +++ b/centipede/testing/BUILD @@ -206,6 +206,15 @@ cc_library( cc_shared_library( name = "multi_dso_target_shared_lib", + user_link_flags = select( + { + "@platforms//os:macos": [ + # For compatible behavior on weak symbols. + "-Wl,-undefined,dynamic_lookup", + ], + "//conditions:default": [], + }, + ), deps = [":multi_dso_target_lib"], )