From 2e23768d2521acec9314d07a4b418089848a0f26 Mon Sep 17 00:00:00 2001 From: Stepan Hruda Date: Fri, 4 Apr 2025 23:03:16 +0000 Subject: [PATCH] Expose symbols on macos in the xplat pytorch stack (#150487) Summary: X-link: https://github.com/pytorch/executorch/pull/9819 Had to revert D71321310 because it affected way too many targets and build sizes. These changes should expose just enough symbols to be buildable in arvr mode on macOS. Could potentially make narrow it down even more by avoiding eg `get_pt_compiler_flags` Differential Revision: D72255474 Pull Request resolved: https://github.com/pytorch/pytorch/pull/150487 Approved by: https://github.com/drisspg --- buckbuild.bzl | 17 +++++++++++++++-- third_party/xnnpack.buck.bzl | 4 ++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/buckbuild.bzl b/buckbuild.bzl index 29addd3bf724..b208a4d25c18 100644 --- a/buckbuild.bzl +++ b/buckbuild.bzl @@ -194,6 +194,9 @@ def get_pt_compiler_flags(): return select({ "DEFAULT": _PT_COMPILER_FLAGS, "ovr_config//compiler:cl": windows_convert_gcc_clang_flags(_PT_COMPILER_FLAGS), + }) + select({ + "DEFAULT": [], + "ovr_config//os:macos": ["-fvisibility=default"], }) _PT_COMPILER_FLAGS = [ @@ -228,6 +231,9 @@ ATEN_COMPILER_FLAGS = [ # Not supported by clang on Windows "DEFAULT": ["-fPIC"], "ovr_config//compiler:clang-windows": [], +}) + select({ + "DEFAULT": [], + "ovr_config//os:macos": ["-fvisibility=default"], }) def get_aten_compiler_flags(): @@ -982,6 +988,10 @@ def define_buck_targets( fb_xplat_cxx_library( name = "torch_mobile_headers", header_namespace = "", + compiler_flags = select({ + "DEFAULT": [], + "ovr_config//os:macos": ["-fvisibility=default"], + }), exported_headers = subdir_glob( [ ("", "torch/csrc/jit/mobile/*.h"), @@ -1185,7 +1195,10 @@ def define_buck_targets( srcs = [ "torch/csrc/jit/mobile/observer.cpp", ] + ([] if IS_OSS else ["torch/fb/observers/MobileObserverUtil.cpp"]), - compiler_flags = ["-fexceptions"], + compiler_flags = ["-fexceptions"] + select({ + "DEFAULT": [], + "ovr_config//os:macos": ["-fvisibility=default"], + }), header_namespace = "", exported_headers = subdir_glob( [ @@ -2035,7 +2048,7 @@ def define_buck_targets( "ovr_config//os:xtensa-xos": [ "-fdata-sections", "-ffunction-sections", - ], + ] }), exported_preprocessor_flags = get_pt_preprocessor_flags() + [ "-DMIN_EDGE_RUNTIME", diff --git a/third_party/xnnpack.buck.bzl b/third_party/xnnpack.buck.bzl index b20a7be4ed1a..231384bd859a 100644 --- a/third_party/xnnpack.buck.bzl +++ b/third_party/xnnpack.buck.bzl @@ -2249,6 +2249,10 @@ def define_xnnpack(third_party, labels = [], XNNPACK_WINDOWS_AVX512F_ENABLED = F exported_deps = [ ":subgraph", ], + compiler_flags = select({ + "DEFAULT": [], + "ovr_config//os:macos": ["-fvisibility=default"], + }), platforms = (APPLE, ANDROID, CXX, WINDOWS), preprocessor_flags = XNN_COMMON_PREPROCESSOR_FLAGS + [ "-DXNN_NO_Q8_OPERATORS",