bazelbuild / bazelbuild/bazel

apple_common.link_multi_arch_binary avoid_deps doesn't avoid linkopts

Open
#16,327 1 comment 0 reactions 0 assignees View on GitHub
P2 team-Rules-ObjC type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description of the bug:

When calling `apple_common.link_multi_arch_binary` and providing `avoid_deps`, the targets in `avoid_deps` are correctly not linked, but any `linkopts` they carry still get applied to the link.

### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

With this project: [linkoptsrepro.zip](https://github.com/bazelbuild/bazel/files/9620976/linkoptsrepro.zip)

Run `bazel build bin`. This should not fail to link but it does because `bad_lib`'s `linkopts` are propagated to the final link.

### Which operating system are you running Bazel on?

macOS

### What is the output of `bazel info release`?

release 6.0.0-pre.20220909.2

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?

_No response_

### Have you found anything relevant by searching the web?

_No response_

### Any other information, logs, or outputs that you want to share?

Note that this API is used in rules_apple, even though AFAIK it's not supposed to be considered public, but this hits in real world use cases there with `test_host`, https://github.com/bazelbuild/rules_apple/pull/1668

Contributor guide

Open the contributing guide

Research direction

Unpack linkoptsrepro.zip and run `bazel build bin` on macOS to reproduce the failure. Start from the `apple_common.link_multi_arch_binary` entry point and trace how `avoid_deps` and their `linkopts` reach the final link. Done means targets in `avoid_deps` remain unlinked, their linkopts are not propagated, and the reproduction builds successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, macos
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.