svn commit: r304320 - head/secure/lib/libcrypto
Jung-uk Kim
jkim at FreeBSD.org
Wed Aug 17 22:13:41 UTC 2016
Author: jkim
Date: Wed Aug 17 22:13:39 2016
New Revision: 304320
URL: https://svnweb.freebsd.org/changeset/base/304320
Log:
Disable assembly sources when compiler/assembler cannot compile certain
instructions. For example, GCC 4.2.1 + binutils 2.17.50 does not support
AVX instructions.
Reported by: bde
MFC after: 2 weeks
Added:
head/secure/lib/libcrypto/opensslconf-aarch64.h.in
- copied, changed from r304319, head/secure/lib/libcrypto/opensslconf-aarch64.h
head/secure/lib/libcrypto/opensslconf-arm.h.in
- copied, changed from r304319, head/secure/lib/libcrypto/opensslconf-arm.h
head/secure/lib/libcrypto/opensslconf-mips.h.in
- copied, changed from r304319, head/secure/lib/libcrypto/opensslconf-mips.h
head/secure/lib/libcrypto/opensslconf-powerpc.h.in
- copied, changed from r304319, head/secure/lib/libcrypto/opensslconf-powerpc.h
head/secure/lib/libcrypto/opensslconf-riscv.h.in
- copied, changed from r304319, head/secure/lib/libcrypto/opensslconf-riscv.h
head/secure/lib/libcrypto/opensslconf-sparc64.h.in
- copied, changed from r304319, head/secure/lib/libcrypto/opensslconf-sparc64.h
head/secure/lib/libcrypto/opensslconf-x86.h.in
- copied, changed from r304319, head/secure/lib/libcrypto/opensslconf-x86.h
Deleted:
head/secure/lib/libcrypto/opensslconf-aarch64.h
head/secure/lib/libcrypto/opensslconf-arm.h
head/secure/lib/libcrypto/opensslconf-mips.h
head/secure/lib/libcrypto/opensslconf-powerpc.h
head/secure/lib/libcrypto/opensslconf-riscv.h
head/secure/lib/libcrypto/opensslconf-sparc64.h
head/secure/lib/libcrypto/opensslconf-x86.h
Modified:
head/secure/lib/libcrypto/Makefile
head/secure/lib/libcrypto/Makefile.asm
head/secure/lib/libcrypto/Makefile.inc
Modified: head/secure/lib/libcrypto/Makefile
==============================================================================
--- head/secure/lib/libcrypto/Makefile Wed Aug 17 21:57:11 2016 (r304319)
+++ head/secure/lib/libcrypto/Makefile Wed Aug 17 22:13:39 2016 (r304320)
@@ -22,9 +22,9 @@ MAN+= config.5 des_modes.7
# base sources
SRCS= cpt_err.c cryptlib.c cversion.c ex_data.c mem.c mem_dbg.c o_dir.c \
o_fips.c o_init.c o_str.c o_time.c uid.c
-.if ${MACHINE_CPUARCH} == "amd64"
+.if defined(ASM_amd64)
SRCS+= x86_64cpuid.S
-.elif ${MACHINE_CPUARCH} == "i386"
+.elif defined(ASM_i386)
SRCS+= x86cpuid.S
.else
SRCS+= mem_clr.c
@@ -33,10 +33,10 @@ INCS+= crypto.h ebcdic.h opensslv.h ossl
# aes
SRCS+= aes_cfb.c aes_ctr.c aes_ecb.c aes_ige.c aes_misc.c aes_ofb.c aes_wrap.c
-.if ${MACHINE_CPUARCH} == "amd64"
+.if defined(ASM_amd64)
SRCS+= aes-x86_64.S aesni-mb-x86_64.S aesni-sha1-x86_64.S \
aesni-sha256-x86_64.S aesni-x86_64.S bsaes-x86_64.S vpaes-x86_64.S
-.elif ${MACHINE_CPUARCH} == "i386"
+.elif defined(ASM_i386)
SRCS+= aes-586.S aesni-x86.S vpaes-x86.S
.else
SRCS+= aes_cbc.c aes_core.c
@@ -60,7 +60,7 @@ INCS+= asn1.h asn1_mac.h asn1t.h
# bf
SRCS+= bf_cfb64.c bf_ecb.c bf_ofb64.c bf_skey.c
-.if ${MACHINE_CPUARCH} == "i386"
+.if defined(ASM_i386)
.if ${MACHINE_CPU:Mi686}
SRCS+= bf-686.S
.else
@@ -82,10 +82,10 @@ SRCS+= bn_add.c bn_blind.c bn_const.c bn
bn_exp.c bn_exp2.c bn_gcd.c bn_gf2m.c bn_kron.c bn_lib.c bn_mod.c \
bn_mont.c bn_mpi.c bn_mul.c bn_nist.c bn_prime.c bn_print.c bn_rand.c \
bn_recp.c bn_shift.c bn_sqr.c bn_sqrt.c bn_word.c bn_x931p.c
-.if ${MACHINE_CPUARCH} == "amd64"
+.if defined(ASM_amd64)
SRCS+= rsaz-avx2.S rsaz-x86_64.S rsaz_exp.c x86_64-gcc.c x86_64-gf2m.S \
x86_64-mont.S x86_64-mont5.S
-.elif ${MACHINE_CPUARCH} == "i386"
+.elif defined(ASM_i386)
SRCS+= bn-586.S co-586.S x86-gf2m.S x86-mont.S
.else
SRCS+= bn_asm.c
@@ -98,9 +98,9 @@ INCS+= buffer.h
# camellia
SRCS+= cmll_cfb.c cmll_ctr.c cmll_ecb.c cmll_ofb.c cmll_utl.c
-.if ${MACHINE_CPUARCH} == "amd64"
+.if defined(ASM_amd64)
SRCS+= cmll_misc.c cmll-x86_64.S
-.elif ${MACHINE_CPUARCH} == "i386"
+.elif defined(ASM_i386)
SRCS+= cmll-x86.S
.else
SRCS+= camellia.c cmll_cbc.c cmll_misc.c
@@ -135,7 +135,7 @@ SRCS+= cbc_cksm.c cbc_enc.c cfb64ede.c c
des_old2.c ecb3_enc.c ecb_enc.c ede_cbcm_enc.c enc_read.c enc_writ.c \
fcrypt.c ofb64ede.c ofb64enc.c ofb_enc.c pcbc_enc.c qud_cksm.c \
rand_key.c read2pwd.c rpc_enc.c set_key.c str2key.c xcbc_enc.c
-.if ${MACHINE_CPUARCH} == "i386"
+.if defined(ASM_i386)
SRCS+= crypt586.S des-586.S
.else
SRCS+= des_enc.c fcrypt_b.c
@@ -161,7 +161,7 @@ SRCS+= ec2_mult.c ec2_oct.c ec2_smpl.c e
ec_curve.c ec_cvt.c ec_err.c ec_key.c ec_lib.c ec_mult.c ec_oct.c \
ec_pmeth.c ec_print.c eck_prn.c ecp_mont.c ecp_nist.c ecp_oct.c \
ecp_smpl.c
-.if ${MACHINE_CPUARCH} == "amd64"
+.if defined(ASM_amd64)
SRCS+= ecp_nistz256.c ecp_nistz256-x86_64.S
.endif
INCS+= ec.h
@@ -218,9 +218,9 @@ INCS+= md4.h
# md5
SRCS+= md5_dgst.c md5_one.c
-.if ${MACHINE_CPUARCH} == "amd64"
+.if defined(ASM_amd64)
SRCS+= md5-x86_64.S
-.elif ${MACHINE_CPUARCH} == "i386"
+.elif defined(ASM_i386)
SRCS+= md5-586.S
.endif
INCS+= md5.h
@@ -232,9 +232,9 @@ INCS+= mdc2.h
# modes
SRCS+= cbc128.c ccm128.c cfb128.c ctr128.c cts128.c gcm128.c ofb128.c \
wrap128.c xts128.c
-.if ${MACHINE_CPUARCH} == "amd64"
+.if defined(ASM_amd64)
SRCS+= aesni-gcm-x86_64.S ghash-x86_64.S
-.elif ${MACHINE_CPUARCH} == "i386"
+.elif defined(ASM_i386)
SRCS+= ghash-x86.S
.endif
INCS+= modes.h
@@ -278,9 +278,9 @@ INCS+= rc2.h
# rc4
SRCS+= rc4_utl.c
-.if ${MACHINE_CPUARCH} == "amd64"
+.if defined(ASM_amd64)
SRCS+= rc4-md5-x86_64.S rc4-x86_64.S
-.elif ${MACHINE_CPUARCH} == "i386"
+.elif defined(ASM_i386)
SRCS+= rc4-586.S
.else
SRCS+= rc4_enc.c rc4_skey.c
@@ -289,7 +289,7 @@ INCS+= rc4.h
# rc5
SRCS+= rc5_ecb.c rc5_skey.c rc5cfb64.c rc5ofb64.c
-.if ${MACHINE_CPUARCH} == "i386"
+.if defined(ASM_i386)
SRCS+= rc5-586.S
.else
SRCS+= rc5_enc.c
@@ -298,7 +298,7 @@ INCS+= rc5.h
# ripemd
SRCS+= rmd_dgst.c rmd_one.c
-.if ${MACHINE_CPUARCH} == "i386"
+.if defined(ASM_i386)
SRCS+= rmd-586.S
.endif
INCS+= ripemd.h
@@ -316,10 +316,10 @@ INCS+= seed.h
# sha
SRCS+= sha1_one.c sha1dgst.c sha256.c sha512.c sha_dgst.c sha_one.c
-.if ${MACHINE_CPUARCH} == "amd64"
+.if defined(ASM_amd64)
SRCS+= sha1-mb-x86_64.S sha1-x86_64.S sha256-mb-x86_64.S sha256-x86_64.S \
sha512-x86_64.S
-.elif ${MACHINE_CPUARCH} == "i386"
+.elif defined(ASM_i386)
SRCS+= sha1-586.S sha256-586.S sha512-586.S
.endif
INCS+= sha.h
@@ -348,9 +348,9 @@ INCS+= ui.h ui_compat.h
# whrlpool
SRCS+= wp_dgst.c
-.if ${MACHINE_CPUARCH} == "amd64"
+.if defined(ASM_amd64)
SRCS+= wp-x86_64.S
-.elif ${MACHINE_CPUARCH} == "i386"
+.elif defined(ASM_i386)
SRCS+= wp-mmx.S wp_block.c
.else
SRCS+= wp_block.c
@@ -389,13 +389,7 @@ CFLAGS+= -I${LCRYPTO_SRC}/crypto/modes
ACFLAGS+= -Wa,--noexecstack
.endif
-.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
-OPENSSLCONF_H= opensslconf-x86.h
-.else
-OPENSSLCONF_H= opensslconf-${MACHINE_CPUARCH}.h
-.endif
-
-CLEANFILES= buildinf.h opensslconf.h
+CLEANFILES= buildinf.h opensslconf.h opensslconf.h.tmp
buildinf.h: Makefile
( echo "#ifndef MK1MF_BUILD"; \
@@ -404,17 +398,21 @@ buildinf.h: Makefile
echo " #define PLATFORM \"platform: FreeBSD-${MACHINE_ARCH}\""; \
echo "#endif" ) > ${.TARGET}
-opensslconf.h: ${OPENSSLCONF_H}
- ${CP} ${.ALLSRC} ${.TARGET}
+opensslconf.h: opensslconf-${MACHINE_CPUARCH:C/^(amd64|i386)$/x86/}.h.in
+.if defined(ASM_${MACHINE_CPUARCH})
+ sed 's/%%ASM%%//; /%%NO_ASM%%/d' ${.ALLSRC} > ${.TARGET}.tmp
+.else
+ sed '/%%ASM%%/d; s/%%NO_ASM%%//' ${.ALLSRC} > ${.TARGET}.tmp
+.endif
+ ${CP} ${.TARGET}.tmp ${.TARGET}
.include <bsd.lib.mk>
-.if ${MACHINE_CPUARCH} == "amd64"
-_bn_asmpath= ${LCRYPTO_SRC}/crypto/bn/asm
-.endif
-
-.if exists(${.CURDIR}/${MACHINE_CPUARCH})
+.if defined(ASM_${MACHINE_CPUARCH})
.PATH: ${.CURDIR}/${MACHINE_CPUARCH}
+.if defined(ASM_amd64)
+.PATH: ${LCRYPTO_SRC}/crypto/bn/asm
+.endif
.endif
.PATH: ${LCRYPTO_SRC}/crypto \
@@ -423,7 +421,6 @@ _bn_asmpath= ${LCRYPTO_SRC}/crypto/bn/as
${LCRYPTO_SRC}/crypto/bf \
${LCRYPTO_SRC}/crypto/bio \
${LCRYPTO_SRC}/crypto/bn \
- ${_bn_asmpath} \
${LCRYPTO_SRC}/crypto/buffer \
${LCRYPTO_SRC}/crypto/camellia \
${LCRYPTO_SRC}/crypto/cast \
Modified: head/secure/lib/libcrypto/Makefile.asm
==============================================================================
--- head/secure/lib/libcrypto/Makefile.asm Wed Aug 17 21:57:11 2016 (r304319)
+++ head/secure/lib/libcrypto/Makefile.asm Wed Aug 17 22:13:39 2016 (r304320)
@@ -6,7 +6,7 @@
.include "Makefile.inc"
-.if ${MACHINE_CPUARCH} == "amd64"
+.if defined(ASM_amd64)
.PATH: ${LCRYPTO_SRC}/crypto \
${LCRYPTO_SRC}/crypto/aes/asm \
@@ -78,7 +78,7 @@ ${s}.S: ${s}.s
cat ${s}.s ) > ${.TARGET}
.endfor
-.elif ${MACHINE_CPUARCH} == "i386"
+.elif defined(ASM_i386)
.PATH: ${LCRYPTO_SRC}/crypto \
${LCRYPTO_SRC}/crypto/aes/asm \
Modified: head/secure/lib/libcrypto/Makefile.inc
==============================================================================
--- head/secure/lib/libcrypto/Makefile.inc Wed Aug 17 21:57:11 2016 (r304319)
+++ head/secure/lib/libcrypto/Makefile.inc Wed Aug 17 22:13:39 2016 (r304320)
@@ -21,7 +21,17 @@ CFLAGS+=-DL_ENDIAN
CFLAGS+=-DB_ENDIAN
.endif
-.if ${MACHINE_CPUARCH} == "amd64"
+.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
+_ASM_AVX!= { \
+ echo vzeroall | \
+ ${CC} -x assembler -o /dev/null -c - 2> /dev/null; \
+ } && echo yes || echo no
+.if ${_ASM_AVX} == yes
+ASM_${MACHINE_CPUARCH}=
+.endif
+.endif
+
+.if defined(ASM_amd64)
CFLAGS+=-DOPENSSL_IA32_SSE2
CFLAGS+=-DAES_ASM -DBSAES_ASM -DVPAES_ASM
CFLAGS+=-DECP_NISTZ256_ASM
@@ -30,7 +40,7 @@ CFLAGS+=-DMD5_ASM
CFLAGS+=-DGHASH_ASM
CFLAGS+=-DSHA1_ASM -DSHA256_ASM -DSHA512_ASM
CFLAGS+=-DWHIRLPOOL_ASM
-.elif ${MACHINE_CPUARCH} == "i386"
+.elif defined(ASM_i386)
CFLAGS+=-DOPENSSL_IA32_SSE2
CFLAGS+=-DAES_ASM -DVPAES_ASM
CFLAGS+=-DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m
Copied and modified: head/secure/lib/libcrypto/opensslconf-aarch64.h.in (from r304319, head/secure/lib/libcrypto/opensslconf-aarch64.h)
==============================================================================
--- head/secure/lib/libcrypto/opensslconf-aarch64.h Wed Aug 17 21:57:11 2016 (r304319, copy source)
+++ head/secure/lib/libcrypto/opensslconf-aarch64.h.in Wed Aug 17 22:13:39 2016 (r304320)
@@ -51,9 +51,9 @@ extern "C" {
#ifndef OPENSSL_THREADS
# define OPENSSL_THREADS
#endif
-#ifndef OPENSSL_NO_ASM
-# define OPENSSL_NO_ASM
-#endif
+%%NO_ASM%%#ifndef OPENSSL_NO_ASM
+%%NO_ASM%%# define OPENSSL_NO_ASM
+%%NO_ASM%%#endif
#ifndef OPENSSL_NO_STATIC_ENGINE
# define OPENSSL_NO_STATIC_ENGINE
#endif
@@ -101,6 +101,8 @@ extern "C" {
# endif
#endif
+%%ASM%%#define OPENSSL_CPUID_OBJ
+%%ASM%%
/* crypto/opensslconf.h.in */
/* Generate 80386 code? */
Copied and modified: head/secure/lib/libcrypto/opensslconf-arm.h.in (from r304319, head/secure/lib/libcrypto/opensslconf-arm.h)
==============================================================================
--- head/secure/lib/libcrypto/opensslconf-arm.h Wed Aug 17 21:57:11 2016 (r304319, copy source)
+++ head/secure/lib/libcrypto/opensslconf-arm.h.in Wed Aug 17 22:13:39 2016 (r304320)
@@ -51,9 +51,9 @@ extern "C" {
#ifndef OPENSSL_THREADS
# define OPENSSL_THREADS
#endif
-#ifndef OPENSSL_NO_ASM
-# define OPENSSL_NO_ASM
-#endif
+%%NO_ASM%%#ifndef OPENSSL_NO_ASM
+%%NO_ASM%%# define OPENSSL_NO_ASM
+%%NO_ASM%%#endif
#ifndef OPENSSL_NO_STATIC_ENGINE
# define OPENSSL_NO_STATIC_ENGINE
#endif
@@ -101,6 +101,8 @@ extern "C" {
# endif
#endif
+%%ASM%%#define OPENSSL_CPUID_OBJ
+%%ASM%%
/* crypto/opensslconf.h.in */
/* Generate 80386 code? */
Copied and modified: head/secure/lib/libcrypto/opensslconf-mips.h.in (from r304319, head/secure/lib/libcrypto/opensslconf-mips.h)
==============================================================================
--- head/secure/lib/libcrypto/opensslconf-mips.h Wed Aug 17 21:57:11 2016 (r304319, copy source)
+++ head/secure/lib/libcrypto/opensslconf-mips.h.in Wed Aug 17 22:13:39 2016 (r304320)
@@ -51,9 +51,9 @@ extern "C" {
#ifndef OPENSSL_THREADS
# define OPENSSL_THREADS
#endif
-#ifndef OPENSSL_NO_ASM
-# define OPENSSL_NO_ASM
-#endif
+%%NO_ASM%%#ifndef OPENSSL_NO_ASM
+%%NO_ASM%%# define OPENSSL_NO_ASM
+%%NO_ASM%%#endif
#ifndef OPENSSL_NO_STATIC_ENGINE
# define OPENSSL_NO_STATIC_ENGINE
#endif
Copied and modified: head/secure/lib/libcrypto/opensslconf-powerpc.h.in (from r304319, head/secure/lib/libcrypto/opensslconf-powerpc.h)
==============================================================================
--- head/secure/lib/libcrypto/opensslconf-powerpc.h Wed Aug 17 21:57:11 2016 (r304319, copy source)
+++ head/secure/lib/libcrypto/opensslconf-powerpc.h.in Wed Aug 17 22:13:39 2016 (r304320)
@@ -51,9 +51,9 @@ extern "C" {
#ifndef OPENSSL_THREADS
# define OPENSSL_THREADS
#endif
-#ifndef OPENSSL_NO_ASM
-# define OPENSSL_NO_ASM
-#endif
+%%NO_ASM%%#ifndef OPENSSL_NO_ASM
+%%NO_ASM%%# define OPENSSL_NO_ASM
+%%NO_ASM%%#endif
#ifndef OPENSSL_NO_STATIC_ENGINE
# define OPENSSL_NO_STATIC_ENGINE
#endif
@@ -101,6 +101,8 @@ extern "C" {
# endif
#endif
+%%ASM%%#define OPENSSL_CPUID_OBJ
+%%ASM%%
/* crypto/opensslconf.h.in */
/* Generate 80386 code? */
Copied and modified: head/secure/lib/libcrypto/opensslconf-riscv.h.in (from r304319, head/secure/lib/libcrypto/opensslconf-riscv.h)
==============================================================================
--- head/secure/lib/libcrypto/opensslconf-riscv.h Wed Aug 17 21:57:11 2016 (r304319, copy source)
+++ head/secure/lib/libcrypto/opensslconf-riscv.h.in Wed Aug 17 22:13:39 2016 (r304320)
@@ -51,9 +51,9 @@ extern "C" {
#ifndef OPENSSL_THREADS
# define OPENSSL_THREADS
#endif
-#ifndef OPENSSL_NO_ASM
-# define OPENSSL_NO_ASM
-#endif
+%%NO_ASM%%#ifndef OPENSSL_NO_ASM
+%%NO_ASM%%# define OPENSSL_NO_ASM
+%%NO_ASM%%#endif
#ifndef OPENSSL_NO_STATIC_ENGINE
# define OPENSSL_NO_STATIC_ENGINE
#endif
Copied and modified: head/secure/lib/libcrypto/opensslconf-sparc64.h.in (from r304319, head/secure/lib/libcrypto/opensslconf-sparc64.h)
==============================================================================
--- head/secure/lib/libcrypto/opensslconf-sparc64.h Wed Aug 17 21:57:11 2016 (r304319, copy source)
+++ head/secure/lib/libcrypto/opensslconf-sparc64.h.in Wed Aug 17 22:13:39 2016 (r304320)
@@ -51,9 +51,9 @@ extern "C" {
#ifndef OPENSSL_THREADS
# define OPENSSL_THREADS
#endif
-#ifndef OPENSSL_NO_ASM
-# define OPENSSL_NO_ASM
-#endif
+%%NO_ASM%%#ifndef OPENSSL_NO_ASM
+%%NO_ASM%%# define OPENSSL_NO_ASM
+%%NO_ASM%%#endif
#ifndef OPENSSL_NO_STATIC_ENGINE
# define OPENSSL_NO_STATIC_ENGINE
#endif
@@ -101,6 +101,8 @@ extern "C" {
# endif
#endif
+%%ASM%%#define OPENSSL_CPUID_OBJ
+%%ASM%%
/* crypto/opensslconf.h.in */
/* Generate 80386 code? */
Copied and modified: head/secure/lib/libcrypto/opensslconf-x86.h.in (from r304319, head/secure/lib/libcrypto/opensslconf-x86.h)
==============================================================================
--- head/secure/lib/libcrypto/opensslconf-x86.h Wed Aug 17 21:57:11 2016 (r304319, copy source)
+++ head/secure/lib/libcrypto/opensslconf-x86.h.in Wed Aug 17 22:13:39 2016 (r304320)
@@ -51,6 +51,9 @@ extern "C" {
#ifndef OPENSSL_THREADS
# define OPENSSL_THREADS
#endif
+%%NO_ASM%%#ifndef OPENSSL_NO_ASM
+%%NO_ASM%%# define OPENSSL_NO_ASM
+%%NO_ASM%%#endif
#ifndef OPENSSL_NO_STATIC_ENGINE
# define OPENSSL_NO_STATIC_ENGINE
#endif
@@ -98,8 +101,8 @@ extern "C" {
# endif
#endif
-#define OPENSSL_CPUID_OBJ
-
+%%ASM%%#define OPENSSL_CPUID_OBJ
+%%ASM%%
/* crypto/opensslconf.h.in */
/* Generate 80386 code? */
More information about the svn-src-head
mailing list