Skip to content

Add swift_binary(linkshared = True) for shared libraries - #1820

Merged
keith merged 1 commit into
bazelbuild:mainfrom
AttilaTheFun:linkshared
Jun 23, 2026
Merged

Add swift_binary(linkshared = True) for shared libraries#1820
keith merged 1 commit into
bazelbuild:mainfrom
AttilaTheFun:linkshared

Conversation

@AttilaTheFun

Copy link
Copy Markdown
Contributor

First of two foundation PRs that split #1809 into reviewable pieces. The Swift
SDK cross-compilation work then stacks on top:

main ─┬─ linkshared (this PR)
      └─ Swift SDK framework
            ├─ WebAssembly
            ├─ Android
            └─ Windows host

This PR is independent and testable on its own.

What this adds

swift_binary(linkshared = True): links the target as a shared library /
loadable module (lib<name>.so, .dylib on Apple) instead of an executable,
like cc_binary's linkshared. The binary has no main, and the
renamed-entry-point machinery is disabled (gated on linkshared or the new
swift.no_entry_point_rename toolchain feature). This is useful for dlopen /
System.loadLibrary consumers such as Android JNI libraries (export functions
with @_cdecl).

examples/xplatform/shared_library builds a dynamic library this way; it's
exercised by the macOS //examples/... wildcard and the Windows CI task.

Links the target as a shared library / loadable module (lib<name>.so, .dylib on
Apple) instead of an executable, like cc_binary's linkshared: no main entry
point, and the renamed-entry-point machinery is disabled (gated on the new
swift.no_entry_point_rename feature or linkshared). Useful for dlopen /
System.loadLibrary consumers such as Android JNI libraries (export functions
with @_cdecl).

examples/xplatform/shared_library builds a dynamic library this way.
@keith
keith merged commit f7118e1 into bazelbuild:main Jun 23, 2026
14 checks passed
@AttilaTheFun
AttilaTheFun deleted the linkshared branch June 24, 2026 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants