From 2a25aa6b62eddea5e0b201a616aa737c06ab0921 Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Fri, 31 Jan 2025 14:39:04 -0800 Subject: [PATCH] Makefile.am: add libcperciva_cpusupport_detect.la libcpusupport_crypto_aes.la needs to resolve symbols such as cpusupport_x86_aesni_detect_1. In scrypt, that was previously provided by cpusupport_x86_aesni.o, which was listed explicitly on the command-line (via Makefile.am's ${crypto_scrypt_files}). However, in the tarsnap repository, cpusupport_x86_aesni.o was linked into libtarsnap.a. When we tried to add libcperciva_crypto_aes.a, that created a circular dependency: - libtarsnap.a needed crypto_aes symbols (which were in libcperciva_crypto_aes) - libcperciva_crypto_aes needed cpusupport_x86_aesni_detect_1 (which were in libtarsnap.a) To avoid the circular dependency, we're moving the cpusupport detection functionality into its own library. --- Makefile.am | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Makefile.am b/Makefile.am index fc5d498f..e867b8e8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,9 +10,6 @@ ACLOCAL_AMFLAGS= -I m4 # lib/crypto/crypto_scrypt_smix_sse2.c # which require special compiler flags and are thus compiled as separate # libraries. See test_scrypt for an example. -# -# crypto_scrypt() does not require aesni or rdrand, but we need to include -# the relevant cpusupport_x86 files so that cpusupport can link to them. crypto_scrypt_files= \ lib/crypto/crypto_scrypt_smix.c \ lib/crypto/crypto_scrypt_smix.h \ @@ -26,13 +23,6 @@ crypto_scrypt_files= \ libcperciva/alg/sha256_shani.h \ libcperciva/alg/sha256_sse2.h \ libcperciva/cpusupport/cpusupport.h \ - libcperciva/cpusupport/cpusupport_arm_aes.c \ - libcperciva/cpusupport/cpusupport_arm_sha256.c \ - libcperciva/cpusupport/cpusupport_x86_aesni.c \ - libcperciva/cpusupport/cpusupport_x86_rdrand.c \ - libcperciva/cpusupport/cpusupport_x86_shani.c \ - libcperciva/cpusupport/cpusupport_x86_sse2.c \ - libcperciva/cpusupport/cpusupport_x86_ssse3.c \ libcperciva/util/insecure_memzero.c \ libcperciva/util/insecure_memzero.h \ libcperciva/util/warnp.c \ @@ -101,6 +91,7 @@ AM_CPPFLAGS= \ -D_XOPEN_SOURCE=700 \ ${CFLAGS_POSIX} +# Each "paragraph" denotes a different set of dependencies. scrypt_LDADD= \ libcperciva_aesni.la \ libcperciva_rdrand.la \ @@ -110,6 +101,9 @@ scrypt_LDADD= \ libscrypt_crypto_aes.la \ libcperciva_arm_sha256.la \ libcperciva_arm_aes.la \ + \ + libcperciva_cpusupport_detect.la \ + \ ${LDADD_POSIX} scrypt_man_MANS= scrypt.1 @@ -159,6 +153,18 @@ libcperciva_arm_sha256_la_SOURCES= libcperciva/alg/sha256_arm.c nodist_libcperciva_arm_sha256_la_SOURCES= cpusupport-config.h libcperciva_arm_sha256_la_CFLAGS=`. ./cpusupport-config.h; echo $${CFLAGS_ARM_SHA256}` +noinst_LTLIBRARIES+= libcperciva_cpusupport_detect.la +libcperciva_cpusupport_detect_la_SOURCES= \ + libcperciva/cpusupport/cpusupport_arm_aes.c \ + libcperciva/cpusupport/cpusupport_arm_sha256.c \ + libcperciva/cpusupport/cpusupport_x86_aesni.c \ + libcperciva/cpusupport/cpusupport_x86_rdrand.c \ + libcperciva/cpusupport/cpusupport_x86_shani.c \ + libcperciva/cpusupport/cpusupport_x86_sse2.c \ + libcperciva/cpusupport/cpusupport_x86_ssse3.c +nodist_libcperciva_cpusupport_detect_la_SOURCES= cpusupport-config.h + + # Library from libcperciva and scrypt code. noinst_LTLIBRARIES+= libscrypt_sse2.la libscrypt_sse2_la_SOURCES= \ @@ -274,10 +280,14 @@ tests_verify_strings_test_scrypt_SOURCES= \ tests/verify-strings/test_scrypt.c \ $(crypto_scrypt_files) +# Each "paragraph" denotes a different set of dependencies. tests_verify_strings_test_scrypt_LDADD= \ libcperciva_shani.la \ libscrypt_sse2.la \ libcperciva_arm_sha256.la \ + \ + libcperciva_cpusupport_detect.la \ + \ ${LDADD_POSIX} # Eliminate false positives while memory-checking for the test framework.