aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Richardson <arichardson@FreeBSD.org>2020-09-18 11:22:34 +0000
committerAlex Richardson <arichardson@FreeBSD.org>2020-09-18 11:22:34 +0000
commit72f97a2d0934a0c72b9c485656f6d1456098b8ef (patch)
tree3c5436d331d1108bba3f30d99d4290585dfa9807
parent16694347a9214b23a550578b7a73e78c0f68e36d (diff)
downloadsrc-72f97a2d0934a0c72b9c485656f6d1456098b8ef.tar.gz
src-72f97a2d0934a0c72b9c485656f6d1456098b8ef.zip
libarchive: fix mismatch between library and test configuration
I was investigating libarchive test failures on CheriBSD and it turns out we get a reproducible SIGBUS for test_archive_m5, etc. Debugging this shows that libarchive and the tests disagree when it comes to the definition of archive_md5_ctx: libarchive assumes it's the OpenSSL type whereas the test use the libmd type. The latter is not necessarily aligned enough to store a pointer (16 bytes for CHERI RISC-V), so we were crashing when storing EVP_MD_CTX* to an 8-byte-aligned archive_md5_ctx. To avoid problems like this in the future, factor out the common compiler flags into a Makefile.inc and include that from the tests Makefile. Reviewed By: lwhsu Differential Revision: https://reviews.freebsd.org/D26469
Notes
Notes: svn path=/head/; revision=365876
-rw-r--r--lib/libarchive/Makefile18
-rw-r--r--lib/libarchive/Makefile.inc21
-rw-r--r--lib/libarchive/tests/Makefile7
3 files changed, 24 insertions, 22 deletions
diff --git a/lib/libarchive/Makefile b/lib/libarchive/Makefile
index e297cd8e6ebe..9206bd5bdd76 100644
--- a/lib/libarchive/Makefile
+++ b/lib/libarchive/Makefile
@@ -6,29 +6,13 @@ _LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive
LIB= archive
-LIBADD= z bz2 lzma bsdxml zstd
-CFLAGS+= -DHAVE_BZLIB_H=1 -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1 -DHAVE_ZSTD_H=1 -DHAVE_LIBZSTD=1
-
# FreeBSD SHLIB_MAJOR value is managed as part of the FreeBSD system.
# It has no real relation to the libarchive version number.
SHLIB_MAJOR= 7
-CFLAGS+= -DPLATFORM_CONFIG_H=\"${.CURDIR}/config_freebsd.h\"
CFLAGS+= -I${.OBJDIR}
CFLAGS+= -I${SRCTOP}/sys/contrib/zstd/lib
-
-.if ${MK_OPENSSL} != "no"
-CFLAGS+= -DWITH_OPENSSL
-LIBADD+= crypto
-.else
-LIBADD+= md
-.endif
-
-.if ${MK_ICONV} != "no"
-# TODO: This can be changed back to CFLAGS once iconv works correctly
-# with statically linked binaries.
-SHARED_CFLAGS+= -DHAVE_ICONV=1 -DHAVE_ICONV_H=1 -DICONV_CONST=
-.endif
+.include "Makefile.inc"
.if ${MACHINE_ARCH:Marm*} != "" || ${MACHINE_ARCH:Mmips*} != "" || \
${MACHINE_ARCH:Mpowerpc*} != ""
diff --git a/lib/libarchive/Makefile.inc b/lib/libarchive/Makefile.inc
new file mode 100644
index 000000000000..6e5017d6621a
--- /dev/null
+++ b/lib/libarchive/Makefile.inc
@@ -0,0 +1,21 @@
+# $FreeBSD$
+# These defines are needed for both libarchive and the tests. If we don't keep
+# them in sync we can get run-time crashes while running tests due to mismatches
+# between structures such as archive_md5_ctx, etc.
+
+LIBADD= z bz2 lzma bsdxml zstd
+CFLAGS+= -DHAVE_BZLIB_H=1 -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1 -DHAVE_ZSTD_H=1 -DHAVE_LIBZSTD=1
+CFLAGS+= -DPLATFORM_CONFIG_H=\"${.CURDIR}/config_freebsd.h\"
+
+.if ${MK_OPENSSL} != "no"
+CFLAGS+= -DWITH_OPENSSL
+LIBADD+= crypto
+.else
+LIBADD+= md
+.endif
+
+.if ${MK_ICONV} != "no"
+# TODO: This can be changed back to CFLAGS once iconv works correctly
+# with statically linked binaries.
+SHARED_CFLAGS+= -DHAVE_ICONV=1 -DHAVE_ICONV_H=1 -DICONV_CONST=
+.endif
diff --git a/lib/libarchive/tests/Makefile b/lib/libarchive/tests/Makefile
index 41e23a23f4ed..a4b1a58dae3b 100644
--- a/lib/libarchive/tests/Makefile
+++ b/lib/libarchive/tests/Makefile
@@ -1,4 +1,5 @@
# $FreeBSD$
+.include <src.opts.mk>
PACKAGE= tests
@@ -15,7 +16,7 @@ PROGS+= libarchive_test
CFLAGS+= -I${.CURDIR} -I${.CURDIR:H} -I${.OBJDIR}
CFLAGS+= -I${_LIBARCHIVEDIR}/libarchive -I${_LIBARCHIVEDIR}/libarchive/test
CFLAGS+= -I${_LIBARCHIVEDIR}/test_utils
-CFLAGS+= -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1
+.include "../Makefile.inc"
# Uncomment to link against dmalloc
#LDADD+= -L/usr/local/lib -ldmalloc
@@ -298,10 +299,6 @@ TESTS_SRCS= \
test_zip_filename_encoding.c
# Deterministic failures:
-# Crashes with SIGBUS
-BROKEN_TESTS+= test_archive_rmd160
-# Fails with `libarchive/test/test_archive_crypto.c:121: md != actualmd`
-BROKEN_TESTS+= test_archive_sha384
# Fails with `test_read_disk_directory_traversals.c:1094: File at has atime 886622, 1443306049 seconds ago`
BROKEN_TESTS+= test_read_disk_directory_traversals