1
0
mirror of https://github.com/BLAKE3-team/BLAKE3 synced 2024-09-27 09:50:52 +02:00
Commit Graph

584 Commits

Author SHA1 Message Date
Taylor C. Richberger
8995bec78c switch SeedableRng::from_seed to use a keyed hasher 2023-11-14 13:09:21 -07:00
Taylor C. Richberger
9d090e2294 implement BufOutputReader and write rand traits around it. 2023-11-14 13:09:12 -07:00
Taylor C. Richberger
0933c1fde7 Add rand_core impls for OutputReader 2023-11-13 23:33:03 -07:00
Jack O'Connor
92e4cd71be add the compiler name to CMake CI jobs 2023-11-05 09:18:39 -08:00
Viacheslav H
1930721c50
Fix CMake target include directories if library is used with add_subdirectory or FetchContent 2023-11-05 12:16:48 -05:00
Rui Ueyama
e1f851d461 Fix Windows build with clang-cl
clang-cl is LLVM's MSVC-compatible compiler frontend for Windows ABI.
If clang-cl is in use, `CMAKE_C_COMPILER_ID` is `Clang` even though
it doesn't take Unix-like command line options but MSVC-like options.

`if(MSVC)` is the correct predicate to check if we should pass MSVC-ish
command line options.
2023-11-05 09:08:13 -08:00
Henrik Gaßmann
3465fe455e style: Exclude whitespace fixups from git blame 2023-10-31 11:53:11 +01:00
Henrik Gaßmann
3e14f865d3 style: Remove trailing whitespace in CMakeLists.txt 2023-10-31 11:51:26 +01:00
Henrik Gaßmann
bfd568897a build(CMake): Provide NEON cflags for ARMv8 32bit
ARMv8 CPUs are guaranteed to support NEON instructions. However, for
32bit ARMv8 triplets GCC needs to explicitly be configured to enable
NEON intrinsics.
2023-10-31 11:45:26 +01:00
Henrik Gaßmann
dd30dcb002 build(CMake): Apply PP definitions to all sources 2023-10-02 11:12:50 -07:00
Jack O'Connor
3d921ae703 allow(unreachable_code) in all the *_detected functions
Previously we only disabled these warnings for SSE2, which is assumed
enabled on x86-64, but it looks like new nightly compilers are also
assuming SSE4.1 on macOS. Disabling these warnings across all the
detection functions accounts for that, and it also gets rid of some
warnings that you'd see if you used RUSTFLAGS='-C target-cpu=native'.
2023-10-02 08:36:29 -07:00
Jack O'Connor
5aa53f07f7 version 1.5.0
Changes since 1.4.1:
- The Rust crate's Hasher type has gained new helper methods for common
  forms of IO: update_reader, update_mmap, and update_mmap_rayon. The
  latter matches the default behavior of b3sum. The mmap methods are
  gated by the new "mmap" Cargo feature.
- Most of the Rust crate's public types now implement the Zeroize trait.
  This is gated by the new "zeroize" Cargo feature.
- The Rust crate's Hash types now implements the serde Serialize and
  Deserialize traits. This is gated by the new "serde" Cargo feature.
- The C library now uses atomics to cache detected CPU features under
  most compilers other than MSVC. Previously this was a non-atomic
  write, which was probably "benign" but made TSan unhappy.
- NEON support is now disabled by default on big-endian AArch64.
  Previously this was a build error if the caller didn't explicitly
  disable it.
2023-09-20 20:12:18 -07:00
Jack O'Connor
d7e9365be1 add a test for the new serde feature 2023-09-19 23:43:47 -07:00
Ralph Minderhoud
5e3eb949a7 Add serde support for Hash behind optional feature
Added a new cargo feature `serde` that when enabled will derive
`serde::Serialize` and `serde::Deserialize` for the `blake3::Hash`
struct.
2023-09-19 21:54:44 -04:00
Jack O'Connor
4e25f2e094 don't default to NEON intrinsics in build.rs for big-endian targets 2023-09-19 17:18:31 -07:00
Havard Eidnes
8bfe93fbf9 c/blake3_impl.h: don't try to do NEON on big-endian aarch64.
...because this would otherwise hit
  #error "This implementation only supports little-endian ARM."
