Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Jan 2017 23:29:30 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r312851 - stable/10/secure/lib/libcrypto
Message-ID:  <201701262329.v0QNTUR9062799@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Thu Jan 26 23:29:30 2017
New Revision: 312851
URL: https://svnweb.freebsd.org/changeset/base/312851

Log:
  Disable assembly sources when compiler/assembler cannot compile certain
  instructions.
  
  Note this is a direct commit because head and stable/11 has OpenSSL 1.0.2
  branch.  However, it is based on r304320.
  
  Requested by:	julian

Added:
  stable/10/secure/lib/libcrypto/opensslconf-arm.h.in
     - copied, changed from r312850, stable/10/secure/lib/libcrypto/opensslconf-arm.h
  stable/10/secure/lib/libcrypto/opensslconf-ia64.h.in
     - copied, changed from r312850, stable/10/secure/lib/libcrypto/opensslconf-ia64.h
  stable/10/secure/lib/libcrypto/opensslconf-mips.h.in
     - copied, changed from r312850, stable/10/secure/lib/libcrypto/opensslconf-mips.h
  stable/10/secure/lib/libcrypto/opensslconf-powerpc.h.in
     - copied, changed from r312850, stable/10/secure/lib/libcrypto/opensslconf-powerpc.h
  stable/10/secure/lib/libcrypto/opensslconf-sparc64.h.in
     - copied, changed from r312850, stable/10/secure/lib/libcrypto/opensslconf-sparc64.h
  stable/10/secure/lib/libcrypto/opensslconf-x86.h.in
     - copied, changed from r312850, stable/10/secure/lib/libcrypto/opensslconf-x86.h
Deleted:
  stable/10/secure/lib/libcrypto/opensslconf-arm.h
  stable/10/secure/lib/libcrypto/opensslconf-ia64.h
  stable/10/secure/lib/libcrypto/opensslconf-mips.h
  stable/10/secure/lib/libcrypto/opensslconf-powerpc.h
  stable/10/secure/lib/libcrypto/opensslconf-sparc64.h
  stable/10/secure/lib/libcrypto/opensslconf-x86.h
Modified:
  stable/10/secure/lib/libcrypto/Makefile
  stable/10/secure/lib/libcrypto/Makefile.asm
  stable/10/secure/lib/libcrypto/Makefile.inc

Modified: stable/10/secure/lib/libcrypto/Makefile
==============================================================================
--- stable/10/secure/lib/libcrypto/Makefile	Thu Jan 26 21:35:58 2017	(r312850)
+++ stable/10/secure/lib/libcrypto/Makefile	Thu Jan 26 23:29:30 2017	(r312851)
@@ -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-sha1-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+=	modexp512-x86_64.S 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
@@ -134,7 +134,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
@@ -215,9 +215,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
@@ -228,9 +228,9 @@ INCS+=	mdc2.h
 
 # modes
 SRCS+=	cbc128.c ccm128.c cfb128.c ctr128.c cts128.c gcm128.c ofb128.c xts128.c
-.if ${MACHINE_CPUARCH} == "amd64" 
+.if defined(ASM_amd64)
 SRCS+=	ghash-x86_64.S
-.elif ${MACHINE_CPUARCH} == "i386"
+.elif defined(ASM_i386)
 SRCS+=	ghash-x86.S
 .endif
 INCS+=	modes.h
@@ -274,9 +274,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
@@ -285,7 +285,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
@@ -294,7 +294,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
@@ -312,9 +312,9 @@ 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-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
@@ -343,9 +343,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
@@ -382,7 +382,7 @@ CFLAGS+=	-I${LCRYPTO_SRC}/crypto/modes
 ACFLAGS+=	-Wa,--noexecstack
 .endif
 
-CLEANFILES=	buildinf.h opensslconf.h
+CLEANFILES=	buildinf.h opensslconf.h opensslconf.h.tmp
 
 buildinf.h: ${.CURDIR}/Makefile
 	( echo "#ifndef MK1MF_BUILD"; \
@@ -391,23 +391,21 @@ buildinf.h: ${.CURDIR}/Makefile
 	echo "    #define PLATFORM \"platform: FreeBSD-${MACHINE_ARCH}\""; \
 	echo "#endif" ) > ${.TARGET}
 
-.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
-opensslconf.h: opensslconf-x86.h
+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
-opensslconf.h: opensslconf-${MACHINE_CPUARCH}.h
+	sed '/%%ASM%%/d; s/%%NO_ASM%%//' ${.ALLSRC} > ${.TARGET}.tmp
 .endif
-	cp -f ${.ALLSRC} ${.TARGET}
+	cp -f ${.TARGET}.tmp ${.TARGET}
 
 .include <bsd.lib.mk>
 
-.if ${MACHINE_CPUARCH} == "amd64"
-.PATH: ${.CURDIR}/amd64
-.elif ${MACHINE_CPUARCH} == "i386"
-.PATH: ${.CURDIR}/i386
+.if defined(ASM_${MACHINE_CPUARCH})
+.PATH:	${.CURDIR}/${MACHINE_CPUARCH}
+.if defined(ASM_amd64)
+.PATH:	${LCRYPTO_SRC}/crypto/bn/asm
 .endif
-
-.if ${MACHINE_CPUARCH} == "amd64"
-_bn_asmpath=	${LCRYPTO_SRC}/crypto/bn/asm
 .endif
 
 .PATH:	${LCRYPTO_SRC}/crypto \
