Skip to content

--incompatible_remove_ctx_objc_fragment #28082

@dabanki

Description

@dabanki

Motivation

Part of Starlarkifying native Bazel flags: move language-specific flags out of the Bazel binary and into the rule set's .bzl definitions. This gives rules owners (in this case, primarily rules_apple) more ownership over their logic and decouples the flag definitions from Bazel releases.

This Starlarkifies flags previously defined in ObjcCommandLineOptions.java.

This removes ctx.fragments.objc.

Description

When flipped, this flag causes Bazel to no longer provide the native objc fragment. ctx.fragments.objc will no longer exist.

A new rules_apple release (and potentially other rules dealing with Objective-C) will use the absence of this fragment as a signal to read all equivalent flag values from Starlark-defined build settings.

This is intended to be a user no-op for most Objective-C builds. However, there are some differences meriting an incompatible flag:

  1. Setting Starlark flags requires an equals sign: $ bazel build //foo --//my:flag=value must be used instead of $ bazel build //foo --//my:flag value. Since we will be aliasing the old native flags to the new Starlark flags, this means users must use the --flag=value syntax for the affected ObjC flags.
  2. Your repository must load the necessary rules (rules_apple or others) for the ObjC Starlark flags to be defined and resolved. This should generally already be true for Objective-C builds.
  3. If you have custom .bzl code or aspects that read from ctx.fragments.objc, this will break. You need to update your code to read the equivalent Starlark build settings. Please comment on this issue if you need guidance.

This change only affects Bazel 10+ (or whatever version this flag is enabled in). Older Bazel versions will continue to work.

Incompatible Flag

--incompatible_remove_ctx_objc_fragment

Migration Guide

  • If using Bazel 10.0+: Update to a recent rules_apple version that supports Starlark-based flags for ObjC. Release information for the required rules_apple version is TBD. Ensure all invocations of former native ObjC flags use the --flag=value syntax.
  • If using Bazel <10.0: No action is needed.

In which Bazel LTS version will this incompatible change be enabled?

Targeting Bazel 10 (or possibly earlier patch into 9).

TODO List

  • Prepare and release the version of rules_apple that reads from Starlark settings when ctx.fragments.objc is not present.
  • Add flag aliases to rules_apple/MODULE.bazel to map old native flag names to the new Starlark settings.
  • Flip the flag default to true in Bazel.
  • Eventually, remove the native ObjC fragment and options class from the Bazel binary.

Metadata

Metadata

Assignees

Labels

incompatible-changeIncompatible/breaking changeteam-Configurabilityplatforms, toolchains, cquery, select(), config transitions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions