Skip to content

Commit ed6e2e2

Browse files
authored
Qualcomm: expose PAL headers via header map so QNN runtime builds under Buck (pytorch#20321)
## Summary The PAL support added the `pal/` sources and headers directly to the QNN `runtime` target and resolved `#include <pal/...>` with a hardcoded `-Ibackends/qualcomm/runtime/pal/include` preprocessor flag. That `-I` path is resolved relative to the Buck project root, so it does not resolve correctly across build roots and `#include <pal/DynamicLoading.h>` / `<pal/Path.h>` fail to compile when building the QNN runtime under Buck. ## Fix Move the PAL sources and headers into a dedicated `pal` library and expose the headers through a **header map** (a dict `exported_headers` with an empty `header_namespace`) instead of an `-I` flag. `runtime` picks it up via `exported_deps`, so dependents that include `QnnImplementation.h` resolve `<pal/...>` too. This mirrors what the CMake build already does with `include_directories(runtime/pal/include)`, and does not disturb the `runtime` target's namespaced `<executorch/...>` exported headers. No functional change — Buck build wiring only. Signed-off-by: Gasoonjia <gasoonjia@icloud.com>
1 parent e2bc39b commit ed6e2e2

1 file changed

Lines changed: 24 additions & 7 deletions

File tree

backends/qualcomm/runtime/targets.bzl

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,29 @@ def define_common_targets():
3535
],
3636
)
3737

38+
# Platform Abstraction Layer. The headers are included as <pal/...> (matching
39+
# the CMake build's `include_directories(runtime/pal/include)`). They are
40+
# exposed through a header map (dict `exported_headers` with an empty
41+
# namespace) instead of an `-I` flag, so the short <pal/...> include resolves
42+
# identically under both the fbcode (`cpp_library`) and xplat
43+
# (`fb_xplat_cxx_library`) rules, which do not share an include-dir attribute.
44+
# Kept in their own library so the mapping does not disturb the runtime
45+
# target's namespaced <executorch/...> exported headers.
46+
runtime.cxx_library(
47+
name = "pal",
48+
srcs = glob([
49+
"pal/src/linux/*.cpp",
50+
]),
51+
exported_headers = {
52+
"pal/DynamicLoading.h": "pal/include/pal/DynamicLoading.h",
53+
"pal/Path.h": "pal/include/pal/Path.h",
54+
},
55+
header_namespace = "",
56+
define_static_target = True,
57+
platforms = [ANDROID],
58+
visibility = ["PUBLIC"],
59+
)
60+
3861
# "runtime" target is used for offline compile, can be renamed to runtime_aot_build as a BE.
3962
for include_aot_qnn_lib in (True, False):
4063
qnn_build_suffix = ("" if include_aot_qnn_lib else "_android_build")
@@ -43,8 +66,6 @@ def define_common_targets():
4366
srcs = glob(
4467
[
4568
"*.cpp",
46-
"pal/src/linux/DynamicLoading.cpp",
47-
"pal/src/linux/Path.cpp",
4869
"backends/*.cpp",
4970
"backends/gpu/*.cpp",
5071
"backends/htp/*.cpp",
@@ -60,8 +81,6 @@ def define_common_targets():
6081
exported_headers = glob(
6182
[
6283
"*.h",
63-
"pal/include/pal/DynamicLoading.h",
64-
"pal/include/pal/Path.h",
6584
"backends/*.h",
6685
"backends/gpu/*.h",
6786
"backends/htp/*.h",
@@ -70,9 +89,6 @@ def define_common_targets():
7089
],
7190
exclude = ["Logging.h"],
7291
),
73-
exported_preprocessor_flags = [
74-
"-Ibackends/qualcomm/runtime/pal/include",
75-
],
7692
define_static_target = True,
7793
link_whole = True, # needed for executorch/examples/models/llama:main to register QnnBackend
7894
platforms = [ANDROID],
@@ -91,6 +107,7 @@ def define_common_targets():
91107
"//executorch/extension/tensor:tensor",
92108
],
93109
exported_deps = [
110+
":pal",
94111
"//executorch/runtime/backend:interface",
95112
"//executorch/runtime/core/exec_aten/util:scalar_type_util",
96113
"//executorch/runtime/core:event_tracer",

0 commit comments

Comments
 (0)