From eccbc976977fcafdf63764fb196c8aa84844b0fb Mon Sep 17 00:00:00 2001 From: Xuan Wang Date: Thu, 19 Oct 2023 09:48:35 -0700 Subject: [PATCH] [Python dist] Explicitly link Core Foundation framework for MacOS (#34395) Some user reported an issue that symbols from CoreFoundation are missing when install grpc/grpc-tools inside Conda: * https://github.com/grpc/grpc/issues/33714 * https://github.com/grpc/grpc/issues/34135 This PR adds the `-framework CoreFoundation` flag so no workarounds are required from user. --- setup.py | 5 +++++ tools/distrib/python/grpcio_tools/setup.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/setup.py b/setup.py index 94aa7793a79..613959550d4 100644 --- a/setup.py +++ b/setup.py @@ -293,6 +293,11 @@ if EXTRA_ENV_LINK_ARGS is None: if "linux" in sys.platform: EXTRA_ENV_LINK_ARGS += " -static-libgcc" +# Explicitly link Core Foundation framework for MacOS to ensure no symbol is +# missing when compiled using package managers like Conda. +if "darwin" in sys.platform: + EXTRA_ENV_LINK_ARGS += " -framework CoreFoundation" + EXTRA_COMPILE_ARGS = shlex.split(EXTRA_ENV_COMPILE_ARGS) EXTRA_LINK_ARGS = shlex.split(EXTRA_ENV_LINK_ARGS) diff --git a/tools/distrib/python/grpcio_tools/setup.py b/tools/distrib/python/grpcio_tools/setup.py index 5d6b8a0a974..c5c7243d233 100644 --- a/tools/distrib/python/grpcio_tools/setup.py +++ b/tools/distrib/python/grpcio_tools/setup.py @@ -190,6 +190,11 @@ if EXTRA_ENV_LINK_ARGS is None: if check_linker_need_libatomic(): EXTRA_ENV_LINK_ARGS += " -latomic" +# Explicitly link Core Foundation framework for MacOS to ensure no symbol is +# missing when compiled using package managers like Conda. +if "darwin" in sys.platform: + EXTRA_ENV_LINK_ARGS += " -framework CoreFoundation" + EXTRA_COMPILE_ARGS = shlex.split(EXTRA_ENV_COMPILE_ARGS) EXTRA_LINK_ARGS = shlex.split(EXTRA_ENV_LINK_ARGS)