diff --git a/.bazelci/build_bazel_binaries.yml b/.bazelci/build_bazel_binaries.yml index 8bbd60ba4bc531..8a808d4c1472ac 100644 --- a/.bazelci/build_bazel_binaries.yml +++ b/.bazelci/build_bazel_binaries.yml @@ -5,29 +5,25 @@ platforms: - "//src:bazel" - "//src:bazel_nojdk" build_flags: - - "-c" - - "opt" + - "--config=release-linux" rockylinux8_arm64: build_targets: - "//src:bazel" - "//src:bazel_nojdk" build_flags: - - "-c" - - "opt" + - "--config=release-linux" ubuntu2004: build_targets: - "//src:bazel" - "//src:bazel_nojdk" build_flags: - - "-c" - - "opt" + - "--config=release-linux" ubuntu2004_arm64: build_targets: - "//src:bazel" - "//src:bazel_nojdk" build_flags: - - "-c" - - "opt" + - "--config=release-linux" # https://github.com/bazelbuild/continuous-integration/issues/2353 - "--linkopt=-Wl,--no-fix-cortex-a53-843419" - "--host_linkopt=-Wl,--no-fix-cortex-a53-843419" @@ -36,28 +32,24 @@ platforms: - "//src:bazel" - "//src:bazel_nojdk" build_flags: - - "-c" - - "opt" + - "--config=release-linux" macos: build_targets: - "//src:bazel" - "//src:bazel_nojdk" build_flags: - - "-c" - - "opt" + - "--config=release" macos_arm64: build_targets: - "//src:bazel" - "//src:bazel_nojdk" build_flags: - - "-c" - - "opt" + - "--config=release" windows: build_flags: - "--copt=-w" - "--host_copt=-w" - - "-c" - - "opt" + - "--config=release" build_targets: - "//src:bazel.exe" - "//src:bazel_nojdk.exe" @@ -65,8 +57,7 @@ platforms: build_flags: - "--copt=-w" - "--host_copt=-w" - - "-c" - - "opt" + - "--config=release" - "--config=windows_arm64" build_targets: - "//src:bazel.exe" diff --git a/.bazelrc b/.bazelrc index afa538f4c55d7b..74d99b153fd499 100644 --- a/.bazelrc +++ b/.bazelrc @@ -61,6 +61,16 @@ try-import %workspace%/user.bazelrc common:docs --workspace_status_command=scripts/docs/get_workspace_status.sh +# Flags for release builds +common:release --compilation_mode opt +common:release-linux --config=release +common:release-linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux +common:release-linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-aarch64-linux +common:release-linux --features=thin_lto + +# TMP +common:linux --config=release-linux + # Flags for CI builds ## Common common:ci-common --lockfile_mode=error diff --git a/MODULE.bazel b/MODULE.bazel index cb1aced6c2f49d..b2c8171f345584 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -33,6 +33,7 @@ bazel_dep(name = "rules_python", version = "1.4.1") bazel_dep(name = "rules_shell", version = "0.6.1") bazel_dep(name = "rules_testing", version = "0.6.0") bazel_dep(name = "stardoc", version = "0.7.2", repo_name = "io_bazel_skydoc") +bazel_dep(name = "toolchains_llvm", version = "1.5.0") bazel_dep(name = "with_cfg.bzl", version = "0.10.3") bazel_dep(name = "zlib", version = "1.3.1.bcr.5") bazel_dep(name = "zstd-jni", version = "1.5.6-9") @@ -157,9 +158,9 @@ maven.install( # keep sorted "args4j:args4j:2.37", "com.beust:jcommander:1.82", + "com.dylibso.chicory:log:1.5.2", "com.dylibso.chicory:runtime:1.5.2", "com.dylibso.chicory:wasm:1.5.2", - "com.dylibso.chicory:log:1.5.2", "com.github.ben-manes.caffeine:caffeine:3.1.8", "com.github.stephenc.jcip:jcip-annotations:1.0-1", "com.google.api-client:google-api-client:1.35.2", @@ -345,6 +346,56 @@ pip.parse( ) use_repo(pip, "bazel_pip_dev_deps") +# ========================================= +# C++ dependencies +# ========================================= + +# Required only by `--extra_toolchains=@local_config_cc//:cc-toolchain-arm64_windows` from .bazelrc +cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure_extension") +use_repo(cc_configure, "local_config_cc") + +http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +SYSROOT_BUILD_FILE = """ +filegroup( + name = "sysroot", + srcs = glob(["*/**"]), + visibility = ["//visibility:public"], +) +""" + +http_archive( + name = "chromium_sysroot_linux_x64", + build_file_content = SYSROOT_BUILD_FILE, + sha256 = "84656a6df544ecef62169cfe3ab6e41bb4346a62d3ba2a045dc5a0a2ecea94a3", + urls = [ + "https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/2202c161310ffde63729f29d27fe7bb24a0bc540/debian_stretch_amd64_sysroot.tar.xz", + ], +) + +http_archive( + name = "chromium_sysroot_linux_aarch64", + build_file_content = SYSROOT_BUILD_FILE, + sha256 = "e39b700d8858d18868544c8c84922f6adfa8419f3f42471b92024ba38eff7aca", + urls = [ + "https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/2202c161310ffde63729f29d27fe7bb24a0bc540/debian_stretch_arm64_sysroot.tar.xz", + ], +) + +llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") + +# Use a version that still runs on Rocky Linux 8. +llvm.toolchain(llvm_version = "17.0.6") +llvm.sysroot( + label = "@chromium_sysroot_linux_x64//:sysroot", + targets = ["linux-x86_64"], +) +llvm.sysroot( + label = "@chromium_sysroot_linux_aarch64//:sysroot", + targets = ["linux-aarch64"], +) +use_repo(llvm, "llvm_toolchain") + # ========================================= # Other Bazel build dependencies # ========================================= @@ -371,10 +422,6 @@ use_repo( "openjdk_win_vanilla", ) -# Required only by `--extra_toolchains=@local_config_cc//:cc-toolchain-arm64_windows` from .bazelrc -cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure_extension") -use_repo(cc_configure, "local_config_cc") - http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") # DO NOT UPDATE the jq versions, they are used to verify compatibility with old and new versions. diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 1b971965398b95..e2c3dd0856ed65 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -204,6 +204,7 @@ "https://bcr.bazel.build/modules/rules_cc/0.1.2/MODULE.bazel": "557ddc3a96858ec0d465a87c0a931054d7dcfd6583af2c7ed3baf494407fd8d0", "https://bcr.bazel.build/modules/rules_cc/0.1.5/MODULE.bazel": "88dfc9361e8b5ae1008ac38f7cdfd45ad738e4fa676a3ad67d19204f045a1fd8", "https://bcr.bazel.build/modules/rules_cc/0.2.0/MODULE.bazel": "b5c17f90458caae90d2ccd114c81970062946f49f355610ed89bebf954f5783c", + "https://bcr.bazel.build/modules/rules_cc/0.2.2/MODULE.bazel": "a0656c5a8ff7f76bb1319ebf301bab9d94da5b48894cac25a14ed115f9dd0884", "https://bcr.bazel.build/modules/rules_cc/0.2.8/MODULE.bazel": "f1df20f0bf22c28192a794f29b501ee2018fa37a3862a1a2132ae2940a23a642", "https://bcr.bazel.build/modules/rules_cc/0.2.9/MODULE.bazel": "34263f1dca62ea664265438cef714d7db124c03e1ed55ebb4f1dc860164308d1", "https://bcr.bazel.build/modules/rules_cc/0.2.9/source.json": "4e49b40effcbd14fbfb233eb929de42dfff7b66538b4ffda310ad501638e7986", @@ -297,6 +298,8 @@ "https://bcr.bazel.build/modules/stardoc/0.7.2/source.json": "58b029e5e901d6802967754adf0a9056747e8176f017cfe3607c0851f4d42216", "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/MODULE.bazel": "5e463fbfba7b1701d957555ed45097d7f984211330106ccd1352c6e0af0dcf91", "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/source.json": "32bd87e5f4d7acc57c5b2ff7c325ae3061d5e242c0c4c214ae87e0f1c13e54cb", + "https://bcr.bazel.build/modules/toolchains_llvm/1.5.0/MODULE.bazel": "31c7077ef64bafdf2dfb46d4bca321b4e8f143b00ac68b2c31f5ff0c91044b60", + "https://bcr.bazel.build/modules/toolchains_llvm/1.5.0/source.json": "aecbd0eea924f27bf8d33d3823f1427e1eddc826ff96425e4304b0d7ad6d7ffa", "https://bcr.bazel.build/modules/upb/0.0.0-20211020-160625a/MODULE.bazel": "6cced416be2dc5b9c05efd5b997049ba795e5e4e6fafbe1624f4587767638928", "https://bcr.bazel.build/modules/upb/0.0.0-20230516-61a97ef/MODULE.bazel": "c0df5e35ad55e264160417fd0875932ee3c9dda63d9fccace35ac62f45e1b6f9", "https://bcr.bazel.build/modules/upb/0.0.0-20230907-e7430e6/MODULE.bazel": "3a7dedadf70346e678dc059dbe44d05cbf3ab17f1ce43a1c7a42edc7cbf93fd9", @@ -866,6 +869,98 @@ ] ] } + }, + "@@toolchains_llvm+//toolchain/extensions:llvm.bzl%llvm": { + "general": { + "bzlTransitiveDigest": "c91yAeoX1Jx16JQSsb7J/fY+/nWiCnOiMgjfjoXqbSQ=", + "usagesDigest": "uCjk3Pz08vNQ1lvsEjkBy/OmdQqnEe3rQA+89U/OnnU=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "llvm_toolchain_llvm": { + "repoRuleId": "@@toolchains_llvm+//toolchain:rules.bzl%llvm", + "attributes": { + "alternative_llvm_sources": [], + "auth_patterns": {}, + "distribution": "auto", + "exec_arch": "", + "exec_os": "", + "extra_llvm_distributions": {}, + "libclang_rt": {}, + "llvm_mirror": "", + "llvm_version": "17.0.6", + "llvm_versions": {}, + "netrc": "", + "sha256": {}, + "strip_prefix": {}, + "urls": {} + } + }, + "llvm_toolchain": { + "repoRuleId": "@@toolchains_llvm+//toolchain:rules.bzl%toolchain", + "attributes": { + "absolute_paths": false, + "archive_flags": {}, + "compile_flags": {}, + "conly_flags": {}, + "coverage_compile_flags": {}, + "coverage_link_flags": {}, + "cxx_builtin_include_directories": {}, + "cxx_flags": {}, + "cxx_standard": {}, + "dbg_compile_flags": {}, + "exec_arch": "", + "exec_os": "", + "extra_exec_compatible_with": {}, + "extra_target_compatible_with": {}, + "fastbuild_compile_flags": {}, + "link_flags": {}, + "link_libs": {}, + "llvm_versions": { + "": "17.0.6" + }, + "opt_compile_flags": {}, + "opt_link_flags": {}, + "stdlib": {}, + "target_settings": {}, + "unfiltered_compile_flags": {}, + "toolchain_roots": {}, + "sysroot": { + "linux-x86_64": "'@@+_repo_rules+chromium_sysroot_linux_x64//:sysroot'", + "linux-aarch64": "'@@+_repo_rules+chromium_sysroot_linux_aarch64//:sysroot'" + } + } + } + }, + "recordedRepoMappingEntries": [ + [ + "", + "chromium_sysroot_linux_aarch64", + "+_repo_rules+chromium_sysroot_linux_aarch64" + ], + [ + "", + "chromium_sysroot_linux_x64", + "+_repo_rules+chromium_sysroot_linux_x64" + ], + [ + "toolchains_llvm+", + "bazel_skylib", + "bazel_skylib+" + ], + [ + "toolchains_llvm+", + "bazel_tools", + "bazel_tools" + ], + [ + "toolchains_llvm+", + "toolchains_llvm", + "toolchains_llvm+" + ] + ] + } } } } diff --git a/scripts/kokoro/release/build_linux.sh b/scripts/kokoro/release/build_linux.sh index 0370e0562ed860..6f5fa9fd5db461 100755 --- a/scripts/kokoro/release/build_linux.sh +++ b/scripts/kokoro/release/build_linux.sh @@ -37,7 +37,7 @@ mkdir output cp bazel-bin/src/bazel output/bazel output/bazel build \ - -c opt \ + --config=release-linux \ --stamp \ --sandbox_tmpfs_path=/tmp \ --embed_label "${RELEASE_NAME}" \ @@ -59,4 +59,3 @@ if [ $ARCHITECTURE = "x86_64" ]; then cp "bazel-bin/scripts/packages/debian/bazel.tar.gz" "artifacts/bazel_${RELEASE_NAME}.tar.gz" cp "bazel-bin/bazel-distfile.zip" "artifacts/bazel-${RELEASE_NAME}-dist.zip" fi - diff --git a/scripts/kokoro/release/build_macos.sh b/scripts/kokoro/release/build_macos.sh index 9edf718e1cd648..4da14bf99eb8d5 100755 --- a/scripts/kokoro/release/build_macos.sh +++ b/scripts/kokoro/release/build_macos.sh @@ -34,7 +34,7 @@ cp bazel-bin/src/bazel output/bazel output/bazel build \ --define IPHONE_SDK=1 \ - -c opt \ + --config=release \ --stamp \ --embed_label "${RELEASE_NAME}" \ --workspace_status_command=scripts/ci/build_status_command.sh \ diff --git a/scripts/kokoro/release/build_windows.bat b/scripts/kokoro/release/build_windows.bat index 4727996de770e8..9f2a8b9121ee24 100755 --- a/scripts/kokoro/release/build_windows.bat +++ b/scripts/kokoro/release/build_windows.bat @@ -26,7 +26,7 @@ set PATH=C:\python37;%PATH% mkdir output copy bazel-bin\src\bazel.exe output\bazel.exe -output\bazel build -c opt --copt=-w --host_copt=-w --stamp --embed_label %RELEASE_NAME% src/bazel scripts/packages/bazel.zip +output\bazel build --config=release --copt=-w --host_copt=-w --stamp --embed_label %RELEASE_NAME% src/bazel scripts/packages/bazel.zip mkdir artifacts move bazel-bin\src\bazel artifacts\bazel-%RELEASE_NAME%-windows-x86_64.exe diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/java/turbine/BUILD b/src/java_tools/buildjar/java/com/google/devtools/build/java/turbine/BUILD index ba9c688e3b6fee..d5c17402e8a8f7 100644 --- a/src/java_tools/buildjar/java/com/google/devtools/build/java/turbine/BUILD +++ b/src/java_tools/buildjar/java/com/google/devtools/build/java/turbine/BUILD @@ -122,8 +122,6 @@ native_image( ":do_use_oracle_graalvm": ["profile.iprof"], "//conditions:default": [], }), - # This provides libz.a on Linux instead of the host system. - static_zlib = "@zlib", deps = [":turbine_deps"], ) diff --git a/src/upload_all_java_tools.sh b/src/upload_all_java_tools.sh index 59880df0982262..e4fc893feb1668 100755 --- a/src/upload_all_java_tools.sh +++ b/src/upload_all_java_tools.sh @@ -58,7 +58,11 @@ commit_hash=$(git rev-parse HEAD) timestamp=$(date +%s) bazel_version=$(bazel info release | cut -d' ' -f2) -RELEASE_BUILD_OPTS="-c opt" +if [[ "$platform" == "linux" ]]; then +RELEASE_BUILD_OPTS="--config=release-linux" +else +RELEASE_BUILD_OPTS="--config=release" +fi # Check that the build machine is set up for Unicode. bazel run ${RELEASE_BUILD_OPTS} //src:CheckSunJnuEncoding