diff --git a/MODULE.bazel b/MODULE.bazel index 4421be477cb34b..510f4e372ab8c0 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -30,6 +30,7 @@ bazel_dep(name = "rules_jvm_external", version = "6.0") bazel_dep(name = "rules_python", version = "0.28.0") bazel_dep(name = "rules_testing", version = "0.0.4") bazel_dep(name = "googletest", version = "1.14.0", repo_name = "com_google_googletest") +bazel_dep(name = "with_cfg.bzl", version = "0.2.4") # TODO(pcloudy): Add remoteapis and googleapis as Bazel modules in the BCR. bazel_dep(name = "remoteapis", version = "") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 33f21354296908..b75d37918e08cd 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1,6 +1,6 @@ { "lockFileVersion": 6, - "moduleFileHash": "66948a27fd148b6c67d7cd1a13b88b9087654044d7eb877dbfca912072f2498f", + "moduleFileHash": "13a19e74796a86b23f1a1e6699a0c3fa5cb1fa9d908689bab86a144802235662", "flags": { "cmdRegistries": [ "https://bcr.bazel.build/" @@ -39,7 +39,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 74, + "line": 75, "column": 22 }, "imports": { @@ -170,7 +170,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 75, + "line": 76, "column": 14 } }, @@ -185,7 +185,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 201, + "line": 202, "column": 19 } }, @@ -200,7 +200,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 201, + "line": 202, "column": 19 } }, @@ -215,7 +215,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 201, + "line": 202, "column": 19 } }, @@ -230,7 +230,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 201, + "line": 202, "column": 19 } }, @@ -245,7 +245,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 201, + "line": 202, "column": 19 } }, @@ -260,7 +260,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 201, + "line": 202, "column": 19 } }, @@ -275,7 +275,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 201, + "line": 202, "column": 19 } }, @@ -290,7 +290,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 201, + "line": 202, "column": 19 } }, @@ -305,7 +305,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 201, + "line": 202, "column": 19 } }, @@ -333,7 +333,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 341, + "line": 342, "column": 22 } } @@ -347,7 +347,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 222, + "line": 223, "column": 32 }, "imports": { @@ -387,7 +387,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 256, + "line": 257, "column": 23 }, "imports": {}, @@ -401,7 +401,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 257, + "line": 258, "column": 17 } } @@ -415,7 +415,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 259, + "line": 260, "column": 20 }, "imports": { @@ -433,7 +433,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 260, + "line": 261, "column": 10 } } @@ -447,7 +447,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 271, + "line": 272, "column": 33 }, "imports": { @@ -478,7 +478,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 292, + "line": 293, "column": 29 }, "imports": { @@ -495,7 +495,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 295, + "line": 296, "column": 20 }, "imports": { @@ -514,7 +514,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 296, + "line": 297, "column": 12 } } @@ -528,7 +528,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 308, + "line": 309, "column": 32 }, "imports": { @@ -547,7 +547,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 316, + "line": 317, "column": 31 }, "imports": { @@ -564,7 +564,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 319, + "line": 320, "column": 48 }, "imports": { @@ -581,7 +581,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 363, + "line": 364, "column": 35 }, "imports": { @@ -598,7 +598,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 366, + "line": 367, "column": 42 }, "imports": { @@ -616,7 +616,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 369, + "line": 370, "column": 45 }, "imports": { @@ -647,6 +647,7 @@ "rules_python": "rules_python@0.28.0", "rules_testing": "rules_testing@0.0.4", "com_google_googletest": "googletest@1.14.0", + "with_cfg.bzl": "with_cfg.bzl@0.2.4", "remoteapis": "remoteapis@_", "googleapis": "googleapis@_", "apple_support": "apple_support@1.8.1", @@ -1784,6 +1785,35 @@ } } }, + "with_cfg.bzl@0.2.4": { + "name": "with_cfg.bzl", + "version": "0.2.4", + "key": "with_cfg.bzl@0.2.4", + "repoName": "with_cfg.bzl", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "bazel_skylib": "bazel_skylib@1.5.0", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "urls": [ + "https://github.com/fmeum/with_cfg.bzl/releases/download/v0.2.4/with_cfg.bzl-v0.2.4.tar.gz" + ], + "integrity": "sha256-BqKxtWpYxHGrQNivFmxNUfCYLhxrxGN1uAWRWz/AZY4=", + "strip_prefix": "with_cfg.bzl-0.2.4", + "remote_patches": { + "https://bcr.bazel.build/modules/with_cfg.bzl/0.2.4/patches/module_dot_bazel_version.patch": "sha256-nMJ63F1h826i8AWSmXwz9pZYDwKfOnM5QdrZqyCLYMo=" + }, + "remote_patch_strip": 1 + } + } + }, "remoteapis@_": { "name": "remoteapis", "version": "", @@ -2848,7 +2878,7 @@ "general": { "bzlTransitiveDigest": "aUI/st4EW9i8qtBNAuP8n/ZqWg45cC/XT4qKpSzhCtc=", "recordedFileInputs": { - "@@//MODULE.bazel": "66948a27fd148b6c67d7cd1a13b88b9087654044d7eb877dbfca912072f2498f", + "@@//MODULE.bazel": "13a19e74796a86b23f1a1e6699a0c3fa5cb1fa9d908689bab86a144802235662", "@@//src/test/tools/bzlmod/MODULE.bazel.lock": "968f7abec98f28f82bdc86b6335ab51ba7734a5896fa9d5db0feb7e97e596843" }, "recordedDirentsInputs": {}, diff --git a/src/test/java/com/google/devtools/build/lib/vfs/bazel/BUILD b/src/test/java/com/google/devtools/build/lib/vfs/bazel/BUILD index 54a712588bf61a..4307662b71318c 100644 --- a/src/test/java/com/google/devtools/build/lib/vfs/bazel/BUILD +++ b/src/test/java/com/google/devtools/build/lib/vfs/bazel/BUILD @@ -1,4 +1,5 @@ load("@rules_java//java:defs.bzl", "java_library", "java_test") +load(":java_opt_binary.bzl", "java_opt_binary") package( default_applicable_licenses = ["//:license"], @@ -44,7 +45,7 @@ java_test( ], ) -java_binary( +java_opt_binary( name = "BazelHashFunctionsBenchmark", srcs = ["BazelHashFunctionsBenchmark.java"], main_class = "org.openjdk.jmh.Main", diff --git a/src/test/java/com/google/devtools/build/lib/vfs/bazel/java_opt_binary.bzl b/src/test/java/com/google/devtools/build/lib/vfs/bazel/java_opt_binary.bzl new file mode 100644 index 00000000000000..22981ee40d3573 --- /dev/null +++ b/src/test/java/com/google/devtools/build/lib/vfs/bazel/java_opt_binary.bzl @@ -0,0 +1,3 @@ +load("@with_cfg.bzl", "with_cfg") + +java_opt_binary, _java_opt_binary = with_cfg(native.java_binary).set("compilation_mode", "opt").build() diff --git a/third_party/blake3/blake3.BUILD b/third_party/blake3/blake3.BUILD new file mode 100644 index 00000000000000..d8e76ece8660aa --- /dev/null +++ b/third_party/blake3/blake3.BUILD @@ -0,0 +1,102 @@ +load("@rules_license//rules:license.bzl", "license") +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") + +licenses(["notice"]) # BSD/MIT-like license + +exports_files(["LICENSE"]) + +license( + name = "license", + package_name = "blake3", + license_kinds = [ + "@rules_license//licenses/spdx:Apache-2.0", + ], + license_text = "LICENSE", + package_version = "1.3.3", +) + +filegroup( + name = "srcs", + srcs = glob(["**"]), + visibility = ["//third_party:__pkg__"], +) + +cc_library( + name = "blake3", + srcs = [ + "c/blake3.c", + "c/blake3_dispatch.c", + "c/blake3_portable.c", + ] + select({ + "@bazel_tools//src/conditions:linux_x86_64": [ + "c/blake3_avx2_x86-64_unix.S", + # Disable to appease bazel-ci which uses ubuntu-18 (EOL) and GCC 7 + # lacking the headers to compile AVX512. + # "c/blake3_avx512_x86-64_unix.S", + "c/blake3_sse2_x86-64_unix.S", + "c/blake3_sse41_x86-64_unix.S", + ], + "@bazel_tools//src/conditions:linux_aarch64": [ + "c/blake3_neon.c", + ], + "@bazel_tools//src/conditions:windows_x64": [ + "c/blake3_avx2_x86-64_windows_msvc.asm", + "c/blake3_avx512_x86-64_windows_msvc.asm", + "c/blake3_sse2_x86-64_windows_msvc.asm", + "c/blake3_sse41_x86-64_windows_msvc.asm", + ], + "@bazel_tools//src/conditions:windows_arm64": [ + "c/blake3_neon.c", + ], + "@bazel_tools//src/conditions:darwin_arm64": [ + "c/blake3_neon.c", + ], + "//conditions:default": [], + }), + hdrs = [ + "c/blake3.h", + "c/blake3_impl.h", + ], + copts = select({ + "@bazel_tools//src/conditions:linux_x86_64": [ + # Disable to appease bazel-ci which uses ubuntu-18 (EOL) and GCC 7 + # lacking the headers to compile AVX512. + "-DBLAKE3_NO_AVX512", + ], + "@bazel_tools//src/conditions:linux_aarch64": [ + "-DBLAKE3_USE_NEON=1", + ], + "@bazel_tools//src/conditions:windows_x64": [], + "@bazel_tools//src/conditions:windows_arm64": [ + "-DBLAKE3_USE_NEON=1", + ], + "@bazel_tools//src/conditions:darwin_arm64": [ + "-DBLAKE3_USE_NEON=1", + ], + "//conditions:default": [ + "-DBLAKE3_NO_AVX2", + "-DBLAKE3_NO_AVX512", + "-DBLAKE3_NO_NEON", + "-DBLAKE3_NO_SSE2", + "-DBLAKE3_NO_SSE41", + ], + }), + includes = ["."], + visibility = ["//visibility:public"], +) + +cc_binary( + name = "example", + srcs = [ + "c/example.c", + ], + copts = [ + "-w", + "-O3", + ], + includes = ["."], + visibility = ["//visibility:public"], + deps = [ + ":blake3", + ], +)