bazelbuild / bazelbuild/bazel

macos_minimum_os documentation improvement and default value

Open
#16,932 1 comment 3 reactions 0 assignees View on GitHub
not stale platform: apple team-OSS type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 16h
Merged PRs (30d)
72

Description

### Description of the feature request:

An Xcode update resulted in odd behavior where compiling on monterey would produce ventura binaries. With most other tools you can either

- Set the officially sanctioned `MACOSX_DEPLOYMENT_TARGET` environment variable.
- Compile with `-mmacosx-version-min=X.Y` (e.g., with `--copt` / `--cxxopt`)

Adding the compilation flags to `bazel` actually doesn't work, and if you search enough you eventually find [this SO answer](https://stackoverflow.com/a/68227936) endorsing `--macos_minimum_os`). The feature request:

1. The environment variable `MACOSX_DEPLOYMENT_TARGET`, when set, should define this value without the user needing to populate it. All of the other tools involved in our [wheel build](https://github.com/RobotLocomotion/drake/pull/18408) use this variable, `bazel` is the only one that does not.
2. Regardless of the decision of (1), the current docs could be updated to include better search terms and make this easier to find. Currently it states

```
[--macos_minimum_os](https://bazel.build/reference/command-line-reference#flag--macos_minimum_os)= default: see description
Minimum compatible macOS version for targets. If unspecified, uses 'macos_sdk_version'.
Tags: [loses_incremental_state](https://bazel.build/reference/command-line-reference#effect_tag_LOSES_INCREMENTAL_STATE)
```

Something including the phrase(s) `macOS deployment target` (deployment target being the one that everyone will search for) and ideally a mention of its default value of `MACOSX_DEPLOYMENT_TARGET` from the environment, or at least a mention of that exact variable (and it _not_ setting the default if that is the decision) will make this easier for users to find.

### What underlying problem are you trying to solve with this feature?

- Bazel should honor the `MACOSX_DEPLOYMENT_TARGET` environment variable.
- The docs for macos_minimum_os are a little difficult to find, I think adding some search terms there will make this easier on users in the future :slightly_smiling_face:

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

macOS monterey 12.6.1 (among others)

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

release 5.3.1

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

n/a

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

```text
n/a
```

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

https://stackoverflow.com/a/68227936

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

If its just a docs update I think I can add them for you all with a little guidance, but if using the environment variable is agreed upon I don't know enough bazel to help with that.

Contributor guide

Open the contributing guide

Research direction

Start with the --macos_minimum_os command-line reference and review how Bazel handles MACOSX_DEPLOYMENT_TARGET during macOS builds. Confirm whether the environment variable should define the default, then update the flag documentation with the relevant search terms and behavior. Done means the intended default is documented and the reported Monterey-versus-Ventura behavior is addressed or clearly explained.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos
Domain
build-system, operating-systems
Issue type
Feature
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.