github bazelbuild/bazel 6.0.0

latest releases: 7.4.1, 9.0.0-pre.20241105.2, 7.4.1rc2...
23 months ago

Bazel 6.0 is a major LTS release. It contains new features and backwards incompatible changes.

Highlights

  • Bzlmod, the new external dependency system in Bazel, is now generally available (though still disabled by default). Use --enable_bzlmod to enable it.
  • Toolchain types may now be optional, in addition to mandatory.
  • The author of a .bzl file can now call visibility() to declare a load visibility for that file. Load visibility is a new concept that governs which other .bzl and BUILD files may load .bzl code.

General

  • [Incompatible] genrule is switched to use exec transition instead of host. This can break targets with hardcoded output paths. To avoid using hardcoded paths use make variables, see Predefined source/output path variables.
  • The Build Event Protocol now contains file digests and sizes along with the file name and URI.
  • Introduced a new canonical label literal syntax @@canonical_repo_name//foo:bar that skips repository mapping. When Bzlmod is enabled, calling str() on a Label object will return literals of this form.
  • [Incompatible] Added a new flag --incompatible_unambiguous_label_stringification (defaults to true), which causes labels in the main repo to stringify into unambiguous forms starting with an @. (#15916)
  • The some function in query now contains an optional parameter that specifies the maximum number of targets to return.

Android

  • D8 is used for dexing and Java 8 desugaring.
  • Bazel uses the D8 jar from Maven instead of the Android SDK.
  • D8 dependency updated to v. 3.3.28.
  • Worker mode for D8 desugaring and dexing is supported.
  • --persistent_multiplex_android_tools added to enable persistent multiplex workers for Android resource processing, dexing, and desugaring.
  • Merging "uses-permissions" tags in Android manifests available with --merge_android_manifest_permissions
  • Start of DX removal: Migrate main_dex_list_creator to D8.
  • Deleted the --extra_proguard_specs Blaze flag.

Apple / Xcode

  • Bazel now matches remote and local xcode versions by the most granular version.
  • Introduced an experimental static library linking API under apple_common.link_multi_arch_static_library.
  • Bazel now no longer includes system headers on macOS in coverage reports (#14969).

C++ / Objective-C

  • Bazel no longer stamps cc_common.link actions for tool dependencies.
  • Switched cc_test, cc_binary and cc_library implementations to Starlark.
  • cc_test will now link statically when targeting Windows regardless of host platform (rather than always linking statically when Windows is the host).
  • [Incompatible] Split up the C++ archive from the C++ link action and set CppArchive as mnemonic.
  • [Incompatible] objc_library now requires CcInfo in its deps. If this breaks you, add empty CcInfo() to your rule.
  • The @bazel_tools//tools/cpp:compiler flag now has the value gcc if the configured compiler is detected to be gcc rather than the generic value compiler. A branch for gcc may have to be added to select statements that do not have a default case that handles gcc appropriately.
  • The @bazel_tools//tools/cpp:compiler flag now has the value clang for the auto-configured Xcode toolchain rather than the generic value compiler. A branch for clang may have to be added to select statements that do not have a default case that handles this toolchain appropriately.
  • [Incompatible] include_prefix and strip_include_prefix for cc rules will no longer accept an empty string (see code); use a dot instead. (#17039)

Configurability

  • cquery's new --output=files lists the output files that targets produce.
  • genquery.scope is faster.
  • New --experimental_output_directory_naming_scheme=diff_against_baseline may improve build speed for builds that use transitions.
  • Incompatible target skipping works when dependencies lack platform-appropriate toolchains.
  • Enable --use_top_level_targets_for_symlinks so targets with transitions are more likely to appear in bazel-out/…/bin.
  • bazel config now only reports info from the last build. To compare configurations across multiple builds, redirect bazel config output to a file and run your favorite diff tool.
  • cquery proto formatted output now includes more information about configurations. This deprecates the configuration field of AnalysisProtosV2.ConfiguredTarget, and adds a new field, configuration_id, to be used instead.
  • [Incompatible] --incompatible_override_toolchain_transition is now always set and will be removed in the future. --noincompatible_override_toolchain_transition has no effect and the value of the incompatible_use_toolchain_transition parameter in aspect() and rule() builtins is ignored.
  • select(): improved support for constraint_value with new alias and specialization support
  • select() no longer reports inaccurate "Duplicate label" errors.
  • Bazel now correctly configures shell actions for multiplatform builds.

External Dependencies

  • [Incompatible] --noincompatible_disable_managed_directories, and with that, workspace(managed_directories=) is not supported anymore.
  • The get_child method of path now accepts an arbitrary number of relative path strings as positional arguments.
  • The new_git_repository repository rule has been deprecated in favor of git_repository. (#16064)

Java

  • Packaging support for deploy JAR embedded JDK files (hermetic Java).
  • Make ijar / java_import preserve classes with @kotlin.Metadata annotations.
  • Singlejar accepts runtime Created-By field.
  • Change singlejar metadata to report Created-By Bazel.
  • Record hermetic packaged JDK modules file size in deploy JAR manifest JDK-Lib-Modules-Size attribute.

Local Execution

  • Made multiple improvements to dynamic execution to manage local machine resources: --experimental_dynamic_exclude_tools, --experimental_dynamic_load_factor, support for ignoring certain errors in one branch, and better prioritization of local-only actions.
  • Fixed a race condition in dynamic execution that caused occasional crashes.
  • The Linux sandbox can now run in a chroot jail only allowing access to allowlisted directories (#13279)
  • Added more data to the profile: system load average (--experimental_collect_load_average_in_profiler), worker memory usage (--experimental_collect_worker_data_in_profiler), system network usage (--experimental_collect_system_network_usage), and system CPU/memory metrics.
  • Added option to include spawn metrics in execution log (--experimental_execution_log_spawn_metrics)
  • It is now possible to use pseudoterminals in the Linux sandbox (#14072)
  • Added the --incompatible_sandbox_hermetic_tmp flag that makes sandboxed actions have separate /tmp directories (Linux only). (#16336)

Packaging

  • Further deprecation and removal of pkg_tar. Stop supporting legacy use of files attribute, where it could be a list of labels instead of a map of paths to labels.
  • Removed --incompatible_no_build_defs_pkg flag. It never fulfilled its purpose because --all_incompatible_changes would never set it. The last rule it gated (pkg_tar) is scheduled to be removed in Bazel 6.x.
  • pkg_tar(symlinks) has been removed. Users needing that feature should migrate to @rules_pkg.
  • Remove mtime options from pkg_tar. Users should migrate to @rules_pkg.
  • The legacy pkg_tar no longer supports the ability to untar and repackage an input tar file (deps attribute). Users needing that capability must switch to rules_pkg.

Persistent Workers

  • Added support for remote persistent workers (#16362)
  • Added --experimental_worker_multiplex_sandboxing flag that controls whether to sandbox multiplex workers that support it.
  • Added --experimental_total_worker_memory_limit_mb flag that enables evicting idle workers when workers use too much memory.
  • Added --experimental_worker_as_resource that prevents creation of workers before they have the resources to run.
  • Added verbosity field to worker protocol for better debugging.
  • Added --experimental_worker_strict_flagfiles flag that makes improper use of @-files in worker definitions a failure.
  • Worker directories are now only created when actually needed.
  • Made the JSON worker protocol newline-delimited (#14219)
  • The worker JSON protocol now ignores unknown fields.
  • [Incompatible] Flag --experimental_worker_allow_json_protocol removed (defaulted to true).

Python

  • Add six to deps of has_services=1 py_proto_librarys.
  • Add --incompatible_build_transitive_python_runfiles alias. (#16303). This will be enabled next release.
  • Added CurrentRepository method to bazel_tools Python runfiles library for Bzlmod support (#16341).
  • Make --incompatible_disallow_legacy_py_provider a no-op; using the modern PyInfo provider is now always required.
  • Remove potentially misleading warning about potential Python version mismatch (#15783).
  • Reduce import overhead during bootstrapping (#15572).
  • Set PYTHONSAFEPATH to prevent escaping runfiles (#15701).
  • Allow larger transitive dependencies by deduplicating PYTHONPATH (#15648).
  • Optimize memory usage when building Python zip files (#15037).
  • Fix: py_test now collect coverage for C++ binaries in data (#15098).
  • Fix: Allow spaces in Windows path to binary (#14851).
  • Fix: Allow Windows launcher to customize executable name (#14343).
  • Fix: py_binary can now be invoked through an sh_binary (#11997).
  • Various preparations to drop Python 2 support and re-implement rules in Starlark (#15684, #15897).

Remote Execution

  • Add support for fetching RPC credentials from credential helper.
  • The deprecated --remote_allow_symlink_upload flag has been removed. Symlinks in local action outputs are always permitted, even with remote caching. Whether they're uploaded as symlinks or as the files/directories they point to is still determined by the --incompatible_remote_symlinks flag.
  • [Incompatible] --incompatible_remote_downloader_send_all_headers is flipped to true. (#16356)
  • [Incompatible] GrpcRemoteDownloader only includes relevant headers instead of sending all credentials (see security advisory).
  • [Incompatible] --incompatible_remote_results_ignore_disk is flipped to true. (#15148)
  • Improve --remote_download_minimal by correctly downloading necessary outputs for bazel run and bazel test.
  • Add flag --experimental_remote_mark_tool_inputs to support remote persistent workers.
  • [Incompatible] Deprecated flag --remote_allow_symlink_upload is deleted.
  • Add flag --experimental_remote_build_event_upload to control how Bazel upload local outputs referenced by BEP to remote cache.

Starlark / Build Language

  • \a \b \f \v escape sequences are now allowed in Starlark.
  • provider() now allows you to specify a custom constructor (init) for performing pre-processing and validation of field values. For more information, see Custom initialization of providers.
  • [Incompatible] The --incompatible_existing_rules_immutable_view flag has been flipped to true. (#13907)
  • Starlark test rules can use the new inherited_environment parameter of testing.TestEnvironment to specify environment variables whose values should be inherited from the shell environment.
  • Aspects can now define and use exec groups using the same API as rules.
  • [Incompatible] analysis_test moved into testing.analysis_test.
  • SourceManifestAction now supports Action.content.
  • Added struct, json, proto, and depset to the starlark environment of Bazel's cquery (--output=starlark) command
  • [Incompatible] The name parameter is removed from the rule function. (#16301)
  • [Incompatible] In package_group's [packages](https://bazel.build/versions/6.0.0/reference/be/functions#package_group.packages) attribute, the syntax "//..." now refers to all packages in the same repository as the package group, rather than all packages everywhere. The new item "public" can be used instead to obtain the old behavior. In bazel query --output=proto (and --output=xml), the packages attribute now serializes with the leading double slash included (for instance, //foo/bar/... instead of foo/bar/...). See issues #16323, #16355, and #16391 for more information and for the flags to temporarily opt out of these changes.
  • package(default_package_metadata=[...]) is now the preferred alternative to default_applicable_liceneses. default_applicable_liceneses will be removed in a future release.
  • Aspects can now have parameters of types: integer and boolean
  • Command-line aspects can now have parameters of types: string, integer and boolean. –aspects_parameters flag is introduced to pass their values [commit].

Acknowledgments

This release contains contributions from many people at Google, as well as Adam Azarchs, Adam Singer, Adam Wolf, Albert Lloveras, Alessandro Patti, Alex Eagle, Alex Scott, Alex Torok, Andreas Fuchs, Andreas Herrmann, Andrew Katson, Andrew Klotz, arun.sampathkumar, arunkumar9t2, Ast-x64, Benedek Thaler, Benjamin Lee, Benjamin Peterson, Bo Zhang, Bohdan Vanieiev, Bradley Burns, Brandon Duffany, Brandon Jacklyn, Brentley Jones, Chad Miller, Charles-Francois Natali, Chris Clearwater, Chris Fredrickson, Christopher Rydell, Christopher Sauer, ckiffel, Cristian Hancila, crydell-ericsson, Dan Fleming, Daniel Wagner-Hall, Danny Wolf, David Ostrovsky, David Sanderson, Denys Kurylenko, dhmemi, Dimi Shahbaz, divanorama, Ed Schouten, Emil Kattainen, Eric Song, Eric Wendelin, Fabian Brandstetter, Fabian Meumertzheim, Fredrik Medley, George Prekas, gkgoat1, gkorlam, Greg Roodt, Gregory Fong, Grzegorz Lukasik, Halil Sener, Hannes Kufler, homuler, Igor Nazarenko, James Broadhead, Jason Tan, Jay Bazuzi, Jeremy Volkman, jheaff1, Jiawen Chen, Joel Williamson, John Laxson, John Millikin, Jon Shea, Jonathan Gerrish, juanchoviedo, Kaiqin Chen, Keith Smiley, Ken Micklas, Kevin Lin, Kirill Zabelin, Kiron, Krishna Ersson, Krzysztof Naglik, lihu, Luc Bertrand, Luis Fernando Pino Duque, Marek uppa, Matt Clarkson, Matt Mackay, Michael P. Nitowski, Mikhail Balabin, Mostyn Bramley-Moore, Nick Korostelev, Nitesh Anandan, Niyas Sait, Noa Resare, Olek Wojnar, Oscar Bonilla, Patrick Balestra, Paul Tarjan, Peter Mounce, Philipp Schrader, Pras Velagapudi, Rahul Butani, Rajeshwar Reddy T, Rifqi Mulya Fahmi, Roman Salvador, rustberry, Ryan Beasley, Ryan Schmidt, Sahin Yort, Saleem Abdulrasool, Sara Adams, Shuai Zhang, Simon Bjorklen, Son Luong Ngoc, Stephan Wolski, Steve Vermeulen, Stiopa Koltsov, Takeo Sawada, Tao Wang, Ted Kaplan, Tetsuo Kiso, Thi Doan, Thomas Chen, Thomas Zayouna, ThomasCJY, Timothe Peignier, Tom de Goede, Tomas Volf, UebelAndre, Ulf Adams, Ulrik Falklof, vardaro, Vasilios Pantazopoulos, Vladimir Tagakov, Waleed Khan, William Muir, Xavier Bonaventura, Xiangquan Xiao, Yannic Bonenberger, Yesudeep Mangalapilly, Yuval K, Zhongpeng Lin.

Notice: Bazel installers contain binaries licensed under the GPLv2 with
Classpath exception. Those installers should always be redistributed along with
the source code.

Some versions of Bazel contain a bundled version of OpenJDK. The license of the
bundled OpenJDK and other open-source components can be displayed by running
the command bazel license. The vendor and version information of the bundled
OpenJDK can be displayed by running the command bazel info java-runtime.
The binaries and source-code of the bundled OpenJDK can be
downloaded from our mirror server.

Security: All our binaries are signed with our
public key 3D5919B448457EE0.

Don't miss a new bazel release

NewReleases is sending notifications on new releases.