1
0
Fork 0
mirror of https://github.com/BLAKE3-team/BLAKE3 synced 2024-05-27 00:16:03 +02:00
Commit Graph

340 Commits

Author SHA1 Message Date
Jack O'Connor 1d03c7d3fa print per-file errros more gracefuly in --check 2020-05-14 11:19:31 -04:00
Jack O'Connor 11edfb76f3 print more compiler version info in CI 2020-05-13 18:45:39 -04:00
Jack O'Connor c5c07bb337 refactor b3sum to support --check
This is an overall cleanup of everything that b3sum is doing, especially
file opening and memory mapping, which makes it easier for the regular
hashing mode to share code with the checking mode.
2020-05-13 18:23:59 -04:00
Jack O'Connor 5030c0f1c3 switch from assert_cmd to CARGO_BIN_EXE_* 2020-05-13 17:47:59 -04:00
Jack O'Connor c6a99dbb23 add parse_check_line
As part of this, reorganize b3sum tests into src/unit_tests.rs and
tests/cli_tests.rs.
2020-05-12 17:09:38 -04:00
Jack O'Connor 584a66598d stop printing the lossy warning
Rather than breaking the check parse with more output, we'll have a rule
that a Unicode replacement character (�) in a path name automatically
fails the check.
2020-05-12 09:58:54 -04:00
Jack O'Connor dc2a79d266 add newline and backslash escaping to b3sum output
As proposed in
https://github.com/BLAKE3-team/BLAKE3/issues/33#issuecomment-623153164

This brings b3sum behavior close to md5sum. All occurrences of backslash
are replaced with "\\", and all occurrences of (Unix) newline are
replaced with "\n". In addition, any line containing these escapes has a
single "\" prepended to the front.

Filepaths were already being converted to UTF-8 with to_string_lossy(),
but this commit adds an extra warning when that conversion is in fact
lossy (because the path is not valid Unicode). This new warning is
printed to stdout, with the goal of deliberately breaking --check (which
is not yet implemented) in this case.
2020-05-05 00:59:31 -04:00
Jack O'Connor 4ad79ae457 lower our required version of `cc`
I've tested manually and found that 1.0.4 is the oldest version of `cc`
that builds successfully for us. (Version 1.0.3 is missing the
`is_flag_supported` method.)

This change might help with
https://github.com/BLAKE3-team/BLAKE3/issues/83. That said, the
underlying issue there is related to "minimum supported Rust versions",
and `blake3` does not yet have an MSRV other than latest stable.
2020-05-04 10:23:03 -04:00
Jack O'Connor 0db6fddc86 version 0.3.3
Changes since 0.3.2:
- `b3sum` binaries are built in CI and attached to new GitHub tags.
2020-04-28 11:20:39 -04:00
Jack O'Connor ba468fbb4f build b3sum binaries in CI for new tags
These configs and code are adapted from the CI workflow in
https://github.com/oconnor663/blake3-py, especially the
upload_github_release_asset.py script, which is copied verbatim.
2020-04-28 11:04:29 -04:00
Jack O'Connor fcb4b83419 version 0.3.2
Changes since 0.3.1:
- Fixed a compiler error on older versions of Clang,
  https://github.com/BLAKE3-team/BLAKE3/issues/79.
2020-04-14 01:13:38 -04:00
Jack O'Connor d5e26538fc refactor build.rs
Two main changes:
- In https://github.com/BLAKE3-team/BLAKE3/issues/79 we learned that
  older versions of Clang require AVX-512 flags even to compile AVX-512
  assembly.
- If the C compiler doesn't support AVX-512, we'd still prefer to build
  the SSE4.1 and AVX2 assembly implementations, on x86_64.
