Undefined symbol for ___get_cpuid_count when building on macOS Sierra
NOTE: I saw #812 (closed) but the compilation log/trace didn't seem the same as the issue that I'm having, so documenting this separately just in case.
Description of problem:
Building gnutls
3.6.9 fails on macOS Sierra with error:
Undefined symbols for architecture x86_64:
"___get_cpuid_count", referenced from:
_register_x86_crypto in libaccelerated.a(x86-common.o)
Version of gnutls used:
3.6.9
Distributor of gnutls (e.g., Ubuntu, Fedora, RHEL)
From source tarball, testing in CI for updating the Homebrew package manager with gnutls
3.6.9. Associated change on the Homebrew side: https://github.com/Homebrew/homebrew-core/pull/42779
How reproducible:
Steps to Reproduce:
- Download and unpack 3.6.9 tarball (https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/gnutls-3.6.9.tar.xz)
./configure --disable-dependency-tracking --disable-silent-rules --disable-static --prefix=#{prefix} --sysconfdir=#{etc} --with-default-trust-store-file=#{etc}/openssl/cert.pem --disable-guile --disable-heartbeat-support --with-p11-kit
make install
Actual results:
Undefined symbols for architecture x86_64:
"___get_cpuid_count", referenced from:
_register_x86_crypto in libaccelerated.a(x86-common.o)
Expected results:
Successful compilation.
Based on my limited understanding from googling this particular error, it seems that the symbol in question was added into clang
starting in llvm
5.0.0. macOS Sierra ships with a toolchain derived from llvm
4.0.0, so the symbol is not available.
I have attempted to use gcc
to build it instead, but gcc
does not seem to like some of the macOS Security framework that gnutls
links against:
In file included from /System/Library/Frameworks/Security.framework/Headers/AuthSession.h:32,
from /System/Library/Frameworks/Security.framework/Headers/Security.h:43,
from system/certs.c:49:
/System/Library/Frameworks/Security.framework/Headers/Authorization.h:192:7: error: variably modified 'bytes' at file scope
192 | char bytes[kAuthorizationExternalFormLength];
| ^~~~~