Skip to content

Commit 3f1db23

Browse files
kirklandsignfacebook-github-bot
authored andcommitted
Set kernel default visibility to hidden (#3060)
Summary: When we compile the kernel into a shared library, we don't know whether the definition of kernel implementation symbol can be dropped or not based on op registry. The kernel itself is just a normal function and the user can find it. We set its visibility to hidden by default. Then these kernels are gone when we do `objdump -TC` This reduces binary size. Differential Revision: D56167833
1 parent ab62707 commit 3f1db23

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

shim/xplat/executorch/kernels/portable/op_registration_util.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
1+
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "is_xplat", "runtime")
22
load("@fbsource//xplat/executorch/build:selects.bzl", "selects")
33

44
def op_target(name, deps = [], android_deps = [], _allow_third_party_deps = False, _aten_mode_deps = []):
@@ -122,7 +122,9 @@ def define_op_library(name, deps, android_deps, aten_target, _allow_third_party_
122122
fbandroid_platform_deps = android_deps,
123123
# kernels often have helpers with no prototypes just disabling the warning here as the headers
124124
# are codegend and linked in later
125-
compiler_flags = ["-Wno-missing-prototypes"],
125+
compiler_flags = ["-Wno-missing-prototypes"] + (
126+
["-fvisibility=hidden"] if is_xplat() else []
127+
),
126128
deps = [
127129
"//executorch/runtime/kernel:kernel_includes" + aten_suffix,
128130
] + deps,

0 commit comments

Comments
 (0)