Skip to content

Commit

Permalink
Fix alwayslink in objc_import
Browse files Browse the repository at this point in the history
When `ObjcCommon` was rewritten in Starlark in 4a0cc3b the `archives` list from `objc_import` (passed in via `extra_import_libraries`) got dropped from the `force_load_library` list in `objc_provider`.

This fix adds them back so `-force_load` is correctly applied when `alwayslink` is set.

Here is the original Java implementation for reference:
https://github.com/bazelbuild/bazel/blob/4a0cc3b3f297f8df60022ae977e170148a4c7ae4/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java#L415-L424

This `for` loop is what was omitted in the rewrite and is what is added in this PR:
```java
for (Artifact archive : extraImportLibraries) {
  objcProvider.add(FORCE_LOAD_LIBRARY, archive);
}
```

Closes bazelbuild#15313.

PiperOrigin-RevId: 455164591
Change-Id: Icc0a5aab26ec150475d82b57549b263418776141
  • Loading branch information
Krishna Ersson authored and copybara-github committed Jun 15, 2022
1 parent 5c544f4 commit a1d7d1f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/starlark/builtins_bzl/common/objc/objc_common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ def _create_context_and_provider(
if compilation_artifacts.archive != None:
direct.append(compilation_artifacts.archive)

direct.extend(extra_import_libraries)

objc_provider_kwargs["force_load_library"] = [
depset(
direct = direct,
Expand Down

0 comments on commit a1d7d1f

Please sign in to comment.