diff --git a/.bazelrc b/.bazelrc index 55d6abefbae79a..6cdb680641cbce 100644 --- a/.bazelrc +++ b/.bazelrc @@ -41,6 +41,9 @@ build --incompatible_disallow_empty_glob # Manually enable cc toolchain resolution before it is flipped. https://github.com/bazelbuild/bazel/issues/7260 build --incompatible_enable_cc_toolchain_resolution +# Fix non-deterministic Java compilation failures (https://github.com/bazelbuild/bazel/issues/3236) +build --incompatible_sandbox_hermetic_tmp + # User-specific .bazelrc try-import %workspace%/user.bazelrc diff --git a/.bazelversion b/.bazelversion index 798e38995c4d67..dc0208aba8e455 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.3.0 +6.3.1 diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index be4a1dab22b24d..2c3ea380b60967 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -19,6 +19,33 @@ body: attributes: label: > Description of the bug: + - type: dropdown + id: subteam + attributes: + label: > + Which category does this issue belong to? + description: > + Answering this will help us triage this issue faster and more accurately to the + relevant team(s). + multiple: true + options: + - Android + - C++ Rules + - CLI + - Configurability + - Core + - Documentation + - External Dependency + - Java Rules + - Loading API + - Local Execution + - Performance + - Python Rules + - Remote Execution + - Rules API + - Server-Side Rules + - Starlark Integration + - Starlark Interpreter - type: textarea id: repro attributes: diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 719ec079327915..f81fd3a3947850 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -19,6 +19,33 @@ body: attributes: label: > Description of the feature request: + - type: dropdown + id: subteam + attributes: + label: > + Which category does this issue belong to? + description: > + Answering this will help us triage this issue faster and more accurately to the + relevant team(s). + multiple: true + options: + - Android + - C++ Rules + - CLI + - Configurability + - Core + - Documentation + - External Dependency + - Java Rules + - Loading API + - Local Execution + - Performance + - Python Rules + - Remote Execution + - Rules API + - Server-Side Rules + - Starlark Integration + - Starlark Interpreter - type: textarea id: problem attributes: diff --git a/CHANGELOG.md b/CHANGELOG.md index dfe2bbfe8ac624..4c33131a7c7d9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,43 @@ +## Release 6.3.1 (2023-07-31) + +``` +Baseline: 0f231ac8acabcd8aa309da041c98ab90a1552418 + +Release Notes: + ++ Mark isolated extension usages as experimental (#19050) ++ Fix a bug where frozen targets list was mutated while expanding env attribute (#19052) ++ Add documentation for --experimental_isolated_extension_usage (#19071) ++ Advertise CcInfo from cc_import (#19086) ++ Create .bazelversion to address postsubmit issues (#19089) ++ Update java_tools version to 12.6 (#19091) ++ Disable lockfiles by default (#19106) + +Acknowledgements: + +This release contains contributions from many people at Google, as well as Brentley Jones, Fabian Meumertzheim, oquenchil, Xùdōng Yáng. +``` + +## Release 7.0.0-pre.20230710.5 (2023-07-28) + +``` +Baseline: 7845acae9769a72dc507dc2f57c4e032ebf429d3 + +Cherry picks: + + + d9e2f9181f8fa283e3986ee3b261e610c41cf61b: + Avoid overcounting in ActionLookupValueProgressReceiver. + + da23370dcdf6ea19545002fb86bd5d3e6519cdf6: + Fix crash for top level aspects on targets with non-idempotent + rule transitions. + + 4714cd70c83de43ba7ab10c29e63af716216770a: + Reuse the built set of tools in `SpawnAction.Builder`. + + 0a1d50533078283fab93024681c917303a91c46c: + Correctly handle symlinks when prefetching. +``` + +Initial release. + ## Release 6.3.0 (2023-07-24) ``` diff --git a/MODULE.bazel b/MODULE.bazel index 77b720dd36049b..9d70633d92beba 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,5 +1,3 @@ -# To build Bazel with Bzlmod: `bazel build --enable_bzlmod //src:bazel_nojdk`. - module( name = "bazel", version = "7.0.0-pre", @@ -20,15 +18,33 @@ bazel_dep(name = "rules_cc", version = "0.0.8") bazel_dep(name = "rules_java", version = "6.3.0") bazel_dep(name = "rules_proto", version = "5.3.0-21.7") bazel_dep(name = "rules_jvm_external", version = "5.2") -bazel_dep(name = "rules_python", version = "0.19.0") +bazel_dep(name = "rules_python", version = "0.24.0") bazel_dep(name = "rules_testing", version = "0.0.4") +# TODO(pcloudy): Add remoteapis and googleapis as Bazel modules in the BCR. +bazel_dep(name = "remoteapis", version = "") +bazel_dep(name = "googleapis", version = "") + single_version_override( module_name = "rules_jvm_external", patch_strip = 1, patches = ["//third_party:rules_jvm_external_5.2.patch"], ) +local_path_override( + module_name = "remoteapis", + path = "./third_party/remoteapis", +) + +local_path_override( + module_name = "googleapis", + path = "./third_party/googleapis", +) + +# ========================================= +# Bazel Java dependencies +# ========================================= + maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") maven.install( # We don't yet specify the maven coordinates in the MODULE.bazel to avoid duplicating information. @@ -41,35 +57,66 @@ maven.install( ) use_repo(maven, "maven") -# TODO(pcloudy): Add remoteapis and googleapis as Bazel modules in the BCR. -bazel_dep(name = "remoteapis", version = "") -bazel_dep(name = "googleapis", version = "") - -local_path_override( - module_name = "remoteapis", - path = "./third_party/remoteapis", -) - -local_path_override( - module_name = "googleapis", - path = "./third_party/googleapis", -) +# ========================================= +# Other Bazel internal dependencies +# - embedded JDKs +# - repos for Debian build +# ========================================= bazel_internal_deps = use_extension("//:extensions.bzl", "bazel_internal_deps") use_repo( bazel_internal_deps, - "openjdk_linux_vanilla", + "debian_cc_deps", "openjdk_linux_aarch64_vanilla", "openjdk_linux_ppc64le_vanilla", "openjdk_linux_s390x_vanilla", - "openjdk_macos_x86_64_vanilla", + "openjdk_linux_vanilla", "openjdk_macos_aarch64_vanilla", - "openjdk_win_vanilla", + "openjdk_macos_x86_64_vanilla", "openjdk_win_arm64_vanilla", + "openjdk_win_vanilla", ) +# ========================================= +# Register platforms & toolchains +# ========================================= + +register_execution_platforms("//:default_host_platform") + register_toolchains("@bazel_tools//tools/python:autodetecting_toolchain") -# Dev dependencies +register_toolchains("//src/main/res:empty_rc_toolchain") + +# ========================================= +# Android tools dependencies +# ========================================= + +maven_android = use_extension("@rules_jvm_external//:extensions.bzl", "maven") +maven_android.install( + name = "maven_android", + # We don't yet specify the maven coordinates in the MODULE.bazel to avoid duplicating information. + # Always respect the maven_install.json file generated by rules_jvm_external from the WORKSPACE file. + # TODO(pcloudy): We should add maven coordinates here when we enable Bzlmod in the default build for Bazel. + lock_file = "//src/tools/android:maven_android_install.json", + repositories = [ + "https://dl.google.com/android/maven2", + "https://repo1.maven.org/maven2", + ], +) +use_repo(maven_android, "maven_android") + +bazel_android_deps = use_extension("//:extensions.bzl", "bazel_android_deps") +use_repo( + bazel_android_deps, + "android_gmaven_r8", + "desugar_jdk_libs", +) + +# ========================================= +# Bazel dev dependencies +# ========================================= + +bazel_dep(name = "googletest", version = "1.12.1", repo_name = "com_google_googletest") -bazel_dep(name = "googletest", version = "1.12.1", repo_name = "com_google_googletest", dev_dependency = True) +bazel_dev_deps = use_extension("//:extensions.bzl", "bazel_dev_deps") +use_repo(bazel_dev_deps, "local_bazel_source_list") diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod index 81e315557a362f..639b5f16465973 100644 --- a/WORKSPACE.bzlmod +++ b/WORKSPACE.bzlmod @@ -1,2 +1,54 @@ # This file will replace the content of the WORKSPACE file when Bzlmod is enabled # No WORKSPACE prefix or suffix are added. + +bind( + name = "android/sdk", + actual = "@bazel_tools//tools/android:poison_pill_android_sdk", +) + +bind( + name = "android/dx_jar_import", + actual = "@bazel_tools//tools/android:no_android_sdk_repository_error", +) + +bind( + name = "android/d8_jar_import", + actual = "@bazel_tools//tools/android:no_android_sdk_repository_error", +) + +bind( + name = "android/crosstool", + actual = "@bazel_tools//tools/cpp:toolchain", +) + +bind( + name = "android_sdk_for_testing", + actual = "@bazel_tools//tools/android:empty", +) + +bind( + name = "android_ndk_for_testing", + actual = "@bazel_tools//tools/android:empty", +) + +bind( + name = "databinding_annotation_processor", + actual = "@bazel_tools//tools/android:empty", +) + +# This value is overridden by android_sdk_repository function to allow targets +# to select on whether or not android_sdk_repository has run. +bind( + name = "has_androidsdk", + actual = "@bazel_tools//tools/android:always_false", +) + +# To run the Android integration tests in //src/test/shell/bazel/android:all or +# build the Android sample app in //examples/android/java/bazel:hello_world +# +# 1. Install an Android SDK and NDK from https://developer.android.com +# 2. Set the $ANDROID_HOME and $ANDROID_NDK_HOME environment variables +# 3. Uncomment the two lines below +# +# android_sdk_repository(name = "androidsdk") +# android_ndk_repository(name = "androidndk") diff --git a/extensions.bzl b/extensions.bzl index 800ee5f8dc9d23..1e38f0a4bcae03 100644 --- a/extensions.bzl +++ b/extensions.bzl @@ -17,8 +17,29 @@ """ load("//:repositories.bzl", "embedded_jdk_repositories") +load("//:distdir.bzl", "dist_http_archive", "dist_http_jar") +load("//tools/distributions/debian:deps.bzl", "debian_deps") +load("//src/test/shell/bazel:list_source_repository.bzl", "list_source_repository") + +### Extra dependencies for building Bazel def _bazel_internal_deps(_ctx): embedded_jdk_repositories() + debian_deps() bazel_internal_deps = module_extension(implementation = _bazel_internal_deps) + +### Extra dependencies for testing Bazel + +def _bazel_dev_deps(_ctx): + list_source_repository(name = "local_bazel_source_list") + +bazel_dev_deps = module_extension(implementation = _bazel_dev_deps) + +### Extra dependencies for Bazel Android tools + +def _bazel_android_deps(_ctx): + dist_http_jar(name = "android_gmaven_r8") + dist_http_archive(name = "desugar_jdk_libs") + +bazel_android_deps = module_extension(implementation = _bazel_android_deps) diff --git a/site/en/community/images/AspectBuildlogohorizontal-black.png b/site/en/community/images/AspectBuildlogohorizontal-black.png new file mode 100644 index 00000000000000..b8ae0bac3274b3 Binary files /dev/null and b/site/en/community/images/AspectBuildlogohorizontal-black.png differ diff --git a/site/en/community/images/gradle-enterprise-gradient-secondary.png b/site/en/community/images/gradle-enterprise-gradient-secondary.png new file mode 100644 index 00000000000000..77c47b40059c07 Binary files /dev/null and b/site/en/community/images/gradle-enterprise-gradient-secondary.png differ diff --git a/site/en/community/partners/_index.yaml b/site/en/community/partners/_index.yaml index d663dfd40feccf..61e316e2c13776 100644 --- a/site/en/community/partners/_index.yaml +++ b/site/en/community/partners/_index.yaml @@ -21,16 +21,10 @@ landing_page: items_across: 2 items: # Item 1 - - image_path: /community/images/aspect-build-logo.png + - image_path: /community/images/AspectBuildlogohorizontal-black.png heading: Aspect Build description: > - Aspect Build is the ultimate build, test, and CI/CD platform designed exclusively for Bazel users. Harness the - power of Aspect Workflows, a seamless, turn-key Bazel CI/CD system, fully compatible with your existing CI - provider. Elevate your development experience with Aspect CLI, a convenient drop-in replacement for the native - Bazel CLI. Unleash the full potential of Bazel for front-end development with Aspect's JavaScript Bazel rules. - Enjoy accelerated build times and reduced compute costs with Aspect Workflows, thanks to fast warming, - auto-scaling CI workers, horizontally scaling remote cache, and auto-scaling remote build executors - delivering - a remarkable 10x performance boost to your Bazel projects. Say goodbye to waiting and hello to rapid iteration! + Introducing Aspect Build - the ultimate build, test, and CI/CD platform designed exclusively for Bazel users. Harness the power of Aspect Workflows, a seamless, turn-key Bazel CI/CD system, fully compatible with your existing CI provider. Elevate your development experience with Aspect CLI, a convenient drop-in replacement for the native Bazel CLI. Unleash the full potential of Bazel for front-end development with Aspect's JavaScript Bazel rules. Enjoy accelerated build times and reduced compute costs with Aspect Workflows, thanks to fast warming, auto-scaling CI workers, horizontally scaling remote cache, and auto-scaling remote build executors - delivering a remarkable 10x performance boost to your Bazel projects. Say goodbye to waiting and hello to rapid iteration! buttons: - label: Learn more path: https://www.aspect.build/ @@ -73,11 +67,11 @@ landing_page: path: https://www.engflow.com/product/demo classname: button # Item 5 - - image_path: /community/images/Gradle.png - heading: Gradle + - image_path: /community/images/gradle-enterprise-gradient-secondary.png + heading: Gradle Inc. description: > - Gradle Enterprise is a multi-build-system platform for improving developer productivity and happiness.It does this by providing a comprehensive and end-to-end solution for build & test observability,acceleration, and failure analytics, and currently supports the Bazel, Apache Maven, Gradle, and SBT build systems.Specifically, Gradle Enterprise for Bazel supports Build Cache to speed up build and test feedback cycles;Build Scan® that is like an X-ray for your build to make troubleshooting more efficient; and Failure Analytics to improve toolchain reliability. + Gradle Enterprise is a multi-build-system platform for improving developer productivity and happiness. It does this by providing a comprehensive and end-to-end solution for build & test observability, acceleration, and failure analytics, and currently supports the Bazel, Apache Maven, Gradle, and SBT build systems. Specifically, Gradle Enterprise for Bazel supports Build Cache to speed up build and test feedback cycles; Build Scan® that is like an X-ray for your build to make troubleshooting more efficient; and Failure Analytics to improve toolchain reliability. buttons: - label: Learn more - path: https://gradle.com/ + path: https://gradle.com/gradle-enterprise-solutions/bazel-build-system/ classname: button diff --git a/site/en/extending/config.md b/site/en/extending/config.md index 1b4dbb312b2c9e..3dffb103ac528e 100644 --- a/site/en/extending/config.md +++ b/site/en/extending/config.md @@ -3,6 +3,8 @@ Book: /_book.yaml # Configurations + + {% include "_buttons.html" %} This page covers the benefits and basic usage of Starlark configurations, @@ -688,7 +690,7 @@ def _rule_impl(ctx): transitioned_dep = ctx.attr.dep[0] # Note: Access doesn't change, other_deps was already a list - for other dep in ctx.attr.other_deps: + for other_dep in ctx.attr.other_deps: # ... @@ -755,11 +757,11 @@ might create exponential growth of your build graph. **Figure 1.** Scalability graph showing a top level target and its dependencies. -This graph shows a top level target, //pkg:app, which depends on two targets, a -//pkg:1_0 and //pkg:1_1. Both these targets depend on two targets, //pkg:2_0 and -//pkg:2_1. Both these targets depend on two targets, //pkg:3_0 and //pkg:3_1. -This continues on until //pkg:n_0 and //pkg:n_1, which both depend on a single -target, //pkg:dep. +This graph shows a top level target, `//pkg:app`, which depends on two targets, a +`//pkg:1_0` and `//pkg:1_1`. Both these targets depend on two targets, `//pkg:2_0` and +`//pkg:2_1`. Both these targets depend on two targets, `//pkg:3_0` and `//pkg:3_1`. +This continues on until `//pkg:n_0` and `//pkg:n_1`, which both depend on a single +target, `//pkg:dep`. Building `//pkg:app` requires \\(2n+2\\) targets: @@ -767,7 +769,7 @@ Building `//pkg:app` requires \\(2n+2\\) targets: * `//pkg:dep` * `//pkg:i_0` and `//pkg:i_1` for \\(i\\) in \\([1..n]\\) -Imagine you [implement](#user-defined-build-settings)) a flag +Imagine you [implement](#user-defined-build-settings) a flag `--//foo:owner=` and `//pkg:i_b` applies depConfig = myConfig + depConfig.owner="$(myConfig.owner)$(b)" diff --git a/site/en/release/index.md b/site/en/release/index.md index d9375860d8280a..e2773cd9d2430a 100644 --- a/site/en/release/index.md +++ b/site/en/release/index.md @@ -84,7 +84,7 @@ on Github. | LTS release | Support stage | Latest version | End of support | | ----------- | ------------- | -------------- | -------------- | | Bazel 7 | Rolling| [Check GitHub release page](https://github.com/bazelbuild/bazel/releases){: .external} | N/A | -| Bazel 6 | Active | [6.3.0](https://github.com/bazelbuild/bazel/releases/tag/6.3.0){: .external} | Dec 2025 | +| Bazel 6 | Active | [6.3.1](https://github.com/bazelbuild/bazel/releases/tag/6.3.1){: .external} | Dec 2025 | | Bazel 5 | Maintenance | [5.4.1](https://github.com/bazelbuild/bazel/releases/tag/5.4.1){: .external} | Jan 2025 | | Bazel 4 | Maintenance | [4.2.4](https://github.com/bazelbuild/bazel/releases/tag/4.2.4){: .external} | Jan 2024 | diff --git a/src/main/java/com/google/devtools/build/docgen/annot/GlobalMethods.java b/src/main/java/com/google/devtools/build/docgen/annot/GlobalMethods.java index d6f382f40ae519..fdfadba95c7eab 100644 --- a/src/main/java/com/google/devtools/build/docgen/annot/GlobalMethods.java +++ b/src/main/java/com/google/devtools/build/docgen/annot/GlobalMethods.java @@ -29,19 +29,18 @@ public @interface GlobalMethods { /** The environment in which the global methods in the annotated class are available. */ enum Environment { + ALL( + "All Bazel files", + "Methods available in all Bazel files, including .bzl files, BUILD, MODULE.bazel," + + " and WORKSPACE."), + BZL(".bzl files", "Global methods available in all .bzl files."), BUILD( "BUILD files", - "This page contains global methods available in BUILD files. See also the Build" + "Methods available in BUILD files. See also the Build" + " Encyclopedia for extra functions and build rules," + " which can also be used in BUILD files."), - WORKSPACE("WORKSPACE files", "This page contains global methods available in WORKSPACE files."), - MODULE( - "MODULE.bazel files", "This page contains global methods available in MODULE.bazel files."), - BZL(".bzl files", "This page contains global methods available in all .bzl files."), - ALL( - "All Starlark files", - "This page contains global methods available in all Starlark files, including BUILD," - + " WORKSPACE, MODULE.bazel, and all .bzl files."); + MODULE("MODULE.bazel files", "Methods available in MODULE.bazel files."), + WORKSPACE("WORKSPACE files", "Methods available in WORKSPACE files."); private final String title; private final String description; diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionInputMap.java b/src/main/java/com/google/devtools/build/lib/actions/ActionInputMap.java index c2246977910db4..0b8e6767f22195 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionInputMap.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionInputMap.java @@ -261,6 +261,16 @@ public TreeArtifactValue getTreeMetadata(PathFragment execPath) { return ((TrieArtifact) value).treeArtifactValue; } + /** + * Returns the {@link TreeArtifactValue} for the shortest prefix of the given path, possibly the + * path itself, that corresponds to a tree artifact; or {@code null} if no such tree artifact + * exists. + */ + @Nullable + public TreeArtifactValue getTreeMetadataForPrefix(PathFragment execPath) { + return treeArtifactsRoot.findTreeArtifactNodeAtPrefix(execPath); + } + @Nullable @Override public ActionInput getInput(String execPathString) { diff --git a/src/main/java/com/google/devtools/build/lib/actions/SpawnExecutedEvent.java b/src/main/java/com/google/devtools/build/lib/actions/SpawnExecutedEvent.java index dfb8aa00f9773f..f5b55bbcfb3a4a 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/SpawnExecutedEvent.java +++ b/src/main/java/com/google/devtools/build/lib/actions/SpawnExecutedEvent.java @@ -64,13 +64,13 @@ public Instant getStartTimeInstant() { * runtime of the entire CriticalPathComponent. */ public static final class ChangePhase implements ExtendedEventHandler.Postable { - private final Action action; + private final ActionAnalysisMetadata action; - public ChangePhase(Action action) { + public ChangePhase(ActionAnalysisMetadata action) { this.action = action; } - public Action getAction() { + public ActionAnalysisMetadata getAction() { return this.action; } } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisOptions.java b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisOptions.java index 5ccce705a0a798..dd2014011e8c26 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisOptions.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisOptions.java @@ -39,6 +39,17 @@ public class AnalysisOptions extends OptionsBase { ) public boolean discardAnalysisCache; + @Option( + name = "allow_analysis_cache_discard", + defaultValue = "true", + documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, + effectTags = {OptionEffectTag.EAGERNESS_TO_EXIT}, + help = + "If discarding the analysis cache due to a change in the build system, setting this" + + " option to false will cause bazel to exit, rather than continuing with the build." + + " This option has no effect when 'discard_analysis_cache' is also set.") + public boolean allowAnalysisCacheDiscards; + @Option( name = "max_config_changes_to_show", defaultValue = "3", diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java index a0e9892b3e45a8..c3d2c9e6770b1b 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java @@ -255,7 +255,10 @@ public AnalysisResult update( } skyframeBuildView.setConfiguration( - eventHandler, topLevelConfig, viewOptions.maxConfigChangesToShow); + eventHandler, + topLevelConfig, + viewOptions.maxConfigChangesToShow, + viewOptions.allowAnalysisCacheDiscards); eventBus.post(new MakeEnvironmentEvent(topLevelConfig.getMakeEnvironment())); eventBus.post(topLevelConfig.toBuildEvent()); @@ -510,7 +513,7 @@ private AnalysisResult createResult( ImmutableMap labelToTargetMap, boolean includeExecutionPhase) throws InterruptedException { - Set