Compiling with Clang works without -flto{,=thin}, compiling with GCC with LTO also works. It is purely -flto & Clang which introduces this issue.
Build version is 1.8.7. Build system is Gentoo ~amd64.
The errors are the following, repeated:
/var/tmp/portage/dev-libs/libgcrypt-1.8.7/work/libgcrypt-1.8.7/cipher/sha256-avx-amd64.S:433:2: note: while in macro instantiation FOUR_ROUNDS_AND_SCHED ^ <instantiation>:53:2: error: invalid operand for instruction and y2, e ^
as well as:
/var/tmp/portage/dev-libs/libgcrypt-1.8.7/work/libgcrypt-1.8.7/cipher/sha512-avx-amd64.S:341:2: error: invalid operand for instruction add [digest + 8*(7)], h_64 ^ /var/tmp/portage/dev-libs/libgcrypt-1.8.7/work/libgcrypt-1.8.7/cipher/sha512-avx-amd64.S:344:6: error: ambiguous operand size for instruction 'add' add msg, 16*8 ^~~ /var/tmp/portage/dev-libs/libgcrypt-1.8.7/work/libgcrypt-1.8.7/cipher/sha512-avx-amd64.S:345:6: error: ambiguous operand size for instruction 'dec' dec msglen
CFLAGS:
CFLAGS="-march=znver2 -O3 -flto=thin -pipe"
gcc:
Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 10.2.0 (Gentoo 10.2.0-r5 p6)
clang:
clang version 11.0.1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/lib/llvm/11/bin Selected GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0
Build log: