Skip to content

Commit

Permalink
Add blake3@1.5.1.bcr.1 (#1831)
Browse files Browse the repository at this point in the history
The previous version didn't actually build on ARM64 Windows.
  • Loading branch information
fmeum committed Apr 16, 2024
1 parent 7ecacf3 commit a42274f
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 1 deletion.
10 changes: 10 additions & 0 deletions modules/blake3/1.5.1.bcr.1/MODULE.bazel
@@ -0,0 +1,10 @@
module(
name = "blake3",
version = "1.5.1.bcr.1",
compatibility_level = 1,
)
bazel_dep(name = "rules_cc", version = "0.0.6")

# Required only by `--extra_toolchains=@local_config_cc//:cc-toolchain-arm64_windows` used in CI.
cc_configure = use_extension("@bazel_tools//tools/cpp:cc_configure.bzl", "cc_configure_extension", dev_dependency = True)
use_repo(cc_configure, "local_config_cc")
69 changes: 69 additions & 0 deletions modules/blake3/1.5.1.bcr.1/patches/add_build_file.patch
@@ -0,0 +1,69 @@
--- /dev/null
+++ BUILD.bazel
@@ -0,0 +1,66 @@
+load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
+
+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",
+ "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": [],
+ "@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_SSE2",
+ "-DBLAKE3_NO_SSE41",
+ "-DBLAKE3_NO_AVX2",
+ "-DBLAKE3_NO_AVX512",
+ ],
+ }),
+ includes = ["."],
+ visibility = ["//visibility:public"],
+)
+
+platform(
+ name = "internal_ci_only_do_not_use_windows_arm64",
+ constraint_values = [
+ "@@platforms//os:windows",
+ "@@platforms//cpu:arm64",
+ ],
+)
@@ -0,0 +1,46 @@
commit 0816badf3ada3ec48e712dd4f4cbc2cd60828278
Author: Javier Blazquez <jblazquez@riotgames.com>
Date: Sat Apr 6 17:30:49 2024 -0700

fix Windows ARM64 build and detect ARM64EC as ARM64

diff --git c/blake3_dispatch.c c/blake3_dispatch.c
index af6c3da..c9abc13 100644
--- c/blake3_dispatch.c
+++ c/blake3_dispatch.c
@@ -4,9 +4,12 @@

#include "blake3_impl.h"

-#if defined(IS_X86)
#if defined(_MSC_VER)
#include <Windows.h>
+#endif
+
+#if defined(IS_X86)
+#if defined(_MSC_VER)
#include <intrin.h>
#elif defined(__GNUC__)
#include <immintrin.h>
diff --git c/blake3_impl.h c/blake3_impl.h
index beab5cf..98611c3 100644
--- c/blake3_impl.h
+++ c/blake3_impl.h
@@ -28,7 +28,7 @@ enum blake3_flags {
#define INLINE static inline __attribute__((always_inline))
#endif

-#if defined(__x86_64__) || defined(_M_X64)
+#if (defined(__x86_64__) || defined(_M_X64)) && !defined(_M_ARM64EC)
#define IS_X86
#define IS_X86_64
#endif
@@ -38,7 +38,7 @@ enum blake3_flags {
#define IS_X86_32
#endif

-#if defined(__aarch64__) || defined(_M_ARM64)
+#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
#define IS_AARCH64
#endif

13 changes: 13 additions & 0 deletions modules/blake3/1.5.1.bcr.1/patches/module_dot_bazel.patch
@@ -0,0 +1,13 @@
--- MODULE.bazel
+++ MODULE.bazel
@@ -0,0 +1,10 @@
+module(
+ name = "blake3",
+ version = "1.5.1.bcr.1",
+ compatibility_level = 1,
+)
+bazel_dep(name = "rules_cc", version = "0.0.6")
+
+# Required only by `--extra_toolchains=@local_config_cc//:cc-toolchain-arm64_windows` used in CI.
+cc_configure = use_extension("@bazel_tools//tools/cpp:cc_configure.bzl", "cc_configure_extension", dev_dependency = True)
+use_repo(cc_configure, "local_config_cc")
29 changes: 29 additions & 0 deletions modules/blake3/1.5.1.bcr.1/presubmit.yml
@@ -0,0 +1,29 @@
matrix:
platform:
- centos7
- debian10
- fedora39
- ubuntu2004
- macos
- macos_arm64
- windows
bazel:
- 6.x
- 7.x
tasks:
verify_targets:
name: Verify build targets
platform: ${{ platform }}
bazel: ${{ bazel }}
build_targets:
- '@blake3//:blake3'
verify_targets_windows_arm:
name: Verify build targets for Windows ARM
platform: windows
bazel: ${{ bazel }}
build_targets:
- '@blake3//:blake3'
build_flags:
- '--incompatible_enable_cc_toolchain_resolution'
- '--platforms=@blake3//:internal_ci_only_do_not_use_windows_arm64'
- '--extra_toolchains=@local_config_cc//:cc-toolchain-arm64_windows'
11 changes: 11 additions & 0 deletions modules/blake3/1.5.1.bcr.1/source.json
@@ -0,0 +1,11 @@
{
"url": "https://github.com/BLAKE3-team/BLAKE3/archive/refs/tags/1.5.1.tar.gz",
"integrity": "sha256-gizTf3AVLlmFQz0sUMj2suyDqvEaoxvp/nFIapF0Tzc=",
"strip_prefix": "BLAKE3-1.5.1",
"patches": {
"add_build_file.patch": "sha256-BmZOqWOTfHup68uNZXOh2mP+b971CWY3QufbkIe6eEM=",
"module_dot_bazel.patch": "sha256-dKnHpXqvNwW2m7vYxnfWEoBhphBysqbeBxAMVX3b5a0=",
"fix_windows_arm_build_pr_389.patch": "sha256-9G3QDBp5OuyYP7vwPKjqK+uTUZmjhLpKSE7nshz8guc="
},
"patch_strip": 0
}
3 changes: 2 additions & 1 deletion modules/blake3/metadata.json
Expand Up @@ -12,7 +12,8 @@
"versions": [
"1.3.3",
"1.3.3.bcr.1",
"1.5.1"
"1.5.1",
"1.5.1.bcr.1"
],
"yanked_versions": {}
}

0 comments on commit a42274f

Please sign in to comment.