Skip to content

Commit

Permalink
Makefile.am: add libcperciva_cpusupport_detect.la
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gperciva committed Jan 31, 2025
1 parent 1c684dc commit 714bd16
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -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 \
Expand All @@ -110,6 +101,9 @@ scrypt_LDADD= \
libcperciva_crypto_aes.la \
libcperciva_arm_sha256.la \
libcperciva_arm_aes.la \
\
libcperciva_cpusupport_detect.la \
\
${LDADD_POSIX}
scrypt_man_MANS= scrypt.1

Expand Down Expand Up @@ -164,6 +158,18 @@ libcperciva_crypto_aes_la_SOURCES= libcperciva/crypto/crypto_aes.c
nodist_libcperciva_crypto_aes_la_SOURCES= cpusupport-config.h
libcperciva_crypto_aes_la_CFLAGS=`. ./apisupport-config.h; echo $${CFLAGS_LIBCRYPTO_LOW_LEVEL_AES}`

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= \
Expand Down Expand Up @@ -273,10 +279,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.
Expand Down

0 comments on commit 714bd16

Please sign in to comment.