in c/blake3_neon.c.
2023-09-19 16:57:11 -07:00
Jack O'Connor
8cdfaa41ea minor cleanup in Hasher docs 2023-09-19 12:47:27 -07:00
Jack O'Connor
b754033a21 make update_reader/mmap/mmap_rayon return self
This makes them consistent with how the existing update() and
update_rayon() methods work, with the difference being that it's it's
io::Result<&mut Self> instead of just &mut Self.
2023-09-16 19:22:36 -07:00
Jack O'Connor
cb32f0bd14 replace the new file module with inherent methods on Hasher
New methods:
- update_reader
- update_mmap
- update_mmap_rayon

These are more discoverable, more convenient, and safer.

There are two problems I want to avoid by taking a `Path` instead of a
`File`. First, exposing `Mmap` objects to the caller is fundamentally
unsafe, and making `maybe_mmap_file` private avoids that issue. Second,
taking a `File` raises questions about whether memory mapped reads
should behave like regular file reads. (Should they respect the current
seek position? Should they update the seek position?) Taking a `Path`
from the caller and opening the `File` internally avoids these
questions.
2023-09-16 17:04:27 -07:00
Banyc
e0bb915641 move file operations from b3sum to blake3 2023-09-16 14:20:39 -07:00
Jack O'Connor
12b368541f document the zeroize Cargo feature
As part of this change, I don't think we need the `zeroize_crate`
workaround anymore if we use the relateively new `dep:` syntax in
Cargo.toml.
2023-09-16 14:11:27 -07:00
Jack O'Connor
f22d66b307 stop using MIPS for big-endian testing
https://twitter.com/burntsushi5/status/1695483429997945092
https://github.com/rust-lang/compiler-team/issues/648
2023-09-10 14:18:55 -07:00
Jack O'Connor
cd4b3140cf update the MSRV for b3sum to 1.70.0
As usual, the driver here is the MSRV of clap. I should've checked this
when I updated the Cargo.lock file.
2023-09-10 14:14:54 -07:00
Jack O'Connor
02dec6e9a6 fix a build break in the blake3_c tests 2023-09-10 14:04:57 -07:00
Jack O'Connor
d6265dafc9 update dev-dependencies 2023-09-10 13:40:12 -07:00
Javier Blazquez
12823b8760 blake3_dispatch: Fix race condition initializing g_cpu_features.
If multiple threads try to compute a hash simultaneously before the library has been used for the first time,
the logic in get_cpu_features that detects CPU features will write to g_cpu_features without synchronization,
which is a race condition and flagged by ThreadSanitizer.

This change marks g_cpu_features as an atomic variable to address the race condition.
2023-07-21 19:18:40 -07:00
Elichai Turkel
e302cdf36f Remove unneeded digest/std in std feature 2023-07-16 13:29:47 -04:00
Elichai Turkel
f18e19092b Add tests for Zeroize 2023-07-16 13:29:47 -04:00
Elichai Turkel
8e92fc6929 Implement Zeroize on exported types 2023-07-16 13:29:47 -04:00
Jack O'Connor
760ed6a8bf version 1.4.1
Changes since 1.4.0:
- Improved performance in the ARM NEON implementation for both C and
  Rust callers. This affects AArch64 targets by default and ARMv7
  targets that explicitly enable (and support) NEON. The size of the
  improvement depends on the microarchitecture, but I've benchmarked
  ~1.3x on a Cortex-A53 and ~1.2x on an Apple M1. Contributed by
  @sdlyyxy in #319.
- The MSRV is now 1.66.1 for both the `blake3` crate and `b3sum`.
2023-07-06 14:30:32 -07:00
Jack O'Connor
99af1ffc66 update constant_time_eq to v0.3.0
This bumps the MSRV of both `blake3` and `b3sum` to 1.66.1.
2023-07-06 13:26:08 -07:00
Jack O'Connor
f7e1a7429f retain the old NEON rotations in inline comments 2023-07-05 10:29:02 -07:00
sdlyyxy
7038dad280 NEON rot7/rot12 use shl+sri 2023-07-05 13:28:45 -04:00
sdlyyxy
a03b7af061 NEON: only use __builtin_shufflevector on clang 2023-07-05 13:28:45 -04:00
sdlyyxy
38a06e78d3 Improve NEON rot16/rot8 2023-07-05 13:28:45 -04:00
1f604
e47e570691 Fix typo exendable -> extendable 2023-06-27 11:31:51 -04:00
Henrik S. Gaßmann
3f396d2239 build(CMake): Rework NEON detection
Given the myriad of `-mfpu` options for ARM [1], the inability to
portably query for CPU support, and the lack of standardized ISA names
we have no other choice, but to opt out of automatically supplying NEON
compile flags. Instead we simply add the NEON optimized source file if
we detect an ISA with guaranteed NEON support (>= ARMv8) or the user
explicitly requests it (in which case he is expected to provide the
compile flags with `CMAKE_C_FLAGS` or `BLAKE3_CFLAGS_NEON` either
through a toolchain file or commandline parameters).

