Page MenuHome GnuPG

libgcrypt 1.9.1 fails to build with --disable-asm
Closed, ResolvedPublic


libgcrypt 1.9.1 contains a couple of changes to configure wrt. the detection of hardware architecture and capabilities. This detection fails when configuring with --disable-asm. Consequently, build fails because some macros are not defined.

E.g., on my system (macOS, amd64) build fails with the following message:

keccak.c:907:23: error: use of undeclared identifier 'HWF_INTEL_FAST_SHLD'


Revisions and Commits

Event Timeline

werner triaged this task as Normal priority.Jan 29 2021, 4:43 PM
werner added projects: libgcrypt, MacOS.

FYI, this is not just an MacOS issue. We see that also on Gentoo Linux:

libtool: compile:  x86_64-pc-linux-gnu-gcc -m32 -DHAVE_CONFIG_H -I. -I/var/tmp/portage/dev-libs/libgcrypt-1.9.1/work/libgcrypt-1.9.1/random -I.. -I../src -I/var/tmp/portage/dev-libs/libgcrypt-1.9.1/work/libgcrypt-1.9.1/src -O2 -pipe -march=znver2 -mno-clzero -mno-mwaitx -mno-wbnoinvd -frecord-gcc-switches -fvisibility=hidden -fno-delete-null-pointer-checks -Wall -c /var/tmp/portage/dev-libs/libgcrypt-1.9.1/work/libgcrypt-1.9.1/random/rndjent.c  -fPIC -DPIC -o .libs/rndjent.o
/var/tmp/portage/dev-libs/libgcrypt-1.9.1/work/libgcrypt-1.9.1/random/rndjent.c: In function ‘is_rng_available’:
/var/tmp/portage/dev-libs/libgcrypt-1.9.1/work/libgcrypt-1.9.1/random/rndjent.c:240:40: error: ‘HWF_INTEL_RDTSC’ undeclared (first use in this function)
  240 |   return !!(_gcry_get_hw_features () & HWF_INTEL_RDTSC);
      |                                        ^~~~~~~~~~~~~~~
/var/tmp/portage/dev-libs/libgcrypt-1.9.1/work/libgcrypt-1.9.1/random/rndjent.c:240:40: note: each undeclared identifier is reported only once for each function it appears in
/var/tmp/portage/dev-libs/libgcrypt-1.9.1/work/libgcrypt-1.9.1/random/rndjent.c:248:1: warning: control reaches end of non-void function [-Wreturn-type]
  248 | }
      | ^
make[2]: *** [Makefile:742: rndjent.lo] Error 1
make[2]: Leaving directory '/var/tmp/portage/dev-libs/libgcrypt-1.9.1/work/libgcrypt-1.9.1-abi_x86_32.x86/random'
make[1]: *** [Makefile:504: all-recursive] Error 1

Thanks for your report.

It would be good to check if "--disable-asm" is needed at all. If building without "--disable-asm" fails, please report bug.

With --disable-asm, you'll lose all acceleration, for example, on AES. For example, AES-CTR on amd64 without "--disable-asm" is 40 times faster than implementation you get with "--disable-asm" (on Ryzen 5800X).

If building without "--disable-asm" does not work, reverting commit 8d404a629167d67ed56e45de3e65d1e0b7cdeb24 will solve the issue. But before you do that, please, report your build issue.

Building without "--disable-asm" works without any issues.

@jukivili Thanks for the reply! We've reverted that commit downstream in Gentoo as a temporary workaround, as due to some complications, our release systems needed to build without asm (for now) to ensure portability. Rest assured, this is not the default, and is discouraged for regular users.

I'll attach my build.log from a Gentoo Linux system which shows the failure. I did mock up a draft patch to guard two defines (one in keccak.c, the other in rndjent.c) but I wasn't confident enough to submit in case I misunderstood your intentions.

Unfortunately, building without "--disable-asm" does not work if building a universal package under MacPorts (e.g. 32bit and 64bit x86 or 64bit x86 and arm64).


Looks like this has been addressed in af23ab5c5482d625ff52e60606cf044e2b0106c8. A quick test building the current version in master with --disable-asm worked for me.

bevan claimed this task.

Fixed in libgcrypt 1.9.2. Thanks!