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
This commit is contained in:
Stepan Hruda
2025-04-04 23:03:16 +00:00
committed by PyTorch MergeBot
parent 2a2ddff214
commit 2e23768d25
2 changed files with 19 additions and 2 deletions

View File

@ -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",

View File

@ -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",