[1]: https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
2023-06-17 22:57:45 -04:00
Jack O'Connor
74220e2ca1 correct the VERSION in CMakeLists.txt 2023-06-17 13:22:26 -07:00
Henrik S. Gaßmann
072bef5bf0 build(CMake): Fix pkg-config directory specification
- Properly add the install prefix to the libdir and includedir.
- Define the prefix once.
- Quote paths which may contain whitespace.
2023-06-17 14:57:25 -04:00
Jack O'Connor
65733a753b version 1.4.0
Changes since 1.3.3:
- The C implementation provides a `CMakeLists.txt` for callers who build
  with CMake. The CMake build is not yet stable, and callers should
  expect breaking changes in patch version updates. The "by hand" build
  will always continue to be supported and documented.
- `b3sum` supports the `--seek` flag, to set the starting position in
  the output stream.
- `b3sum --check` prints a summary of errors to stderr.
- `Hash::as_bytes` is const.
- `Hash` supports `from_bytes`, which is const.
2023-06-08 13:06:32 -07:00
Jack O'Connor
0c7add10c6 update memmap2 to v0.7.0 2023-06-08 13:00:52 -07:00
Jack O'Connor
fbc96eb7ad factor out b3sum tests in ci.yml, to support a different MSRV 2023-06-08 12:49:32 -07:00
Jack O'Connor
4108923f52 add b3sum --seek 2023-06-06 20:25:00 -07:00
Henrik S. Gaßmann
76f9339312 build(cmake): Print the active SIMD configuration 2023-05-24 13:31:00 -07:00
Henrik S. Gaßmann
0e872a02ea build(cmake): Properly configure dispatcher for no SIMD
If no SIMD support could be configured we need to inform
`blake3_dispatch.c` about it.
2023-05-24 13:31:00 -07:00
Henrik S. Gaßmann
962d5f757e build(cmake): Correctly detect x86 and arm64 Windows
The ISA names communicated by `CMAKE_SYSTEM_PROCESSOR` aren't as much
standardized as one would wish they were. Factor the different names
into lists allowing for simpler checks and future updates.

Add hidden options for enabling SIMD support in case ISA detection
fails. These should only be used to temporarily workarounds until the
ISA name lists has been updated/fixed.
2023-05-24 13:31:00 -07:00
Jack O'Connor
ef5679ef7b Update c/CMakeLists.txt
Co-authored-by: Henrik Gaßmann <BurningEnlightenment@users.noreply.github.com>
2023-05-23 14:48:45 -07:00
Jack O'Connor
afebadf4a0 Update c/CMakeLists.txt
Co-authored-by: Henrik Gaßmann <BurningEnlightenment@users.noreply.github.com>
2023-05-23 14:48:45 -07:00
Henrik S. Gaßmann
1a9dd71681 Explicitly specify C symbol visibility
In order for blake3 to be usable as a shared library on Windows it is
required to annotate public symbols. Use this as an opportunity to prune
the symbol table for other OSes, too.
2023-05-23 14:48:45 -07:00
Henrik S. Gaßmann
4bb0466579 Refactor CMake buildsystem to be portable and modern
Aggreggate source files directly in the target instead of a proxy
variable.

Install CMake package config files in order to allow the project to be
found via `find_package()` by dependents.

Replace hard coded SIMD compiler flags with configurable options. Retain
the current GCC/Clang flags as defaults for these compilers. Add default
SIMD compiler flags for MSVC.

Remove hard coded compiler flags (including -fPIC). These are not
portable and should be set by the toolchain file or on the CLI.

- Guard ASM sources with triplet compatibility checks.
- Remove the `BLAKE3_STATIC` option in favor of [`BUILD_SHARED_LIBS`].

[`BUILD_SHARED_LIBS`]: https://cmake.org/cmake/help/v3.9/variable/BUILD_SHARED_LIBS.html
2023-05-23 14:48:45 -07:00