From 99bd291367a5420d9c7f5a47de6599e6ce122db1 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Mon, 6 Oct 2025 16:59:01 -0700 Subject: [PATCH] Build pthreadpool with hidden visibility on Apple --- CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7012ec641bf..ca5503a357b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -266,6 +266,18 @@ if(EXECUTORCH_BUILD_PTHREADPOOL) executorch_move_interface_include_directories_to_build_time_only( pthreadpool_interface ) + + if(APPLE) + # Use hidden visibility for pthreadpool on Apple platforms to avoid issues + # with pthreadpool symbols from libtorch_cpu taking precedence over the ones + # from the pthreadpool library statically linked in _portable_lib. The + # pthreadpool public APIs are marked as weak by default on some Apple + # platforms, so setting to hidden visibility works around this by not + # putting the symbol in the indirection table. See + # https://github.com/pytorch/executorch/issues/14321 for more details. + target_compile_options(pthreadpool PRIVATE -fvisibility=hidden) + endif() + install( TARGETS pthreadpool pthreadpool_interface fxdiv EXPORT ExecuTorchTargets