Skip to content

Commit

Permalink
Set alwayslink on the clang target of mixed_language_library as w…
Browse files Browse the repository at this point in the history
…ell (#1451)

Signed-off-by: Brentley Jones <[email protected]>
  • Loading branch information
brentleyjones committed Oct 31, 2024
1 parent 054c8a6 commit 00a52db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion doc/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ Once that is the case, this macro will be deprecated.
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="mixed_language_library-name"></a>name | The name of the target. | none |
| <a id="mixed_language_library-alwayslink"></a>alwayslink | If true, any binary that depends (directly or indirectly) on this library will link in all the object files for the files listed in `swift_srcs`, even if some contain no symbols referenced by the binary. This is useful if your code isn't explicitly called by code in the binary; for example, if you rely on runtime checks for protocol conformances added in extensions in the library but do not directly reference any other symbols in the object file that adds that conformance. | `False` |
| <a id="mixed_language_library-alwayslink"></a>alwayslink | If true, any binary that depends (directly or indirectly) on this library will link in all the object files for the files listed in `clang_srcs` and `swift_srcs`, even if some contain no symbols referenced by the binary. This is useful if your code isn't explicitly called by code in the binary; for example, if you rely on runtime checks for protocol conformances added in extensions in the library but do not directly reference any other symbols in the object file that adds that conformance. | `False` |
| <a id="mixed_language_library-clang_copts"></a>clang_copts | The compiler flags for the clang library. These will only be used for the clang library. If you want them to affect the swift library as well, you need to pass them with `-Xcc` in `swift_copts`. | `[]` |
| <a id="mixed_language_library-clang_defines"></a>clang_defines | Extra clang `-D` flags to pass to the compiler. They should be in the form `KEY=VALUE` or simply `KEY` and are passed not only to the compiler for this target (as `clang_copts` are) but also to all dependers of this target. Subject to "Make variable" substitution and Bourne shell tokenization. | `[]` |
| <a id="mixed_language_library-clang_srcs"></a>clang_srcs | The list of C, C++, Objective-C, or Objective-C++ sources for the clang library. | none |
Expand Down
13 changes: 7 additions & 6 deletions mixed_language/mixed_language_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ def mixed_language_library(
name: The name of the target.
alwayslink: If true, any binary that depends (directly or indirectly) on
this library will link in all the object files for the files listed
in `swift_srcs`, even if some contain no symbols referenced by the
binary. This is useful if your code isn't explicitly called by code
in the binary; for example, if you rely on runtime checks for
protocol conformances added in extensions in the library but do not
directly reference any other symbols in the object file that adds
that conformance.
in `clang_srcs` and `swift_srcs`, even if some contain no symbols
referenced by the binary. This is useful if your code isn't
explicitly called by code in the binary; for example, if you rely on
runtime checks for protocol conformances added in extensions in the
library but do not directly reference any other symbols in the
object file that adds that conformance.
clang_copts: The compiler flags for the clang library. These will only
be used for the clang library. If you want them to affect the swift
library as well, you need to pass them with `-Xcc` in `swift_copts`.
Expand Down Expand Up @@ -341,6 +341,7 @@ a mixed language Swift library, use a clang only library rule like \
native.objc_library(
name = clang_library_name,
srcs = clang_srcs,
alwayslink = alwayslink,
hdrs = adjusted_hdrs,
non_arc_srcs = non_arc_srcs,
# `internal_swift_interop_name` isn't needed here because
Expand Down

0 comments on commit 00a52db

Please sign in to comment.