2020-04-13 20:46:42 -04:00
Samuel Neves 7ef795d62e Do not require AVX512DQ
Whereas vinserti64x4 is present on AVX512F, vinserti32x8 requires
AVX512DQ, which we do not test for. At this point there is not
much risk of incompatibility, since Skylake-X chips have all the
requires instruction sets, but let's be precise about this.
2020-04-12 11:38:11 +01:00
Jack O'Connor 370ba3644a print the compiler version in CI, for help with debugging 2020-04-11 23:03:32 -04:00
Jack O'Connor 86c3174d5b unbreak neon benchmarks
A helper function was incorrectly restricted to x86-only. CI doesn't
currently cover this, because benchmarks are nightly-only, and it's kind
of inconvenient to set RUSTC_BOOTSTRAP=1 through `cross` (which normally
doesn't propagate env vars). But maybe we should start...
2020-04-10 11:24:39 -04:00
Jack O'Connor e3069da68e only run CI on branches and PRs, not tags 2020-04-02 10:23:46 -04:00
Jack O'Connor 5e82396d80 version 0.3.1
Changes since 0.3.0:
- The x86 build now automatically falls back to "pure" Rust intrinsics,
  under either of two possible conditions:
  1. The `cc` crate fails to invoke a C compiler at all, indicating that
     nothing of the right name (e.g. "cc" or "$CC" on Unix) is installed.
  2. The `cc` crate detects that the compiler doesn't support AVX-512
     flags, usually because it's too old.
  The end result should be that most callers successfully build the
  assembly implementations, and that callers who can't build those see a
  warning but not an error. (And note that Cargo suppresses warnings for
  non-path depencies.)
2020-04-02 10:08:47 -04:00
Jack O'Connor b8cdcb1f84 automatically fall back to the pure Rust build
There are two scenarios where compiling AVX-512 C or assembly code might
not work:

1. There might not be a C compiler installed at all. Most commonly this
   is either in cross-compiling situations, or with the Windows GNU
   target.
2. The installed C compiler might not support e.g. -mavx512f, because
   it's too old.

In both of these cases, print a relevant warning, and then automatically
fall back to using the pure Rust intrinsics build.

Note that this only affects x86 targets. Other targets always use pure
Rust, unless the "neon" feature is enabled.
2020-04-01 19:13:15 -04:00
Samuel Neves eec458d03e move prototypes to shared header file, and make all local functions static. 2020-03-31 21:21:08 +01:00
Jack O'Connor 2dff29cf0e turn all compiler warnings into errors in CI 2020-03-31 16:02:57 -04:00
Jack O'Connor 27f3273d68 put the CI badge back down in the README 2020-03-30 10:13:41 -04:00
Jack O'Connor 6fbc1a679d version 0.3.0
Changes since version 0.2.3:
- The optimized assembly implementations are now built by default. They
  perform better than the intrinsics implementations, and they compile
  much more quickly. Bringing the default behavior in line with reported
  benchmark figures should also simplify things for people running their
  own benchmarks. Previously this crate only built Rust intrinsics
  implementations by default, and the assembly implementations were
  gated by the (slightly confusingly named) "c" feature. Now the "c"
  feature is gone, and applications that need the old behavior can use
  the new "pure" feature. Mainly this will be applications that don't
  want to require a C compiler. Note that the `b3sum` crate previously
  activated the "c" feature by default, so its behavior hasn't changed.
2020-03-30 00:36:13 -04:00
Jack O'Connor 152740578e add testing-only flags to disable individual instruction sets
This lets CI test a wider range of possible SIMD support settings.
2020-03-29 23:12:47 -04:00
Jack O'Connor e06a0f255a refactor the Cargo feature set
The biggest change here is that assembly implementations are enabled by
default.

Added features:
- "pure" (Pure Rust, with no C or assembly implementations.)

Removed features:
- "c" (Now basically the default.)

Renamed features;
- "c_prefer_intrinsics" -> "prefer_intrinsics"
- "c_neon" -> "neon"

Unchanged:
- "rayon"
- "std" (Still the only feature on by default.)
2020-03-29 18:02:03 -04:00
Jack O'Connor 7caf1ad4bb version 0.2.3
Changes since version 0.2.2:
- Bug fix: Commit 13556be fixes a crash on Windows when using the SSE4.1
  assembly implementation (--features=c, set by default for b3sum). This
  is undefined behavior and therefore a potential security issue.
- b3sum now supports the --num-threads flag.
- The C API now includes a blake3_hasher_finalize_seek() function, which
  returns output from any position in the extended output stream.
- Build fix: Commit 5fad419 fixes a compiler error in the AVX-512 C
  intrinsics implementation targeting the Windows GNU ABI.
2020-03-29 01:44:00 -04:00
Jack O'Connor 5fad419a8d add a Windows GNU AVX-512 build break workaround
The break in question only repros under --release, and we didn't start
testing a release build of the prefer-intrinsics mode until just now.
2020-03-29 01:42:41 -04:00
Jack O'Connor 96c36d5df9 add more --release mode testing 2020-03-29 01:01:30 -04:00
Samuel Neves 13556be388 save missing clobbered registers on Windows 2020-03-29 05:53:37 +01:00
Jack O'Connor be4e7babee print instruction set support quietly 2020-03-28 19:51:54 -04:00
Jack O'Connor f77c8ffd7c print out instruction set support in CI 2020-03-28 19:30:28 -04:00
Jack O'Connor eb50d82f16 add release assembly tests 2020-03-28 19:15:25 -04:00
Jack O'Connor c26a37f70c C files -> C and assembly files 2020-03-25 17:25:48 -04:00
Jack O'Connor c3639b4255 c/README.md changes
The C implementation now supports output seeking. Also expand the API
section a bit, and reorganize things to put the example on top.
2020-03-25 17:11:36 -04:00
Jack O'Connor a4ceef3932 add blake3_hasher_finalize_seek to the C API 2020-03-25 17:11:36 -04:00
Jack O'Connor 4feadee6bb disable fail-fast for cross tests too 2020-03-24 16:45:33 -04:00
Jack O'Connor 9d77bd6958 correct a comment 2020-03-17 14:26:39 -04:00
Jack O'Connor c8f93a32bb add links to other implementations in the readme 2020-03-16 17:38:08 -04:00
Jack O'Connor 470d42a05a update b3sum/README.md 2020-03-16 12:26:16 -04:00
Jack O'Connor a0355ba8e0 add the --num-threads flag
As part of this change, make the rayon and memmap dependencies
mandatory. This simplifies the code a lot, and I'm not aware of any
callers who build b3sum without the default dependencies.

If --num-threads is not given, or if its value is 0, b3sum will still
respect the RAYON_NUM_THREADS environment variable.
2020-03-16 12:24:03 -04:00
Jack O'Connor d925728aed wrap --help output to 80 columns 2020-03-15 15:47:58 -04:00
Jack O'Connor 1f529a841c add an example of parsing a Hash from a hex string
Suggested by @zaynetro:
https://github.com/BLAKE3-team/BLAKE3/pull/24#issuecomment-594369061
2020-03-05 10:54:22 -05:00
Jack O'Connor 48f2f745d9 clean up the C example a bit 2020-03-01 17:33:36 -05:00
Jack O'Connor 0432f9c7a3 some comment typos 2020-02-27 09:52:46 -05:00
Jack O'Connor c197a773ac version 0.2.2
Changes since 0.2.1 (and since c-0.2.0):
- Fix a performance issue when the caller makes multiple calls to
  update() with uneven lengths. (#69, reported by @willbryant.)
2020-02-25 12:15:27 -05:00
Jack O'Connor 8d84cfc0af remove a mis-optimization that hurt performance for uneven updates
If the total number of chunks hashed so far is e.g. 1, and update() is
called with e.g. 8 more chunks, we can't compress all 8 together. We
have to break the input up, to make sure that that 1 lone chunk CV gets
merged with its proper sibling, and that in general the correct layout
of the tree is preserved. What we should do is hash 1-2-4-1 chunks of
input, using increasing powers of 2 (with some cleanup at the end). What
we were doing was 2-2-2-2 chunks. This was the result of a mistaken
optimization that got us stuck with an always-odd number of chunks so
far.

Fixes https://github.com/BLAKE3-team/BLAKE3/issues/69.
2020-02-25 11:40:37 -05:00
Jack O'Connor 74b5fe9054 update the red bar chart with the figure from the asm implementation 2020-02-21 18:14:31 -05:00
Jack O'Connor 9f6104c8ed add examples to the b3sum readme 2020-02-19 16:48:53 -05:00
Jack O'Connor fdd329ba57 check for AVX-512 compiler support even when using assembly 2020-02-14 11:59:59 -05:00
Jack O'Connor 865d201722 version 0.2.1
Changes since 0.2.0:
- Workarounds in the assembly implementations (enabled by the "c"
  feature), to build with older compilers.
2020-02-14 11:20:03 -05:00
Jack O'Connor fdeb3a38ee tag the first release of the C implementation, c-0.2.0
This release is motivated by a fix for a potential security
vulnerability. 421a21abd8 fixes a bug
introduced in a1c4c4efb5. A truncated
pointer register led to a segfault on x86-64 under Clang 7 and 8.
Clang 9 happens to be unaffected, but the behavior is undefined in
general. See also:
https://github.com/BLAKE3-team/BLAKE3/issues/60#issuecomment-585838317

The C implementation of BLAKE3 hasn't been formally packaged anywhere,
and most callers vendor code from master. This release tag is intended
to make the fix above more visible, to encourage callers to update their
vendored copies. We will continue to publish tags like this whenever
bugs in the C implementation are fixed, or if there are any incompatible
API changes.

Note that the issue above does not impact callers of the Rust `blake3`
crate. The affected file, `blake3_dispatch.c`, is not compiled by that
crate in any configuration. It does impact callers of the internal
`blake3_c_rust_bindings` crate, but that crate is not published on
crates.io and not intended for production use.
2020-02-13 12:30:10 -05:00