Skip to content

Set kernel default visibility to hidden #3060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shim/xplat/executorch/build/env_interface.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ env = struct(
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
genrule = native.genrule,
is_oss = True,
is_xplat = False,
is_xplat = lambda: False,
patch_deps = _patch_deps,
patch_cxx_compiler_flags = _patch_cxx_compiler_flags,
patch_executorch_genrule_cmd = _patch_executorch_genrule_cmd,
Expand Down
14 changes: 12 additions & 2 deletions shim/xplat/executorch/kernels/portable/op_registration_util.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "is_xplat", "runtime")
load("@fbsource//xplat/executorch/build:selects.bzl", "selects")

def op_target(name, deps = [], android_deps = [], _allow_third_party_deps = False, _aten_mode_deps = []):
Expand Down Expand Up @@ -122,7 +122,17 @@ def define_op_library(name, deps, android_deps, aten_target, _allow_third_party_
fbandroid_platform_deps = android_deps,
# kernels often have helpers with no prototypes just disabling the warning here as the headers
# are codegend and linked in later
compiler_flags = ["-Wno-missing-prototypes"],
compiler_flags = ["-Wno-missing-prototypes"] + (
# For shared library build, we don't want to expose symbols of
# kernel implementation (ex torch::executor::native::tanh_out)
# to library users. They should use kernels through registry only.
# With visibility=hidden, linker won't expose kernel impl symbols
# so it can prune unregistered kernels.
# Currently fbcode linkes all dependent libraries through shared
# library, and it blocks users like unit tests to use kernel
# implementation directly. So we enable this for xplat only.
["-fvisibility=hidden"] if is_xplat() else []
),
deps = [
"//executorch/runtime/kernel:kernel_includes" + aten_suffix,
] + deps,
Expand Down