From 70b293d13a6f9d4fba7a5e76d5f9e507cd7d2b8b Mon Sep 17 00:00:00 2001 From: Vittorio Giovara <vittorio.giovara@savoirfairelinux.com> Date: Thu, 12 Jun 2014 11:03:54 -0400 Subject: [PATCH] contrib: add gcrypt rules Dependency required by ccrtp. Change-Id: I810fe72d5ac07afa5ddb36f24f476360ccd54484 Refs: #46617 --- .../0001-Fix-assembly-division-check.patch | 30 ++++ contrib/src/gcrypt/SHA512SUMS | 1 + .../fix-amd64-assembly-on-solaris.patch | 130 ++++++++++++++++++ ...gcrypt-fix-x86_64-codepath-on-Darwin.patch | 29 ++++ contrib/src/gcrypt/mpi-darwin13.patch | 15 ++ contrib/src/gcrypt/rules.mak | 55 ++++++++ 6 files changed, 260 insertions(+) create mode 100644 contrib/src/gcrypt/0001-Fix-assembly-division-check.patch create mode 100644 contrib/src/gcrypt/SHA512SUMS create mode 100644 contrib/src/gcrypt/fix-amd64-assembly-on-solaris.patch create mode 100644 contrib/src/gcrypt/gcrypt-fix-x86_64-codepath-on-Darwin.patch create mode 100644 contrib/src/gcrypt/mpi-darwin13.patch create mode 100644 contrib/src/gcrypt/rules.mak diff --git a/contrib/src/gcrypt/0001-Fix-assembly-division-check.patch b/contrib/src/gcrypt/0001-Fix-assembly-division-check.patch new file mode 100644 index 0000000000..13ec1b4614 --- /dev/null +++ b/contrib/src/gcrypt/0001-Fix-assembly-division-check.patch @@ -0,0 +1,30 @@ +From ef3e66e168c4b9b86bfc4903001631e53a7125d8 Mon Sep 17 00:00:00 2001 +From: Jussi Kivilinna <jussi.kivilinna@iki.fi> +Date: Sun, 12 Jan 2014 22:01:28 +0200 +Subject: [PATCH] Fix assembly division check + +* configure.ac (gcry_cv_gcc_as_const_division_ok): Correct variable +name mismatch at '--Wa,--divide' workaround check. +-- + +Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi> +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index fac5f7a..7d37f94 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1101,7 +1101,7 @@ if test $amd64_as_feature_detection = yes; then + AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [[__asm__("xorl \$(123456789/12345678), %ebp;\n\t");]])], + [gcry_cv_gcc_as_const_division_with_wadivide_ok=yes])]) +- if test "$gcry_cv_gcc_as_const_division_ok_with_wadivide_ok" = "no" ; then ++ if test "$gcry_cv_gcc_as_const_division_with_wadivide_ok" = "no" ; then + # '-Wa,--divide' did not work, restore old flags. + CPPFLAGS="$_gcc_cppflags_save" + fi +-- +1.9.1 + diff --git a/contrib/src/gcrypt/SHA512SUMS b/contrib/src/gcrypt/SHA512SUMS new file mode 100644 index 0000000000..8dd1cfc756 --- /dev/null +++ b/contrib/src/gcrypt/SHA512SUMS @@ -0,0 +1 @@ +83d502cf998736a5920df7324b7ff658041c34b2cfddccd8b96744ff940c0c84fe91fe7bfe03a69b10b9697a6f04f3007134bbc3c288b0fed78b60fc6ff15bc2 libgcrypt-1.6.1.tar.bz2 diff --git a/contrib/src/gcrypt/fix-amd64-assembly-on-solaris.patch b/contrib/src/gcrypt/fix-amd64-assembly-on-solaris.patch new file mode 100644 index 0000000000..a73fc60c97 --- /dev/null +++ b/contrib/src/gcrypt/fix-amd64-assembly-on-solaris.patch @@ -0,0 +1,130 @@ +From: Jussi Kivilinna <jussi.kivilinna@iki.fi> +Date: Sun, 12 Jan 2014 08:53:47 +0000 (+0200) +Subject: Fix constant division for AMD64 assembly on Solaris/x86 +X-Git-Url: http://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgcrypt.git;a=commitdiff_plain;h=43376891c01f4aff1fbfb23beafebb5adfd0868c + +Fix constant division for AMD64 assembly on Solaris/x86 + +* configure.ac (gcry_cv_gcc_as_const_division_ok): Add new check for +constant division in assembly and test for "-Wa,--divide" workaround. +(gcry_cv_gcc_amd64_platform_as_ok): Check for also constant division. +-- + +Appearantly on Solaris/x86 '/' character is treated as begining of line +comment by GNU as. This causes problems when compiling SHA-1 SSSE3 +implementation: + +On 02.01.2014 16:26, Richard PALO wrote: +>> COLLECT_GCC_OPTIONS='-D' 'HAVE_CONFIG_H' '-I' '.' '-I' '..' '-I' '../src' '-I' '/var/tmp/pkgsrc/security/libgcrypt/work/.buildlink/include' '-I' '/var/tmp/pkgsrc/security/libgcrypt/work/.buildlink/include/gettext' '-D' '_REENTRANT' '-O2' '-MT' 'sha1-ssse3-amd64.lo' '-MD' '-MP' '-MF' '.deps/sha1-ssse3-amd64.Tpo' '-c' '-fPIC' '-D' 'PIC' '-o' '.libs/sha1-ssse3-amd64.o' '-v' '-mtune=generic' '-march=x86-64' +>> /usr/gnu/bin/as -v -I . -I .. -I ../src -I /var/tmp/pkgsrc/security/libgcrypt/work/.buildlink/include -I /var/tmp/pkgsrc/security/libgcrypt/work/.buildlink/include/gettext -V -Qy -s --64 -o .libs/sha1-ssse3-amd64.o /var/tmp//ccAxWPXX.s +>> GNU assembler version 2.23.1 (i386-pc-solaris2.11) using BFD version (GNU Binutils) 2.23.1 +>> /var/tmp//ccAxWPXX.s: Assembler messages: +>> /var/tmp//ccAxWPXX.s:34: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:38: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:42: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:46: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:54: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:58: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:62: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:66: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:70: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:74: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:78: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:82: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:86: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:90: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:94: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:98: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:102: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:106: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:110: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:114: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:119: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:123: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:127: Error: unbalanced parenthesis in operand 1. +>> /var/tmp//ccAxWPXX.s:132: Error: unbalanced parenthesis in operand 1. +> +> +> apparently the paddd code, such as +> `paddd (.LK_XMM + ((i)/20)*16) RIP, tmp0;` +> isn't digested well, appended is the generated assembler code. + +On 02.01.2014 17:41, Richard PALO wrote: +> Hi again, after finding the following: +> https://sourceware.org/bugzilla/show_bug.cgi?id=4572 +> +> I tried using '-Wa,--divide' and that seemed to workaround the problem... +> +> perhaps the code, or at least the Makefile could be adapted accordingly? + +Patch adds detection of this feature and attempts to workaround issue with by +adding "-Wa,--divide" to CPPFLAGS. If workaround does not work (old GAS on +Solaris/x86), we'll disable AMD64 assembly. + +[v3]: + - Update CPPFLAGS after testing instead of CFLAGS. + +Reported-and-tested-by: Richard PALO <richard.palo@free.fr> +Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi> +--- + +diff --git a/configure.ac b/configure.ac +index 05cdaf8..fac5f7a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1079,11 +1079,42 @@ fi + + + # ++# Check whether GCC assembler needs "-Wa,--divide" to correctly handle ++# constant division ++# ++if test $amd64_as_feature_detection = yes; then ++ AC_CACHE_CHECK([whether GCC assembler handles division correctly], ++ [gcry_cv_gcc_as_const_division_ok], ++ [gcry_cv_gcc_as_const_division_ok=no ++ AC_COMPILE_IFELSE([AC_LANG_SOURCE( ++ [[__asm__("xorl \$(123456789/12345678), %ebp;\n\t");]])], ++ [gcry_cv_gcc_as_const_division_ok=yes])]) ++ if test "$gcry_cv_gcc_as_const_division_ok" = "no" ; then ++ # ++ # Add '-Wa,--divide' to CPPFLAGS and try check again. ++ # ++ _gcc_cppflags_save="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS -Wa,--divide" ++ AC_CACHE_CHECK([whether GCC assembler handles division correctly with "-Wa,--divide"], ++ [gcry_cv_gcc_as_const_division_with_wadivide_ok], ++ [gcry_cv_gcc_as_const_division_with_wadivide_ok=no ++ AC_COMPILE_IFELSE([AC_LANG_SOURCE( ++ [[__asm__("xorl \$(123456789/12345678), %ebp;\n\t");]])], ++ [gcry_cv_gcc_as_const_division_with_wadivide_ok=yes])]) ++ if test "$gcry_cv_gcc_as_const_division_ok_with_wadivide_ok" = "no" ; then ++ # '-Wa,--divide' did not work, restore old flags. ++ CPPFLAGS="$_gcc_cppflags_save" ++ fi ++ fi ++fi ++ ++ ++# + # Check whether GCC assembler supports features needed for our amd64 + # implementations + # + if test $amd64_as_feature_detection = yes; then +- AC_CACHE_CHECK([whether GCC assembler is compatible for amd64 assembly implementations], ++ AC_CACHE_CHECK([whether GCC assembler is compatible for amd64 assembly implementations], + [gcry_cv_gcc_amd64_platform_as_ok], + [gcry_cv_gcc_amd64_platform_as_ok=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( +@@ -1096,6 +1127,11 @@ if test $amd64_as_feature_detection = yes; then + "asmfunc:\n\t" + ".size asmfunc,.-asmfunc;\n\t" + ".type asmfunc,@function;\n\t" ++ /* Test if assembler allows use of '/' for constant division ++ * (Solaris/x86 issue). If previous constant division check ++ * and "-Wa,--divide" workaround failed, this causes assembly ++ * to be disable on this machine. */ ++ "xorl \$(123456789/12345678), %ebp;\n\t" + );]])], + [gcry_cv_gcc_amd64_platform_as_ok=yes])]) + if test "$gcry_cv_gcc_amd64_platform_as_ok" = "yes" ; then diff --git a/contrib/src/gcrypt/gcrypt-fix-x86_64-codepath-on-Darwin.patch b/contrib/src/gcrypt/gcrypt-fix-x86_64-codepath-on-Darwin.patch new file mode 100644 index 0000000000..e04787b4a1 --- /dev/null +++ b/contrib/src/gcrypt/gcrypt-fix-x86_64-codepath-on-Darwin.patch @@ -0,0 +1,29 @@ +From 3149e9b73a94b45a5126cc778fe03f0b686dced9 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org> +Date: Sat, 22 Mar 2014 19:55:52 +0100 +Subject: [PATCH] Fix code path selection for x86_64 on Darwin + +--- + mpi/config.links | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/mpi/config.links b/mpi/config.links +index 0217d35..4f35ea2 100644 +--- a/mpi/config.links ++++ b/mpi/config.links +@@ -127,6 +127,12 @@ case "${host}" in + path="i586 i386" + mpi_cpu_arch="x86" + ;; ++ x86_64-apple-darwin*) ++ echo '#define BSD_SYNTAX' >>./mpi/asm-syntax.h ++ cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h ++ path="amd64" ++ mpi_cpu_arch="x86" ++ ;; + x86_64-*-*) + echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h + cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h +-- +1.8.5.2 (Apple Git-48) + diff --git a/contrib/src/gcrypt/mpi-darwin13.patch b/contrib/src/gcrypt/mpi-darwin13.patch new file mode 100644 index 0000000000..a1f9af5028 --- /dev/null +++ b/contrib/src/gcrypt/mpi-darwin13.patch @@ -0,0 +1,15 @@ +--- a/mpi/config.links 2013-07-25 13:10:04.000000000 +0400 ++++ b/mpi/config.links 2013-11-10 15:36:20.000000000 +0400 +@@ -100,6 +100,12 @@ + cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h + path="i586 i386" + ;; ++ x86_64-apple-darwin13*) ++ echo '#define BSD_SYNTAX' >>./mpi/asm-syntax.h ++ cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h ++ path="amd64" ++ mpi_cpu_arch="x86" ++ ;; + i[3467]86*-*-*) + echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h + cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h diff --git a/contrib/src/gcrypt/rules.mak b/contrib/src/gcrypt/rules.mak new file mode 100644 index 0000000000..2d1ece90c1 --- /dev/null +++ b/contrib/src/gcrypt/rules.mak @@ -0,0 +1,55 @@ +# GNU Cryptography + +GCRYPT_VERSION := 1.6.1 +GCRYPT_URL := ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-$(GCRYPT_VERSION).tar.bz2 + +ifeq ($(call need_pkg," >= 1.5.0"),) +PKGS_FOUND += gcrypt +endif + +DEPS_gcrypt = gpgerror + +$(TARBALLS)/libgcrypt-$(GCRYPT_VERSION).tar.bz2: + $(call download,$(GCRYPT_URL)) + +.sum-gcrypt: libgcrypt-$(GCRYPT_VERSION).tar.bz2 + +gcrypt: libgcrypt-$(GCRYPT_VERSION).tar.bz2 .sum-gcrypt + $(UNPACK) + $(APPLY) $(SRC)/gcrypt/gcrypt-fix-x86_64-codepath-on-Darwin.patch + $(APPLY) $(SRC)/gcrypt/fix-amd64-assembly-on-solaris.patch + $(APPLY) $(SRC)/gcrypt/0001-Fix-assembly-division-check.patch + $(APPLY) $(SRC)/gcrypt/mpi-darwin13.patch + $(MOVE) + + +GCRYPT_CONF = \ + --enable-ciphers=aes,des,rfc2268,arcfour \ + --enable-digests=sha1,md5,rmd160,sha256,sha512 \ + --enable-pubkey-ciphers=dsa,rsa,ecc +ifdef HAVE_WIN64 +GCRYPT_CONF += --disable-asm +endif +ifdef HAVE_IOS +GCRYPT_EXTRA_CFLAGS = -fheinous-gnu-extensions +else +GCRYPT_EXTRA_CFLAGS = +endif +ifdef HAVE_MACOSX +GCRYPT_CONF += --disable-aesni-support +else +ifdef HAVE_BSD +GCRYPT_CONF += --disable-asm --disable-aesni-support +endif +endif +ifdef HAVE_ANDROID +ifeq ($(ANDROID_ABI), x86) +GCRYPT_CONF += ac_cv_sys_symbol_underscore=no +endif +endif + +.gcrypt: gcrypt + $(RECONF) + cd $< && $(HOSTVARS) CFLAGS="$(CFLAGS) $(GCRYPT_EXTRA_CFLAGS)" ./configure $(HOSTCONF) $(GCRYPT_CONF) + cd $< && $(MAKE) install + touch $@ -- GitLab