Repository navigation
Argon2: fix build with -march=x86-64-v3/v4 and XOP targets - #1906
Merged
Merged
Conversation
blamka-round-opt.h picked its SSE2, AVX2 or AVX-512 definitions only from the compiler flags. With global flags such as -march=x86-64-v3 or -march=x86-64-v4, opt_sse2.c (and with v4 also opt_avx2.c) saw __AVX2__ or __AVX512F__ and got definitions that do not match its code, so the build failed. Let opt_sse2.c and opt_avx2.c select the variant they implement, and fall back to the compiler flags for other includers. This needs no new compiler options, so it also works with old compilers and with the plain objects used by NOASM=1 builds. With XOP targets (-march=bdver*), the header skipped its _mm_roti_epi64 fallback but did not include the intrinsic; include <x86intrin.h> for GCC and Clang there. Hashes are identical through the AVX2, SSE2 and reference code paths, and match an unmodified build. Fixes veracrypt#1867 Fixes veracrypt#1871
The #else/#endif comments still named __AVX2__ and __AVX512F__, but the branches are now selected by ARGON2_BLAMKA_USE_SSE2/AVX2. Refs veracrypt#1867
Member
|
Thanks, I prefer this approach. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1867 (the build error also reported in #1871). Alternative to #1890, opened at @puleglot's request.
When squashing: the first commit message says
Fixes #1871, please change that toRefs #1871, since #1871 is mainly about the Ubuntu 22.04 CI runner, which this doesn't touch.blamka-round-opt.hpicked its SSE2, AVX2 or AVX-512 definitions only from the compiler flags. With global flags such as-march=x86-64-v3or-march=x86-64-v4(Ubuntu 26.04, distribution builds,-march=native),opt_sse2.c, and with v4 alsoopt_avx2.c, got definitions that don't match their code, and the build failed.Changes:
opt_sse2.cdefinesARGON2_BLAMKA_SSE2andopt_avx2.cdefinesARGON2_BLAMKA_AVX2before including the header, and the header uses that to select the variant. Any other includer still gets the old selection by compiler flags.-mno-avx512fneeded) and also covers the plain objects used byNOASM=1builds.-march=bdver*), the header skipped its_mm_roti_epi64fallback, but the include that declares the intrinsic was commented out. The#include <x86intrin.h>that is already guarded by__XOP__ && (__GNUC__ || __clang__)is enabled again; MSVC and the Windows driver never take that branch.Testing:
opt_sse2.c,opt_avx2.c -mavx2andopt_avx2.cwithout-mavx2(as inNOASM=1) compile without errors or warnings (-Wall -Wextra) with GCC 10, 12, 14.2 and Clang 19.1.7, for default,x86-64-v2,x86-64-v3,x86-64-v4,bdver2,bdver4,znver4(not known to GCC 10),skylake-avx512andnative. On master, the v3, v4, bdver2, bdver4, znver4, skylake-avx512 and native builds (on an AVX2 host) fail.NOASM=1-style plain objects) are byte-identical to master.argon2id_hash_rawthrough the AVX2 path, the SSE2 path, and the portable code (forced withld --wrapon x86-64, whereHasSSE2()is always 1). All three give identical hashes, which also match an unmodified master build, with GCC 14 and Clang 19 for default and-march=x86-64-v3flags. The Argon2i/Argon2id self-tests pass through the AVX2 and SSE2 paths with GCC 10, GCC 14 and Clang 19 for default and-march=x86-64-v3flags.