What’s new in Bazel 7.0
Bazel 7.0 includes over 3,700 changes since 6.0. It’s the latest major release, following the release of 6.0 in December of last year, and it’s Bazel’s fourth LTS release.
Since there were so many changes, many of them quite impactful, I felt I needed to review them all and provide a nice summary for y’all.
While I reviewed every change, I didn’t understand every change 😅. I just wanted to mention that, since this isn’t an exhaustive list of changes, but it is a lot of changes I felt were relevant to a large portion of the community. Also, this year I’ve included changes that appeared in the Bazel 6 minor releases (e.g. Bazel 6.1). While you might already be on a version greater than 6.0, you might not know about all of the neat changes that made it into these “minor” releases.
Similar to Bazel 6.0’s changes, the end result was quite big, so I’ve included a table of contents to allow easy navigation to the changes that interest you the most:
Command-line flag changes
Bazel’s LTS strategy allows for breaking changes between major versions. In particular, it allows for command-line flags to be removed, renamed, made to do nothing, or have their default values changed. In the following sections I collected all such flag changes I could find.
Renamed
- [6.1.0]
--experimental_strict_conflict_checks
to--incompatible_strict_conflict_checks
(77f82f4) - [6.2.0]
--experimental_remote_grpc_log
to--remote_grpc_log
(2715120) - [6.3.0]
--experimental_credential_helper
to--credential_helper
(0573eee) - [6.3.0]
--experimental_credential_helper_cache_duration
to--credential_helper_cache_duration
(0573eee) - [6.3.0]
--experimental_credential_helper_timeout
to--credential_helper_timeout
(0573eee) --experimental_allow_unresolved_symlinks
to--allow_unresolved_symlinks
(215f698)--experimental_heuristically_drop_nodes
to--heuristically_drop_nodes
(e8a69f5)--experimental_remote_build_event_upload
to--remote_build_event_upload
(fb16e8c)--experimental_remote_cache_compression
to--remote_cache_compression
(0cdd409)--experimental_remote_download_regex
to--remote_download_regex
(6d04d38)--experimental_repository_disable_download
to--repository_disable_download
(4c7baa2)--experimental_sandbox_memory_limit
to--experimental_sandbox_memory_limit_mb
(09a07a4)--experimental_worker_multiplex
to--worker_multiplex
(4ad970d)
Default values changed
- [6.3.0]
--experimental_credential_helper_timeout=10s
(5a71d9b) - [6.4.0]
--experimental_cc_implementation_deps=true
(05787f3) --android_fixed_resource_neverlinking=true
(253e986)--enable_bzlmod=true
(30d033c)--experimental_build_transitive_python_runfiles=false
(2f9c7d6)--experimental_exec_configuration_distinguisher=off
(94d8bd3)--experimental_link_static_libraries_once=true
(1456361)--experimental_merged_skyframe_analysis_execution=true
(1b729a5)--experimental_output_directory_naming_scheme=diff_against_dynamic_baseline
(81d12db)--experimental_sandbox_async_tree_delete_idle_threads=4
(d169556)--incompatible_allow_tags_propagation=true
(d0625f5)--incompatible_check_sharding_support=true
(d6257ee)--incompatible_disallow_java_import_exports=true
(b740189)--incompatible_enable_android_toolchain_resolution=true
(05bea52)--incompatible_enable_cc_toolchain_resolution=true
(1be55d8)--incompatible_exclusive_test_sandboxed=true
(23580aa)--incompatible_fail_on_unknown_attributes=true
(5f4a0b2)--incompatible_legacy_local_fallback=false
(0f75c57)--incompatible_remote_use_new_exit_code_for_lost_inputs=true
(c77790f)--incompatible_sandbox_hermetic_tmp=true
(fe85936)--incompatible_merge_fixed_and_default_shell_env=true
(8c191d8)--incompatible_multi_release_deploy_jars=true
(36998c5)--incompatible_strict_conflict_checks=true
(53035bf)--incompatible_use_host_features=true
(93f2216)--incompatible_visibility_private_attributes_at_definition=true
(0656103)--lockfile_mode=update
(8ba6618)--java_language_version=""
(f23440b)--remote_build_event_upload=minimal
(bfdff54)--remote_download_outputs=toplevel
(9c96529)--watchos_cpus=x86_64
(0205bf7)--dynamic_local_strategy
now includesstandalone
when--experimental_local_lockfree_output
is set (40cf855)- Removed
--experimental_inmemory_jdeps_files
and--experimental_inmemory_dotd_files
from the expansion of--remote_download_minimal
and--remote_download_toplevel
(0d9e477) - Removed
--nobuild_runfile_links
from the expansion of--remote_download_minimal
(24ba4fa)
Undeprecated
Surprisingly, a flag was undeprecated in Bazel 7.0:
--allowed_local_actions_regex
(a1dcaea)
No-op
These flags now do nothing, but still exist to allow for migration off of them:
- [6.2.0]
--use_workers_with_dexbuilder
(765c0eb) - [6.3.0]
--experimental_use_fork_join_pool
(30cf799) --action_cache_store_output_metadata
(ec6ce5b)--android_databinding_use_androidx
(6a19449)--android_databinding_use_v3_4_args
(6a19449)--collapse_duplicate_defines
(68a4780)--experimental_allow_android_library_deps_without_srcs
(2c16f3f)--experimental_android_databinding_v2
(6a19449)--experimental_collect_local_action_metrics
(549254e)--experimental_collect_local_sandbox_action_metrics
(549254e)--experimental_enable_aspect_hints
(86d4f48)--experimental_genquery_use_graphless_query
(b7678af)--experimental_parse_headers_skipped_if_corresponding_srcs_found
(d4625cf)--experimental_require_availability_info
(c02d128)--experimental_sandboxfs_map_symlink_targets
(217fafe)--experimental_worker_as_resource
(660f441)--high_priority_workers
(8e359e7)--legacy_bazel_java_test
(08d3187)--incompatible_auto_configure_host_platform
(f95df42, 51396c3)--incompatible_disallow_symlink_file_to_dir
(8d375a9)--incompatible_generated_protos_in_virtual_imports
(3efaa32)--incompatible_remote_build_event_upload_respect_no_cache
(fe97f20)--incompatible_remote_results_ignore_disk
(c88f374)--incompatible_remove_rule_name_parameter
(fcf6b79)--incompatible_require_javaplugininfo_in_javacommon
(192702c)--target_platform_fallback
(51396c3)--use_top_level_targets_for_symlinks
(32df891)
Removed
--android_include_proguard_location_references
(bbf11ed)--apple_bitcode
(37b8e1b)--apple_compiler
(1acdfc4)--apple_enable_auto_dsym_dbg
(40ef6d3)--apple_grte_top
(fb4106b)--compress_in_memory_genquery_results
(554f309)--debug_print_action_contexts
(737830a)--distinct_host_configuration
(9c01a5a)--deduplicate_depsets
(53ca28c)--dynamic_worker_strategy
(2ca7c18)--experimental_allow_top_level_aspects_parameters
(6b2ff30)--experimental_analysis_test_call
(b747a4f)--experimental_android_local_test_binary_resources
(6122700)--experimental_apple_mandatory_minimum_version
(dbd9e18)--experimental_async_execution
(6b2ff30)--experimental_availability_info_exempt
(6b2ff30)--experimental_build_setting_api
(d72760b)--experimental_cc_shared_library_debug
(92e16da)--experimental_cpp_compile_argv_ignore_param_file
(b34ea66)--experimental_enable_objc_cc_deps
(51f45c4)--experimental_enable_target_export_check
(1456361)--experimental_execution_graph_log
(8ab9c6e)--experimental_execution_graph_log_cached
(6b204c0)--experimental_execution_graph_log_missed
(6b204c0)--experimental_execution_log_spawn_metrics
(c0f2e14)--experimental_dynamic_execution_cpu_limited
(6b2ff30)--experimental_dynamic_skip_first_build
(6b2ff30)--experimental_includes_attribute_subpackage_traversal
(1961b09)--experimental_java_proto_library_default_has_services
(0c8b3ed)--experimental_keep_config_nodes_on_analysis_discard
(6b2ff30)--experimental_lazy_template_expansion
(61c31d2)--experimental_local_memory_estimate
(6b2ff30)--experimental_multi_cpu
(6b2ff30)--experimental_multi_threaded_digest
(6b2ff30)--experimental_persistent_javac
(7fe8fa2)--experimental_prioritize_local_actions
(e45b8d4)--experimental_replay_action_out_err
(6b2ff30)--experimental_repository_cache_urls_as_default_canonical_id
(a6f8923)--experimental_repository_hash_file
(176b07f)--experimental_sandboxfs_path
(217fafe)--experimental_shortened_obj_file_path
(6b2ff30)--experimental_show_artifacts
(bdcd311)--experimental_skip_runfiles_manifests
(2dc7375)--experimental_skyframe_include_scanning
(205091e)--experimental_skymeld_ui
(681a0c1)--experimental_supports_info_crosstool_configuration
(1ebfb7d)--experimental_use_sh_binary_stub_script
(f2d82c6)--experimental_verify_repository_rules
(176b07f)--incompatible_avoid_conflict_dlls
(e1eef7c)--incompatible_disallow_legacy_javainfo
(606dac7)--incompatible_disable_cc_configuration_make_variables
(20528af)--incompatible_disable_cc_toolchain_label_from_crosstool_proto
(20528af)--incompatible_disable_crosstool_file
(20528af)--incompatible_disable_depset_in_cc_user_flags
(20528af)--incompatible_disable_expand_if_all_available_in_flag_set
(ff37230)--incompatible_disable_legacy_cpp_toolchain_skylark_api
(20528af)--incompatible_disable_legacy_flags_cc_toolchain_api
(20528af)--incompatible_disable_managed_directories
(20528af)--incompatible_disable_runtimes_filegroups
(20528af)--incompatible_display_source_file_location
(8c24877)--incompatible_disable_sysroot_from_configuration
(20528af)--incompatible_disable_tools_defaults_package
(20528af)--incompatible_disable_third_party_license_checking
(ae40562)--incompatible_dont_emit_static_libgcc
(20528af)--incompatible_enable_legacy_cpp_toolchain_skylark_api
(20528af)--incompatible_force_strict_header_check_from_starlark
(3f36464)--incompatible_genquery_use_graphless_query
(58a44d4)--incompatible_linkopts_in_user_link_flags
(20528af)--incompatible_load_cc_rules_from_bzl
(65b5640)--incompatible_provide_cc_toolchain_info_from_cc_toolchain_suite
(20528af)--incompatible_remove_cpu_and_compiler_attributes_from_cc_toolchain
(0567176)--incompatible_require_feature_configuration_for_pic
(20528af)--incompatible_use_platforms_repo_for_constraints
(a7f7df3)--legacy_spawn_scheduler
(f2c11f7)--print_workspace_in_output_paths_if_needed
(f2c11f7)--remove_all_convenience_symlinks
(002bd04)--resource_autosense
(c6ba553)--show_warnings
(53b0081)--toolchain_resolution_override
(60a3c5b)--tvos_simulator_version
(f2c11f7)--tvos_simulator_device
(f2c11f7)--use_single_jar_apk_builder
(669c8aa)--use_workers_with_dexbuilder
(f2c11f7)--watchos_simulator_version
(f2c11f7)--watchos_simulator_device
(f2c11f7)
Remote
One of Bazel’s most powerful features is its ability to use remote caching and remote execution. Numerous improvements and fixes to Bazel’s remote capabilities made it into Bazel since 6.0.
Below are some changes that weren’t tied to any specific remote feature (e.g. gRPC connections):
- [6.2.0] Added the
--remote_retry_max_delay
flag, which allows remote retry max delay to be user configurable. (060fea5) - [6.3.0] Added the
--experimental_circuit_breaker_strategy
,--experimental_remote_failure_rate_threshold
, and--experimental_remote_failure_window_interval
flags, which causes Bazel to stop using the remote cache or remote execution after a certain rate of failures. (5575ff2, 10fb5f6) - [6.4.0] The
digest_function
field is now set as part of all relevant gRPC requests. (0a8380b) - [6.4.0] The stack trace is now included in all gRPC errors when
--verbose_failures
is set. (454f11d) - [6.4.0] SSL
BAD_DECRYPT
errors are now retried. (fb38c3a) - Optimized fetching of
ServerCapabilities
. (35642f4, 0d36c6b) exec_properties
is now used whenremote_execution_properties
is empty. (6f24fa5)
Remote caching (RBC)
Using a remote cache is one of the most popular ways of speeding up a Bazel build. Thankfully these changes make using a remote cache both more performant and more reliable:
- [6.1.0] Added the
--incompatible_remote_use_new_exit_code_for_lost_inputs
flag, which causes Bazel to exit with code 39 if the remote cache evicted blobs that Bazel needed. (99cff33) - [6.1.0] Background download progress is now reported in the UI. (0f524c6)
- [6.1.0] Bazel now cleans up stale metadata when it detects that remote cache blobs have been evicted. (963640a, 32e4f23, c05ba76)
- [6.1.0] When using a combined cache, the AC integrity check now applies to disk part as well. (5f2866f)
- [6.1.0] Fixed
--remote_download_minimal
to work withbazel test
. (e8182ce) - [6.2.0] Added the
--experimental_remote_cache_eviction_retries
flag, which automatically retries the build if it encounters a remote cache eviction error. (24b4589) - [6.2.0] All remote metadata is now cleared if any blobs are detected as evicted from the remote cache. (49a9502)
- [6.2.0] Removed
action_id
metadata from prefetched inputs. (f62a8b9) - [6.2.0]
ALREADY_EXISTS
when uploading is now treated as a success. (daa3dbe) - [6.2.0] Improved the upload early return logic. (50ec6bb)
- [6.2.0] Fixed failures creating output directories. (4050120)
- [6.3.0]
--experimental_remote_cache_eviction_retries
is now disabled if--invocation_id
is set. (d9b94cb) - [6.2.0] Output symlinks are now gracefully handled when using Build without the Bytes. (ca30372)
- [6.3.0] The
prefetecher
action_id
metadata is now set for prefected inputs. (3b39ab8) - [6.3.0] Fixed local action non-declared symlink issue when using Build without the Bytes. (5c4cf47)
- [6.3.0] Fixed a potential memory leak in the UI. (ce8836d)
- [6.4.0] Added the
--experimental_remote_require_cached
flag, which fails the build if any remotely cachable actions aren’t cached. (22f518c) - [6.4.0] Added support new-style digest functions. (88412ce)
- [6.4.0] Added support for multiple digest functions. (f8c8875)
- Added the
--incompatible_disallow_unsound_directory_outputs
flag, which disallows materializing an output file as a directory. (77f8603) - Added the
--remote_download_all
flag, which is similar to the--remote_download_{toplevel,minimal}
flags. (d097b5d) - Added the
--experimental_remote_cache_ttl
flag, which causes old blobs to be considered potentially evicted from the remote cache. (1ebb04b) - Added the
--experimental_remote_cache_lease_extension
flag, which causes a background thread to periodically sendFindMissingBlobs
requests to the remote cache during a build. (1a2b792) - Added the
--experimental_remote_scrubbing_config
flag, which allows scrubbing remote cache keys for locally run actions. (24de276) - Build without the Bytes now works without setting the
--experimental_inmemory_*_files
flags. (ba5e617) - Changing
--remote_download_mode
no longer invalidates the analysis cache. (d426b3d) - HTTP remote cache failures are now retried. (6115d94)
- If the remote cache is unavailable at the start of the build, it will now automatically fall back to local execution. (0d36c6b)
- Tree objects are now emitted in topological order. (c20d7ed)
- The mtime is now updated on files stored or retrieved from the disk cache. (7a774ff)
- Fixed
--experimental_remote_download_regex
to work in incremental builds. (20552d8) - Fixed Build without the Bytes when using multiple source roots. (de4746d)
- Fixed prefetching symlinks. (0a1d505)
- Fixed runfile symlink handling when using Build without the Bytes. (fb76e6e)
Remote execution (RBE)
For some projects, using remote execution is the ultimate performance unlock for their Bazel builds. In addition to the remote caching changes covered above, which also apply to remote execution, the following changes improve the remote execution experience:
- [6.1.0] Added the
--experimental_remote_discard_merkle_trees
flag, which discards in-memory copies of the input root’s Merkle tree and associated input mappings during calls toGetActionResult
andExecute
. (4069a87) - [6.1.0] Made Bazel more responsive and use less memory when
--jobs
is set to a high value. (4069a87) - [6.1.0] Fixed handling of remote cache eviction when uploading inputs. (c1168e1)
- [6.2.0] Optimized building Merkle trees. (f63ce79, 6d6fa81)
- [6.2.0] Tree artifacts are now included in the Merkle cache. (0f55d12)
- [6.3.0] Added support for
output_symlinks
inActionResult
. (e842fd5, d3fb047) - [6.3.0] Remote symlink outputs are now supported when using building without the bytes. (0ff6b88)
- [6.4.0] The
no-remote-exec
execution requirement is now part of the action salt. (5a23ab2)
Dynamic execution
Dynamic execution allows for Bazel to race remote and local execution of actions, potentially allowing you to get the benefit of both modes, without the drawbacks of either. Bazel 7.0 only included a single notable user-facing change to dynamic execution:
- Added the
--experimental_dynamic_ignore_local_signals
flag, which allows local failures under dynamic execution to be ignored for exit codes > 127 (signals). (07ee4b7)
Build Event Service (BES)
Using a build event service can give you unparalleled insight into your Bazel builds at scale. There were a couple nice changes to BES support:
- [6.1.0] stdout and stderr logs are now uploaded when using
--experimental_remote_build_event_upload=minimal
. (17b8e44) - [6.1.0] When using
--experimental_remote_build_event_upload=minimal
,bytestream://
is always used for BEP referenced files. (b0c5eb3) - Added the
--bes_system_keywords
flag, which allows specifying non-prefixed notification keywords. (8daa3dc) - Added the
--build_event_{binary,json,text}_file_upload_mode
flags, which specify the upload mode to use for each file type. (ca62ca1)
Logging
Bazel offers various methods to gain insight into your build. I cover some of the notable changes to those methods below.
Build Event Protocol (BEP)
The build event protocol is used by build event services, so all of these changes could have also been listed in that section as well. The BEP can also be collected locally with --build_event_json_file
, --build_event_binary_file
, and --build_event_text_file
.
The vast majority of changes added additional information to the BEP, though some are fixes and improvements:
- [6.3.0] Added the
action_cache_statistics
field toBuildMetrics.ActionSummary
. (7963528) - Added the
end_time
,start_time
, andstrategy_details
fields toActionExecuted
. (2ddacab) - Added the
exec_kind
field toBuildMetrics.ActionSummary.RunnerCount
. (0e1d1b6) - Added the
execution_phase_time_in_ms
field toBuildMetrics.ActionSummary.TimingMetrics
. (be63eee) - Added the
package_load_metrics
field toBuildMetrics.ActionSummary.PackageMetrics
. (0597a07) - Added the
symlink_target_path
field toFile
. (7fa5796) - Added the
system_time
anduser_time
fields toBuildMetrics.ActionSummary.ActionData
. (5f1a570) - Added the
worker_ids
field toBuildMetrics.WorkerMetrics
. (d31dd09) - Added the
worker_key_hash
field toBuildMetrics.WorkerMetrics
. (58eeea1) - Added the
worker_pool_metrics
field toBuildMetrics
. (284e5a3) - Added the
CoverageActionsFinishedId
event. (c2a6f0c) - Added the
ExecRequest
event. (9a047de) - Added the
TestProgress
event. (d8b8ab0) - Added the
--experimental_publish_package_metrics_in_bep
flag, which populates theBuildMetrics.ActionSummary.PackageMetrics.package_load_metrics
field. (0597a07) - Added the
--experimental_run_bep_event_include_residue
flag, which populates theExecRequest.argv
field. (9a047de, dab6383) - Deprecated the
worker_id
field inBuildMetrics.WorkerMetrics
. (d31dd09) - Fixed Starlark flags set in
.bazelrc
from appearing inUnstructuredCommandLine
. (f272df3)
Timing profile
The action timing profile, which is enabled by default with --profile
, is viewable both locally in Chrome and on build event services. These changes add more detail and clarity to the profile:
- [6.1.0] Added the
bazel_version
field tootherData
. (7569b0d) - [6.2.0] Added the
profile_finish_ts
field tootherData
. (dbc8423) - [6.4.0] Added profiling of Bzlmod operations. (e7cfd2e, 8a68310)
- Added local action cache hits as a stacked chart. (610b56f)
- Added the
--experimental_collect_pressure_stall_indicators
flag, which adds Linux PSI data to the profile. (50446bc) - Added the
--experimental_collect_resource_estimation
flag, which adds CPU and memory estimation profiling. (2e2f5d9) - Added the
ANALYZE_AND_EXECUTE
(interleaved loading, analysis and execution
) phase. (78140bf) - Added profiling of checking outputs. (df3d00a)
- Added profiling of execution log creation, writing, and sorting. (c2e25ea)
- Added profiling of long wait times for cancelling the other branch in dynamic execution. (9f2cc56)
- Added profiling of network handshakes. (bf9b177)
- Added profiling of symlink tree creation and deletion. (f84329e)
- Doubles are now used instead of strings for counter series. (6d1dd4e)
REMOTE_DOWNLOAD
(remote output download
) now has a 10ms threshold. (b8e2c5f)- Extended the span of checking action cache hits to include all of the work and not only the actual cache lookup. (df3d00a)
- Removed
taskId
. (bf2368a) - Fixed local execution to use
LOCAL_PROCESS_TIME
(Local execution process wall time
) instead ofREMOTE_PROCESS_TIME
(Remote execution process wall time
). (480b234)
Execution log
Bazel logs all of the spawns it executes in the execution log, which is enabled with the --execution_log_json_file
or --execution_log_binary_file
flags. This feature is relatively stable, with just a few noticeable changes:
- [6.1.0] Added the
--execution_log_sort
flag, which allows disabling execution log sorting. (1a6ffe6) - [6.4.0] Added the
is_tool
field toFile
. (0434287) --execution_log_json_file
and--execution_log_binary_file
are now mutually exclusive. (61fa933)- Renamed the
remote_cache_hit
field inSpawnExec
tocache_hit
. (60dbc64) - Removed the
progress_message
field fromSpawnExec
. (0ca0510) - Removed the
walltime
field fromSpawnExec
. (60e03bf)
Execution graph
The execution graph, which is enabled with the --experimental_enable_execution_graph_log
flag, logs all actions executed during a build. It differs from the execution log in that it contains additional information needed to reconstruct the full dependency graph.
Even though there aren’t many changes to the execution graph in Bazel 7.0, I only recently learned about its existence, and wanted to call attention to it:
- Added the
discover_inputs_millis
field toMetrics
. (0e099d9) - Added the
--experimental_execution_graph_enable_edges_from_filewrite_actions
flag, which adjusts how filewrite action edges are handled. (4973166) - Added the
--experimental_enable_execution_graph_log
and--experimental_execution_graph_log_path
flags, which replace the--experimental_execution_graph_log
flag. (8ab9c6e) - The execution graph is now written to the output base instead of the workspace. (b5808a4)
- Shared actions are now included in the execution graph. (2036a0f)
- Test actions no longer output an extra node. (c3260c4)
Other
- [6.3.0] Changed
--memory_profile_stable_heap_parameters
to accept more than one GC specification. (3dc6951) - Added the
--experimental_command_profile
flag, which records a Java Flight Recorder CPU profile into aprofile.jfr
file in the output base. (5cbb153)
Execution
Executing build commands is a primary function of Bazel. Some execution related changes can be classified in a particular way, such as remote execution or dynamic execution. For the rest, I’ve collected them here.
Below I summarize some foundational execution related changes, including “local execution” strategies:
- [6.1.0] Added the
--experimental_writable_outputs
flag, which causes the permissions of all output files to0755
instead of0555
. (88c426e) - [6.1.0] Added the
--local_extra_resources
flag, which allows specifying additional resource types that can limit concurrently running actions. (2b2bea4) - [6.1.0] Fixed symlink creation overhead. (c15148a)
- [6.2.0] ctime is now used in file digest cache keys. (763f1d9)
- [6.2.0] Optimized file checksumming. (368bf11)
- [6.3.0] Adjusted
--top_level_targets_for_symlinks
to work in more cases. (ceb9955) - [6.4.0] Added the
--allow_analysis_cache_discard
flag, which when false causes the build to fail if the analysis cache would be discarded. (1997f09) - [6.4.0] Added the
blake3
option to--digest_function
. (cc49d68) - [6.4.0] Added the
diff_against_dynamic_baseline
option to--experimental_output_directory_naming_scheme
. (39b450c) - [6.4.0] Added the
FORMATTED_DATE
entry to the volatile workspace status file. (ee36d32) - Added a
forced=k
option to--test_sharding_strategy
. (bd5f3c3) - Added the
--experimental_gc_thrashing_limits
and--gc_thrashing_limits_retained_heap_limiter_mutually_exclusive
flags, which causes Bazel to trigger an OOM crash when too much garbage collection thrashing happens. (9f93780) - Added the
--experimental_throttle_action_cache_check
flag, which throttles action cache checks. (3d29b2e) - Added the
--experimental_skymeld_analysis_overlap_percentage
flag, which limits amount of analysis phase and execution phase overlap. (9adbe0f) - Added the
--experimental_use_semaphore_for_jobs
flag, which limits the number of concurrent action execution with a semaphore. (a83a97e) - Added the
--skip_incompatible_explicit_targets
flag, which skips incompatible targets that are explicitly listed on the command line. (136a1ee) - Actions can now opt into path mapping with the
supports-path-mapping
execution requirement. (a239ea8) --flag_alias
can now be set oncommon
andalways
. (86fe599)- Elevated the
analysis cache discarded
message fromINFO
toWARN
. (0a47a1f) - Normalized
--action_env
,--flag_alias
,--host_action_env
, and--test_env
values. (4dc5de8) 0755
instead of0777
is now used when creating a writable directory. (ff0e61a, 4da0642)- Optimized computing digests from the filesystem. (e2a57ac)
- When using
--experimental_merged_skyframe_analysis_execution
, symlinks aren’t planted for paths in.bazelignore
. (e1fbc83) - When using
--subcommands
the mnemonic is now reported. (afa2500) - Removed the
sandboxfs
strategy. (217fafe) - Fixed
--reuse_sandbox_directories
to work with differently-named workspaces. (2dc5ba9) - Fixed encoding of non-ascii contents written to parameter files. (dc80fa7)
- Fixed state tracking for actions that run under multiple strategies. (d46aed6)
- Fixed docker strategy
GID
clash. (4082e0f)
Running and testing
In addition to building targets, Bazel can run applications and tests with the run
and test
commands. Here were some notable changes to that functionality:
- [6.1.0] Non-test actions are no longer reported as tests in the UI. (fcb0077)
- [6.1.0] Non-started tests now count as skipped. (16427c9)
- [6.2.0]
SIGWINCH
is now correctly handled whenbazel run
-ing test rules. (38ece3c) - [6.2.0] Fixed missing output from quick tests run with
bazel run
. (c04f0d4) - [6.3.0] Added the
--incompatible_check_sharding_support
flag, which will fail sharded tests that don’t touch theTEST_SHARD_STATUS_FILE
file. (f7d795a) - [6.3.0]
test-setup.sh
now raises a signal on exit codes above 128. (90c4bdf) - [6.4.0] Runfiles related environment variables are now cleared when using
bazel run
. (bc83389) - [6.4.0] When
--test_summary=detailed
is used, passing methods are now also included in the test summary. (c75fda9) - Added the
--run
flag, which if false prevents bazel from running the built executable. (6069512) - Added the
//command_line_option/fragment:test
option for thetransitive_configs
attribute. (6bd7878) - Made
--experimental_inprocess_symlink_creation
work with--nobuild_runfile_links
. (7b87ae1) - When switching from
--enable_runfiles
to--noenable_runfiles
the previous runfiles symlink tree is now cleaned up. (f84329e) - Fixed incrementality issues related to runfiles and a changing
--output_base
. (c9d7ff9)
Coverage
Bazel can collect code coverage when running tests. Recent changes made the default settings work for more people:
- [6.1.0]
bazel coverage
now works with--remote_download_minimal
. (e8ff51f) - [6.1.0]
@remote_coverage_tools
is now only fetched when collecting coverage. (4d188a9) - [6.1.0] Fixed LLVM coverage collection for source file paths with a
tmp
segment. (88b51f5) - [6.3.0] Added the flag
--experimental_collect_code_coverage_for_generated_files
, which collects code coverage for generated files. (9c83049) - [6.3.0] Added the
metadata_files
parameter to thecoverage_common.instrumented_files_info
function. (ef54ef5) - [6.3.0]
--experimental_split_coverage_postprocessing
now works in combination with--experimental_generate_llvm_lcov
. (9d3b375) - [6.3.0] Fixed
json.gz
check to not rely ongcov --version
. (7f628d7) - The
CoverageReport
action now uses theno-remote
execution requirement instead oflocal
. (188b4ef) - The
coverage_support_files
parameter on thecoverage_common.instrumented_files_info
function now acceptsFilesToRunProvider
arguments. (062b83f) - Fixed coverage combining to happen after exclusive tests have run. (6eb7dbb)
Persistent Workers
Persistent workers improve build performance by sending multiple requests to long-running processes. Here are some notable changes to persistent worker support:
- Added the
--experimental_shrink_worker_pool
flag, which shrinks the worker pool if memory pressure gets too high. (dce697d) - Added the
--experimental_worker_allowlist
flag, which specifies which mnemonics can use persistent workers. (85dcafe) - Added the
--experimental_worker_memory_limit_mb
flag, which kills workers using more than a given amount of memory. (8d1db5b) - Added the
--experimental_worker_metrics_poll_interval
flag, which allows changing the interval between collecting worker metrics and possibly attempting evictions. (a95847c) - Added the
--experimental_worker_sandbox_hardening
flag, which uses the linux sandbox for worker sandboxing. (6669a4f) - Removed support for high priority workers. (8e359e7)
Querying
Here are some changes that were made to the query
family of commands, starting with ones that applied to more than one of the commands:
- [6.2.0] The
aquery
andcquery
commands now respect the--query_file
flag just like thequery
command. (fb23246) - [6.4.0] Added the
--consistent_labels
flag, which forces consistent label formatting across all output modes that is also compatible withstr(Label(...))
in Starlark. (20cdacc) - Added the
--proto:include_attribute_source_aspects
flag, which includes a new fieldsource_aspect_name
to theAttribute
message that indicates the source aspect that the attribute comes from. (5c7a159) - Added a filter in
cquery
/aquery
to skip targets with mismatched configurations. (a2bd3ef) label_flag
andlabel_setting
values now consider defaults. (658b3a6)
query
- [6.3.0] Added
jsonproto
option to the--output
flag. (a94383f) - [6.3.0] Fixed
--output=proto --order_output=deps
not returning targets in topological order. (2ff87be) - [6.4.0] Renamed
--output=jsonproto
tostreamed_jsonproto
and made the format valid ndjson. (2cd583a) - Duplicates in
<rule-inputs>
when usingquery --output=xml --aspect_deps=precise
are removed. (5c7a159)
cquery
- [6.2.0] Added support for
alias
targets to theproviders
function. (156325e) - Added the
streamed_proto
option to the--output
flag. (aa88357) - Starlark transitions now have full fidelity in
cquery
. (9575c7f) cquery --output=starlark
now respectsBuildLanguageOptions
. (1447f24)
aquery
- [6.1.0] The effective environment is now printed for for all
CommandAction
s. (2ae409b) - Added
streamed_proto
option to the--output
flag. (8490321) - Added the target paths of
UnresolvedSymlink
actions. (df82dcd) - Added whether or not a
FileWrite
action’s output is executable. (abac1c6) - Added
RepoMappingManifest
to the set of files that--include_file_write_contents
affects. (604a9ef) - Removed duplicate printing of
ExecutionInfo
. (dd3b0ec)
Dependency management
With Bazel 7.0 external dependencies can be managed either with Bzlmod or the WORKSPACE
file. Here are some changes that apply to either method:
- [6.1.0] Improved readability of human-readable download progress. (66b58ee)
- [6.1.0] Repository fetch progress is now reported during main repo mapping computation. (51e6c38)
- [6.3.0] Added the
archive_type
attribute tohttp_archive
. (c7695ce) - [6.3.0] Download progress now includes a percentage complete if possible. (6ffff17)
- [6.3.0] Hash strings can now contain uppercase characters. (cc8ecc5)
- [6.4.0] Fixed handling of non-ASCII characters in archive entry file names. (10169bb)
- [6.4.0] Generated patches files now use
\n
for line endings on all platforms. (07e0d31) - Added support for
.tbz
files in therepository_ctx.download_and_extract
function. (6e01b25) - Added the
--experimental_worker_for_repo_fetching
flag, which allows fetching repositories using a worker thread. (1590dbc) - Added the
--http_connector_attempts
and--http_connector_retry_max_timeout
flags, which makes connection retry attempts and timeout configurable. (f29db1b) .git
directories are now deleted fromgit_repository
external repositories when usingstrip_prefix
. (2977ba6)- Extended
--unix_digest_hash_attribute_name
to also work in the repository cache. (87d6e9a) - HTTP 429 (Too Many Requests) errors are now retried. (4ed6a2f)
- URLs are now used as default canonical IDs in common repo rules. (a6f8923)
Bzlmod
With Bazel 7.0 Bzlmod is enabled by default. While Bzlmod was made non-experimental in Bazel 6.0, the minor releases contained a lot of additional quality-of-life and feature improvements:
- [6.1.0] Tildes are now acceped in
--override_module
. (094a0aa) - [6.2.0] Added the
--lockfile_mode
flag, which controls how the bzlmod lockfile is generated and checked. (3b11a2f) - [6.2.0] Added the
dev_dependency
attribute toregister_execution_platforms
andregister_toolchains
. (f39454f) - [6.2.0] Added the
is_dev_dependency
attribute tomodule_ctx
. (1a719ce) - [6.2.0] Added the
extension_metadata
attribute tomodule_ctx
. (6a47481) - [6.2.0] Added the
max_compatibility_level
attribute tobazel_dep
, which allows version selection to upgrade a dependency up to the specified compatibility level. (152a001) - [6.2.0] Added support for relative paths in
--override_module
. (f7627e0) - [6.2.0] Fixed an issue where WORKSPACE and WORKSPACE-loaded .bzl files couldn’t see the Bzlmod root module’s mappings when Bzlmod is enabled. (dfdf63a)
- [6.3.0] Added the
root_module_has_non_dev_dependency
attribute tomodule_ctx
. (640e850) - [6.3.0] Added the
show
command tobazel mod
. (1ae56c2) - [6.3.0]
REPO.bazel
andMODULE.bazel
files are now considered workspace boundary markers. (f93b2f3) - [6.3.0] Overrides specified by non-root modules no longer cause an error, and are silently ignored instead. (78cb7d5)
- [6.3.0] The canonical repo name of the
platforms
module is now forced to beplatforms
. (343ab03) - [6.3.0] Renamed
modquery
command tomod
. (f6c2ef9) - [6.3.0] Yanked module versions no longer contribute dependency requirements or emit
DEBUG
messages forprint()
statements. (2a2a474) - [6.4.0] Added the
environ
attribute tomodule_extension
. (64554a3) - [6.4.0] Added the
--experimental_isolated_extension_usages
flag, which enables theisolate
parameter ofuse_extension
. (19a9710, 3a4b04f) - [6.4.0] Builtin modules are now injected at the end of the
MODULE.bazel
file. (0e58b0d) - [6.4.0] Release candidates are now considered equivalent to the actual release for
module.bazel_compatibility
. (21cd4ef) - [6.4.0] Optimized computing root repository mapping. (8a68310)
- [6.4.0] Optimized memory usage. (74aadb2)
- [6.4.0] Optimized registry downloading. (8337dd7)
- Added the
--all
flag to thefetch
command. (0356a3f) - Added the
--repo
flag to thefetch
command. (9a1d385) - Added support for the
use_repo_rule
directive inMODULE.bazel
files. (ab016be) - All labels in Bazel error messages, log output, Build Event Protocol, etc. are now prefixed with
@@
instead@
where applicable, to properly denote that they contain canonical repo names. (c456082) - Optimized CPU usage. (57b0bd7)
Platforms
Platforms are where your build tools run (i.e. execution platforms) or where your built products will run (i.e. target platforms). In previous years I catagorized changes along those lines, but this year I’m not making that distinction.
Android
- Continued progress on Starlarkifying the Android rules
- [6.1.0] Made desugar dependencies deterministic. (a306f4f)
- [6.1.0] Fixed multiplexed workers for busybox tools. (8b1521e)
- [6.2.0] Added test coverage support to
android_local_test
. (6bd2cc3) - [6.2.0] Fixed worker and multiplex workers for
DexBuilder
andDesugar
actions. (765c0eb) - Added the
--experimental_persistent_aar_extractor
flag, which uses persistent workers for aar extractors. (74bc046) - Added the
--optimizing_dexer
flag, which allows specifying a binary to use to do dexing without sharding. (9337dfe) - Added the
bazel_android
fragment. (bd0f9b0) - Added the
dexdump
tool toandroid_sdk_repository
. (773b50f) - Added the
dexdump
attribute toandroid_sdk
. (1e4b275) - Added persistent worker support for
GenerateDataBindingBaseClasses
. (9092e29) - Added persistent worker support for
ProcessDatabinding
. (9092e29) - Added support for
R.txt
files generated withaapt2 link --package-id
. (41f894f) - Added support for optimizers rewriting baseline profiles. (5391486)
AndroidDataBindingProcessingAction
now emits deterministic zip file timestamps. (10af780)- Made
AndroidInstall
actions hermetic with respect to dex shards. (2b104c8) - The
--no_proguard_location_reference
flag is now added unconditionally to the command line ofaapt2
. (7d911b5) - The default Android SDK toolchain is now registered first. (9be1e9b)
- Baseline profile wildcards are now expanded before optimizer tools see them. (52c3566)
- Removed support for Databinding v1. (6a19449)
Apple
- [6.1.0]
xcrun
is now used to invokeinstall_name_tool
. (8ec8743) - [6.1.0] Dropped support for macOS versions prior to 10.13. (43dadb2)
- [6.2.0] Patched
zlib
to fix compatibility with latest Xcode. (1f2b3ed) - [6.3.0] Bumped
default_macos_sdk_version
to10.11
. (86ef4f4) - [6.4.0] Added initial visionOS support. (c113e62)
- [6.4.0] The
xcode_autoconf
repository rule will now re-run when theDEVELOPER_DIR
orXCODE_VERSION
environment variable changes. (19979e6) - [6.4.0] Removed the
-s
flag fromlibtool
invocation. (ae7cfa5) - Added
-dead_strip
toopt
linker flags. (1da8a82) - Added the
extra_requested_features
andextra_disabled_features
parameters to theapple_common.link_multi_arch_binary
function. (1f8951c) - Linker framework arguments now use the two-argument form (e.g.
["-framework", "UIKit"]
instead of["-Wl,-framework,UIKit"]
). (32fb0a2) - Moved Apple toolchain setup to apple_support. (699e403)
xcode_autoconf
now usedconfigure = True
instead oflocal = True
. (c747ae7)xcrunwrapper
is no longer used for theObjcBinarySymbolStrip
action. (80621fd)- Removed
apple_common.multi_arch_split
. (a76763c) - Removed
apple_common.apple_crosstool_transition
. (534e6f8) - Removed
darwin
as a--cpu
value. (d1b4fb7) - Removed bitcode support. (37b8e1b)
- Removed the use of
-undefined dynamic_lookup
. (4853dfd)
Linux
- [6.3.0]
--local_termination_grace_seconds
is now used when testing sandbox availability. (d0e19ae) - Added the
--experimental_sandbox_memory_limit
flag, which allows setting per-sandbox memory limits. (03996c1) .bazelignore
paths on Linux are no longer watched for changes. (4dabe43)- Bazel’s local CPU resource on Linux is now container aware. Use
--local_cpu_resources
,--loading_phase_threads
or--jobs
to override. (ab2953c)
Windows
- [6.1.0] The
archive_param_file
feature is now enabled by default for Windows. (bb0b886) - [6.1.0] Fixed
--nozip_undeclared_test_outputs
on Windows. (cd10d50) - [6.2.0] C++ deps pruning is now enabled on Windows when PARSE_SHOWINCLUDES is available. (788801a)
- [6.3.0] Fixed VS 2022 autodetection. (cd33d14)
- [6.4.0] Compilation actions using the auto-configured MSVC toolchain are forced to emit error messages in English if the English language pack for Visual Studio is installed. (0f10359)
- [6.4.0] Fixed Bash runfiles failure when the output base contains uppercase letters. (ea4ab7d)
- Added the
external_include_paths
feature to the windows cc toolchain. (850b334) .bazelignore
paths on Windows are no longer watched for changes. (4dabe43)- The execution platform, instead of the host platform, is now used to decide whether to do Windows-specific things in a few places. (2f0948b)
- The arm64 version of the embedded JDK is now used for Windows ARM64. (b43418d)
- Enabled the
compiler_param_file
feature in the Windows MSVC toolchain. (d47a410) - Removed forced link to
clang_rt.builtins
in the Windows MSVC toolchain. (761b280) - Fixed
launcher_maker
to work with long paths on Windows. (33fed24)
Languages
While there are lots of programming languages that are supported through standalone Starlark rules, some are still written as “native” rules in Bazel core, or are bundled Starlark rules while Starlarkification is in progress. In the following sections I summarize the notable changes in support of these languages.
Bash
- [6.1.0] Fixed
runfiles_current_repository
with RBE. (497b7e4) - [6.1.0] Fix root symlink edge case in runfiles library. (dd24a00)
- Fixed runfiles calling repository lookup for directly run scripts. (da1a6d7)
C and C++
- Continued progress on Starlarkifying C/C++ rules. (starlarkification roadmap)
- [6.1.0] Added support for
.pyd
extensions. (073f54b) - [6.1.0] Added support for
.wasm
extensions. (de062a6, 4b6f014) - [6.1.0] Added the sanitizer features to
unix_cc_toolchain_config
. (abae5ca) - [6.1.0] The exec transition is now applied to
lcov_merger
insh_test
andcc_test
. (37953c5) - [6.1.0] The
cc_shared_library.roots
attribute was renamed todeps
. (68aad18) - [6.1.0]
libtool
is no longer hardcoded when using the unix cc toolchain. (3c47b47) - [6.1.0] Removed the
-O1
flag from sanitizer feature flags. (e132653) - [6.1.0] Removed the
static_deps
attribute fromcc_shared_library
. (9815b76) - [6.2.0] Exposed
cc_proto_aspect
as a toplevel symbol. (2aa06cf) - [6.3.0] Added the
force_no_whole_archive
feature, which force disables--whole-archive
. (661ebef) - [6.3.0] Added the
additional_compiler_inputs
attribute tocc_library
. (ade32e6) - [6.3.0] Added the
CcSharedLibraryHintInfo
provider. (dbb09c9) - [6.3.0] File extensions are case sensitive again. (e4990f8)
- [6.3.0] Unused targets listed in
cc_shared_library.dynamic_deps
are now linked. (ba5c740) - [6.3.0]
cc_binary
targets withdynamic_deps
attributes no longer link indirectdynamic_deps
on Unix. (95ae4db) - [6.3.0] Added the
exclude_bazel_rpaths_in_transitive_libs
andlink_indirect_dynamic_deps_in_binary
features. (95ae4db) - [6.3.0] Removed
cc_shared_library_permissions
. (adfd4df) - [6.3.0] Removed the
preloaded_deps
attribute fromcc_shared_library
. (3b7e233) - [6.3.0] Fixed the
cc_shared_library
aspect to propagate along all attributes. (590ee17) - [6.3.0] Fixed the order of linker inputs in
cc_binary
andcc_shared_library
. (a772452) - [6.3.0] Fixed rpath for symlinks in
cc_shared_library
. (044a14c) - [6.3.0] Fixed
cc_shared_library
to take into account unusedCcInfo
s. (b6b9eec) - [6.3.0] Fixed
cc_shared_library
to take into account indirect top level deps. (f9008f6) - [6.3.0] Fixed
exports_filter
incc_shared_library
. (bc33ac2) - [6.4.0] Added the
additional_linker_inputs
attribute tocc_library
. (0589995) - [6.4.0] Debug info context is now collected from the
cc_library.implementation_deps
attribute. (e55fee2) - [6.4.0] Data dependencies are now propagated through the
cc_library.implementation_deps
attribute. (56e9020) - [6.4.0]
c++14
is now used as the default C++ standard. (978cd23) - Added auto-configured Unix toolchain support for
BAZEL_CONLYOPTS
. (b272cef) - Added a feature definition for
static_link_cpp_runtimes
to the unix cc toolchain config. (6c7147b) - Added support for optional toolchains to
find_cpp_toolchain
. (6b126d6) - Added the
external_includes
attribute tocompilation_context
. (a6ef0b3) - Added the
validates_layering_check_in_textual_hdrs
feature, which skips theparse_headers
action. (8ef60d0) - Added the
prefer_pic_for_opt_binaries
feature, that indicates that PIC compiles are preferred for binaries even in optimized builds. (4084671) - Added the
--memprof_profile
flag, which allows passing an LLVM MemProf toCppCompile
actions. (617a3bd) - Added the
--@bazel_tools//tools/cpp:link_extra_libs
flag, which allow. (9f2c62a) - Added the
link_extra_lib
attribute tocc_binary
s specifying extra libraries to be linked into every binary. (5eff703) - Added the
module_files
output group, which enables building PCMs fromcc_library
targets directly. (9b30bf7) - Added support for
expand_if_available
toenv_entry
. (cc335fd) - Added the
use_lto_native_object_directory
feature, which adds tree artifact support to thethin_lto
feature. (db34798, 480c8c8) - Added a tool name for
objcopy
. (2d1f37d) cc_test
can now be configured by using anative.toolchain()
. (99b672b)--crosstool_top
is now unset when--incompatible_enable_cc_toolchain_resolution
is set. (0013115)--fdo_optimize
no longer accepts a relative path. (afe070e)- C++ branch coverage is now enabled when using gcov 8 or later. (57ae1ff)
- The
BAZEL_CURRENT_REPOSITORY
preprocessor variable is now only set during compilation if the target depends on the runfiles library viadeps
orimplementation_deps
. (1b214d2) - The
includes
parameter in thecc_common.compile()
function now accepts depsets as well as lists. (c8d6c11) - Made
generate_system_module_map.sh
more deterministic. (78f98e7) - Moved
CcSharedLibraryHintInfo
to cc_common. (b1c2e8d) libstdc++
(libc++
on macOS) andlibm
are no longer linked in if none of their symbols are referenced, e.g., in a pure C target. (2482322)- When building C++ modules, FDO variables and profile inputs are no longer added. (edeb037)
- Relocatable object files are no longer wrapped in
-Wl,-whole-archive
-Wl,-no-whole-archive
. (61267b3) - Removed the
cc_host_toolchain_alias
rule. (3543b19) - Removed the
grep_includes
parameter fromcc_common
functions. (b82e202)
Java
- Continued progress on Starlarkifying Java rules. (starlarkification roadmap)
- [6.1.0] Coverage can now be collected for external targets. (00e9af1)
- [6.1.0] Fixed coverage collection with the Java 8 runtime. (c266651)
- [6.1.0] Fixed
--experimental_java_classpath=bazel
. (ac504cb) - [6.2.0] Added the
version
attribute tojava_runtime
andJavaRuntimeInfo
. (7556e11) - [6.2.0] Added
-Xep:IgnoredPureGetter:OFF
to defaultjavacopts
. (3b57894) - [6.2.0] Added
-Xep:LenientFormatStringValidation:OFF
to defaultjavacopts
. (33a3b01) - [6.2.0] Added
-Xep:ReturnMissingNullable:OFF
to defaultjavacopts
. (e80ca15) - [6.2.0] JVM warnings are now redirected to stderr. (abea37b)
- [6.3.0]
local_java_repository
now sets theversion
attribute ofjava_runtime
. (1c1584b) - [6.3.0]
ijar
now handles dynamic constants. (69d2991) - [6.4.0] Added a toolchain type for the Java bootstrap runtime. (8715e9a)
- [6.4.0] Optimized classpath pre-processing in
java_stub_template.txt
. (4e8f0bd) - Added
-Xep:EmptyTopLevelDeclaration:OFF
to defaultjavacopts
. (8d9a06e) - Added the
bootclasspath
parameter to thejava_common.compile
function. (a75f516) - Added the
default_cds
attribute tojava_runtime
andJavaRuntimeInfo
. (53ff268) - Added the
exec_compatibility_with
andtarget_compatibility_with
attributes tolocal_java_runtime
anddefault_java_toolchain
. (27fe30b) - Added the
ijar
attribute toJavaToolchainInfo
. (0dd6a49) - Added the
proguard_allowlister
attribute toJavaToolchainInfo
. (8b9e8d5) - Added the
javac_options_list
attribute tocompilation_info
. (ea154dc) - Added the
--incompatible_disable_non_executable_java_binary
flag, which removes thecreate_executable
attribute fromjava_binary
. (d12c7fa) - Added the
--incompatible_java_info_merge_runtime_module_flags
flag, which causes theJavaInfo
constructor to mergeadd_exports
andadd_opens
ofruntime_deps
in addition todeps
andexports
. (e2249f9) - Added the
--build_target
flag tosinglejar
, which allows changing thebuild.target
property when stamping is enabled. (a1a5f33) darwin_x86_64
anddarwin_arm64
now have separatejava_tools
releases. (3b475b3)java_stub_template.txt
is now exported from@java_tools//jdk
. (1465771)- The
--experimental_local_java_optimization_configuration
flag now only accepts a single-label. (6e3a421) - Proto toolchains are now used in
java_lite_proto_library
. (8c38be3) - Proto toolchains are now used in
java_proto_library
. (51970d2) - Optimized
java_common.merge
memory usage. (8ffb972) - Upgraded default
java_toolchain.java_runtime
to JDK 17. (75e0f7d) - Replaced remote JDK 18 with JDK 20. (19b2e2f, 0e8e611, 7ff98ba)
- Removed the
transitive_deps
andtransitive_runtime_deps
attributes fromJavaInfo
. (72058be) - Removed deprecated targets from
@java_tools//jdk
. (844b5d2) - Fixed proguard output map symlink when
proguard_specs
is aselect()
. (c2761af)
Objective-C
- [6.3.0] Added the
implementation_deps
attribute toobjc_library
. (ae7b9c5) - [6.4.0] Added the
--incompatible_disable_objc_library_transition
flag, which removesobjc_libary
’s custom transition. (0f34e76) - Added the
target_should_alwayslink
attribute to theobjc
fragment. (c878b59, 3c0f394) - Added the
--incompatible_disallow_sdk_frameworks_attributes
flag, which disallows thesdk_frameworks
andweak_sdk_frameworks
attributes inobjc_library
andobjc_import
. (66121a7) - Added the
--incompatible_objc_alwayslink_by_default
flag, which changes the default ofobjc.target_should_alwayslink
toTrue
. (a8b36c1) - Added the
--incompatible_objc_provider_remove_linking_info
flag, which removes linking information fromObjcProvider
. (3e170fb) - The
apple_common.new_executable_binary_provider
andapple_common.new_dynamic_framework_provider
functions no longer require theobjc
argument. (28f9056) - The
variables_extension
parameter on theapple_common.link_multi_arch_binary
function can now beNone
. (87bd420) objc_common
no longer sets linking information inObjcProvider
. (0fa7933)- Linking no longer uses
ObjcProvider
information. (426f225) - Linking features, in addition to linkopts, are considered when determining the stripping type. (3a31a6c)
- Tree artifacts in source attributes of
objc_library
can now have arbitrary extensions. (280ae1a) - Removed the
runtime_deps
attribute fromobjc_library
. (3ea60b7) - Removed the
objc_archive
action (cpp_static_library
is used instead). (e1cb203) - Removed the
objc++-executable
action (objc-executable
is used instead). (1623f7e, 6d0c210, 004c73c) - Fixed the
includes
attribute ofobjc_library
when--experimental_sibling_repository_layout
is set. (bbe453e)
Proto
- Continued progress on Starlarkifying Proto rules. (starlarkification roadmap)
- [6.3.0] Added the
output_files
attribute toproto_lang_toolchain
. (4d14d3f) - Added the
--incompatible_enable_proto_toolchain_resolution
flag, which causes proto language rules to use toolchain resolution. (d435c6d) - Removed the
proto_compiler
attribute fromproto_lang_toolchain
. (f5fb2f6) - Fixed proto generation when using
--experimental_sibling_repository_layout
. (6c6c196)
Python
- Continued progress on Starlarkifying Python rules. (starlarkification roadmap)
- [6.1.0] Added host transition to the
lcov_merger
attribute ofpy_test
. (4a6d056) - [6.2.0] Fixed runfiles lookup when using a manifest file. (91584dd)
- Added the
--incompatible_python_disable_py2
flag, which causespython_version=PY2
,srcs_version=PY2
orsrcs_version=PY2ONLY
withpy_binary
,py_test
,py_library
,py_runtime
, orpy_runtime_pair
to throw an error. (d1bbf4b, 95a57ef) - Added the
--incompatible_python_disallow_native_rules
flag, which causes an error if a native Python rule is used without going through rule_python. (2e558ed) - Added the
build_python_zip
attribute to thepy
fragment. (38b2789) - Added the
default_python_version
attribute to thepy
fragment. (c3b2be9) - Added the
default_to_explicit_init_py
attribute to thepy
fragment. (38b2789) - Added the
use_toolchains
attribute to thepy
fragment. (c3b2be9) - Added the
bootstrap_template
attribute topy_runtime
. (0696ba3) - Removed the
py_transitions
module. (e2c4d3c)
Starlark and Build API
Starlark is the configuration language used to configure your project. It is also the programming language used to define rules. Bazel also has a Build API which defines standard functions, modules, and rules that can be used from Starlark. Here are some notable changes to both:
- [6.1.0] Added the
--incompatible_use_host_features
flag, which causes the--features
flag to only apply to the target configuration, while the--host_features
flag only applies to the exec configuration. (0ef9c7c) - [6.1.0] Added the
package_relative_label
function on thenative
module. (b859571) - [6.1.0] The
map_each
callback intemplate_dict.add_joined
can now returnNone
. (db68419) - [6.1.0] The
map_each
callback intemplate_dict.add_joined
can now return a list of strings. (8783459) - [6.2.0] Added the
module_name
andmodule_version
attributes on thenative
module. (bcf309b) - [6.2.0]
json.decode
now accepts duplicate keys. (8548e20) - [6.2.0] Multiple matching
select
branches are now allowed if they resolve to the same value. (d43737f) - [6.4.0] Added the
--incompatible_merge_fixed_and_default_shell_env
flag, which merges rule supplied and shell provided environment variables. (d1fdc53) - [6.4.0] Optimized empty depsets. (fa0ff49)
- [6.4.0] Optimized single transitive depsets. (216fce5)
- [6.4.0] Rule and aspect validation output groups are now merged. (cd72583)
- [6.4.0] When the
repr
function is called on an exported rule the name of the rule is now included in the output. (002490b) - Added the
abs()
function. (5e37989) - Added the
allow_closure
attribute totemplate_dict.add_all
. (4188edd) - Added the
compressed_output
attribute togenquery
. (7f639c6) - Added the
format_joined
callback totemplate_dict.add_all
. (4188edd) - Added the
initializer
parameter to therule
function, which allows specifying a function that computes default values for attributes. (45bac19) - Added the
--experimental_enable_scl_dialect
flag, which allows loading.scl
(Starlark Configuration Langauge) files. (a0cd355) - Added the
--experimental_rule_extension_api
flag, which enables the use of rule extension and subrules. (8815980) - Added the
--incompatible_no_package_distribs
flag, which disables thedistribs
attribute ofpackage
. (e8184e0) - Added the
starlark_doc_extract
rule, which is used by newer versions of Stardoc. (fa65782) - Changed the default value of
attrs
inrule()
andaspect()
to an empty dictionary. (e8f5082) --deleted_packages
now accumulates multiple values. (2a5d9c7)attr
objects now use value equality rather than reference equality. (31fd464)json.decode
now takes an optionaldefault
positional parameter. If this parameter is specified and decoding fails,json.decode
will return thedefault
value instead of failing Starlark evaluation. (71fb1e4)proto.encode_text()
now omits struct fields withNone
values. (88346f1)- Besides for
implementation
, all arguments to therule
function now need to be named. (cbd63ea) - The
location
of rules that explicitly specifygenerator_name
and/orgenerator_function
attributes is now the top-level call in theBUILD
file. (9800ffd) - Transitions can now inspect attribute value. (ceddfb1)
_whitelist_function_transition
is now applied automatically. (60f3319)- Optimized calls to functions with
kwargs
. (2fc7ab9) - Optimized depsets in providers. (cb5a033)
- Optimized provider memory layout. (fc86f15)
- Optimized singleton tuples (e.g.
(single_value, )
). (2cc9e13) - Optimized statement/expression heavy code. (704027e)
- Optimized string
find
/index
calls whenend
isn’t specified. (70c821a) - Optimized string
{l,r,}strip
calls. (62ceeaf) - Optimized string key dictionary lookups. (6087258)
- Optimized tuple and list
in
checks. (d027d48) - Optimized type checks. (2e4694d)
- Optimized
OutputGroupInfo
. (655849b) - Removed the
default_provider
attribute from thectx
module. (2ce1a1b) - Removed the
host_configuration
attribute from thectx
module. (51e1da9) - Removed the
host_fragments
attribute from thectx
module. (0ca7857) - Removed the
new_file
function from thectx
module. (ffe595c) - Removed the
exec_tools
attribute fromgenrule
. (5ce12ee) - Removed the
cmd_helper
module. (b3749b3) - Removed support for
_whitelist_function_transition
. (4064d78) - Fixed
ctx.expand_location
handling of binary target inputs. (4148241) - Fixed
genrule
to use the execution platform to determine whichcmd*
to run. (c64fa6d) - Fixed encoding of positive infinity in
proto.encode_text
. (98e3752)
Aspects
Aspects allow augmenting build dependency graphs with additional information and actions.
- Console output now includes target status, even if non-validation aspects are requested. (944b154)
- Only the visibility of an aspect’s implicit dependencies are checked now. (bc1df91)
- Fixed resolving aspect attributes with the same name as an underlying target attribute. (93ad589)
Platforms and toolchains API
In Bazel 7.0 the C++, Android, and Apple rules completed their migration to support building with Platforms.
Here are some of the platforms and toolchains related changes which weren’t tied to any of those migrations:
- [6.1.0]
--platforms
is no longer cleared in transitions when no change is made to--cpu
. (5b4de12) - Added support for platform to Starlark flags platform mappings. (8a7f5e2)
- Added the
--experimental_exec_config
flag, which allows setting a custom transition to be used forcfg = "exec"
. (23de211, f847e3f) - Added the
--incompatible_auto_exec_groups
flag, which automatically creates exec groups for each toolchain used by a rule. (design doc, 6194956) - Added the
--incompatible_check_visibility_for_toolchains
flag, which applies visibility checking to toolchain implementations. (eecd04f) - Added the
--use_target_platform_for_tests
flag, which uses the target platform for running tests. (d181353) --extra_toolchains
precedence is now last-wins, instead of first-wins. (a4576c1)- Attributes on
platform
are now non-configurable. (b8faa69) - The
platform
rule is now non-configurable. (87fb462) - Made
target_compatible_with
work better onalias()
targets. (1d2e9c8) - Root repository mappings now work in the
platform_mappings
file. (c0fc433) - Target incompatibility is now checked before toolchain resolution. (8482c7c)
- Subsequent settings of
--extra_execution_platforms
now override previous settings, instead of adding them to a list. (c602cec) - Removed the
copy_from_rule
attribute fromexec_group
. (f48412f) - Removed the
host
transition. (c18e6d5)
Misc
There were a handful of changes that I couldn’t find a nice home for in the sections above, but I still felt were important or interesting enough to call attention to:
- [6.2.0]
@foo
labels can now be used on the command line as the top-level target. (24f6fe8) - [6.3.0] Options specified on the pseudo-command
common
in.rc
files are now ignored by commands that do not support them as long as they are valid options for any Bazel command. (44d3953) - [6.3.0] Added the
always
pseudo-command which has the semantics of pre-6.3.0common
in.rc
files. (44d3953) - [6.3.0] Credential helpers now apply to repository fetching as well. (9731e69)
- [6.3.0] Wall-time is now used for credential helper invalidation. (5f77aba)
- Added the
--experimental_include_default_values
flag, which includes default values for Starlark flags in thecanonicalize-flags
command. (33e9bf1) --ui_event_filters
now accumulates multiple values. (3d1aeb5)- JVM options in the
JAVA_TOOL_OPTIONS
andJDK_JAVA_OPTIONS
environment variables no loner propagate to the Bazel server; use--host_jvm_args
instead. (22e3ba5) - The repo mapping manifest is now generated when possible, not only when Bzlmod is enabled. (cb55897)
Summary
As you can see, Bazel 7.0 was another massive release (20% larger than last year!). Thankfully, through the rolling releases process, people were able to test, or even actively depend on, these changes well before the first 7.0 release candidate was cut.
Work on Bazel 8.0 is well underway, and I look forward to summarizing its changes next year. Until then, 👋.