@@ -416,7 +414,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: stable/10/secure/lib/libcrypto/Makefile.asm
==============================================================================
--- stable/10/secure/lib/libcrypto/Makefile.asm	Thu Jan 26 21:35:58 2017	(r312850)
+++ stable/10/secure/lib/libcrypto/Makefile.asm	Thu Jan 26 23:29:30 2017	(r312851)
@@ -6,7 +6,7 @@
 
 .include "Makefile.inc"
 
-.if ${MACHINE_CPUARCH} == "amd64"
+.if defined(ASM_amd64)
 
 .PATH:	${LCRYPTO_SRC}/crypto \
 	${LCRYPTO_SRC}/crypto/aes/asm \
@@ -73,7 +73,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: stable/10/secure/lib/libcrypto/Makefile.inc
==============================================================================
--- stable/10/secure/lib/libcrypto/Makefile.inc	Thu Jan 26 21:35:58 2017	(r312850)
+++ stable/10/secure/lib/libcrypto/Makefile.inc	Thu Jan 26 23:29:30 2017	(r312851)
@@ -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+=-DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m
@@ -29,7 +39,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: stable/10/secure/lib/libcrypto/opensslconf-arm.h.in (from r312850, stable/10/secure/lib/libcrypto/opensslconf-arm.h)
==============================================================================
--- stable/10/secure/lib/libcrypto/opensslconf-arm.h	Thu Jan 26 21:35:58 2017	(r312850, copy source)
+++ stable/10/secure/lib/libcrypto/opensslconf-arm.h.in	Thu Jan 26 23:29:30 2017	(r312851)
@@ -42,9 +42,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
@@ -83,6 +83,8 @@ extern "C" {
 # endif
 #endif
 
+%%ASM%%#define OPENSSL_CPUID_OBJ
+%%ASM%%
 /* crypto/opensslconf.h.in */
 
 /* Generate 80386 code? */

Copied and modified: stable/10/secure/lib/libcrypto/opensslconf-ia64.h.in (from r312850, stable/10/secure/lib/libcrypto/opensslconf-ia64.h)
==============================================================================
--- stable/10/secure/lib/libcrypto/opensslconf-ia64.h	Thu Jan 26 21:35:58 2017	(r312850, copy source)
+++ stable/10/secure/lib/libcrypto/opensslconf-ia64.h.in	Thu Jan 26 23:29:30 2017	(r312851)
@@ -36,9 +36,9 @@
 #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: stable/10/secure/lib/libcrypto/opensslconf-mips.h.in (from r312850, stable/10/secure/lib/libcrypto/opensslconf-mips.h)
==============================================================================
--- stable/10/secure/lib/libcrypto/opensslconf-mips.h	Thu Jan 26 21:35:58 2017	(r312850, copy source)
+++ stable/10/secure/lib/libcrypto/opensslconf-mips.h.in	Thu Jan 26 23:29:30 2017	(r312851)
@@ -42,9 +42,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: stable/10/secure/lib/libcrypto/opensslconf-powerpc.h.in (from r312850, stable/10/secure/lib/libcrypto/opensslconf-powerpc.h)
==============================================================================
--- stable/10/secure/lib/libcrypto/opensslconf-powerpc.h	Thu Jan 26 21:35:58 2017	(r312850, copy source)
+++ stable/10/secure/lib/libcrypto/opensslconf-powerpc.h.in	Thu Jan 26 23:29:30 2017	(r312851)
@@ -42,9 +42,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
@@ -83,6 +83,8 @@ extern "C" {
 # endif
 #endif
 
+%%ASM%%#define OPENSSL_CPUID_OBJ
+%%ASM%%
 /* crypto/opensslconf.h.in */
 
 /* Generate 80386 code? */

Copied and modified: stable/10/secure/lib/libcrypto/opensslconf-sparc64.h.in (from r312850, stable/10/secure/lib/libcrypto/opensslconf-sparc64.h)
==============================================================================
--- stable/10/secure/lib/libcrypto/opensslconf-sparc64.h	Thu Jan 26 21:35:58 2017	(r312850, copy source)
+++ stable/10/secure/lib/libcrypto/opensslconf-sparc64.h.in	Thu Jan 26 23:29:30 2017	(r312851)
@@ -42,9 +42,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
@@ -83,6 +83,8 @@ extern "C" {
 # endif
 #endif
 
+%%ASM%%#define OPENSSL_CPUID_OBJ
+%%ASM%%
 /* crypto/opensslconf.h.in */
 
 /* Generate 80386 code? */

Copied and modified: stable/10/secure/lib/libcrypto/opensslconf-x86.h.in (from r312850, stable/10/secure/lib/libcrypto/opensslconf-x86.h)
==============================================================================
--- stable/10/secure/lib/libcrypto/opensslconf-x86.h	Thu Jan 26 21:35:58 2017	(r312850, copy source)
+++ stable/10/secure/lib/libcrypto/opensslconf-x86.h.in	Thu Jan 26 23:29:30 2017	(r312851)
@@ -42,6 +42,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
@@ -80,8 +83,8 @@ extern "C" {
 # endif
 #endif
 
-#define OPENSSL_CPUID_OBJ
-
+%%ASM%%#define OPENSSL_CPUID_OBJ
+%%ASM%%
 /* crypto/opensslconf.h.in */
 
 /* Generate 80386 code? */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701262329.v0QNTUR9062799>