Skip to content
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

Set kernel default visibility to hidden #3060

Closed
wants to merge 1 commit into from

Conversation

kirklandsign
Copy link
Contributor

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

Copy link

pytorch-bot bot commented Apr 16, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/3060

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit c84fa42 with merge base c73bfc0 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 16, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D56167833

kirklandsign added a commit to kirklandsign/executorch that referenced this pull request Apr 16, 2024
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
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D56167833

kirklandsign added a commit to kirklandsign/executorch that referenced this pull request Apr 16, 2024
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.

---

This is not done in fbcode so far. When we compile in fbcode, seems that all dependency libraries is compiled into shared library, not static library. For example, op tests depends on op implementation through shared library. In that case, the hidden symbols are not exposed and could cause link time failure.

In xplat, these dependencies are set to static libraries so it has no impact. Only when we explicitly build a shared library (for android), we hide the symbols and rely on op registry to store the impl.

Differential Revision: D56167833
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D56167833

kirklandsign added a commit to kirklandsign/executorch that referenced this pull request Apr 16, 2024
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.

---

This is not done in fbcode so far. When we compile in fbcode, seems that all dependency libraries is compiled into shared library, not static library. For example, op tests depends on op implementation through shared library. In that case, the hidden symbols are not exposed and could cause link time failure.

In xplat, these dependencies are set to static libraries so it has no impact. Only when we explicitly build a shared library (for android), we hide the symbols and rely on op registry to store the impl.

---

This applies to internal build only for now. We will re-visit this for OSS later. It's a step needed to make use of selective build for building shared library (android use case mainly)

Differential Revision: D56167833
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D56167833

kirklandsign added a commit to kirklandsign/executorch that referenced this pull request Apr 16, 2024
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.

---

This is not done in fbcode so far. When we compile in fbcode, seems that all dependency libraries is compiled into shared library, not static library. For example, op tests depends on op implementation through shared library. In that case, the hidden symbols are not exposed and could cause link time failure.

In xplat, these dependencies are set to static libraries so it has no impact. Only when we explicitly build a shared library (for android), we hide the symbols and rely on op registry to store the impl.

---

This applies to internal build only for now. We will re-visit this for OSS later. It's a step needed to make use of selective build for building shared library (android use case mainly)

Reviewed By: dbort

Differential Revision: D56167833
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D56167833

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.

---

This is not done in fbcode so far. When we compile in fbcode, seems that all dependency libraries is compiled into shared library, not static library. For example, op tests depends on op implementation through shared library. In that case, the hidden symbols are not exposed and could cause link time failure.

In xplat, these dependencies are set to static libraries so it has no impact. Only when we explicitly build a shared library (for android), we hide the symbols and rely on op registry to store the impl.

---

This applies to internal build only for now. We will re-visit this for OSS later. It's a step needed to make use of selective build for building shared library (android use case mainly)

Reviewed By: dbort

Differential Revision: D56167833
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D56167833

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 54f9f3e.

@mergennachin mergennachin mentioned this pull request Apr 26, 2024
@kirklandsign kirklandsign deleted the export-D56167833 branch September 6, 2024 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants