[vlc-devel] [PATCH 2/2] gcrypt: fix amd64 assembly on Solaris

Sean McGovern gseanmcg at gmail.com
Wed Mar 26 23:18:50 CET 2014


---
 .../src/gcrypt/fix-amd64-assembly-on-solaris.patch |  134 ++++++++++++++++++++
 contrib/src/gcrypt/rules.mak                       |    3 +-
 2 files changed, 136 insertions(+), 1 deletion(-)
 create mode 100644 contrib/src/gcrypt/fix-amd64-assembly-on-solaris.patch

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 0000000..bd60b52
--- /dev/null
+++ b/contrib/src/gcrypt/fix-amd64-assembly-on-solaris.patch
@@ -0,0 +1,134 @@
+[v2] Fix constant division for AMD64 assembly on Solaris/x86
+
+From: Jussi Kivilinna <jussi.kivilinna at iki.fi>
+
+* 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. 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.
+
+[v2]:
+ - Update CPPFLAGS after testing instead of CFLAGS. CFLAGS are modified
+   because that's what is used by AC_COMPILE_IFELSE. However Makefiles use
+   CPPFLAGS for assembly files (*.S).
+
+Reported-by: Richard PALO <richard.palo at free.fr>
+Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
+---
+ configure.ac |   42 +++++++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 41 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index e98fa4e..c5321b6 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1077,11 +1077,46 @@ 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 CFLAGS (AC_COMPILE_IFELSE uses CFLAGS) and
++    # try check again.
++    #
++    _gcc_cflags_save="$CFLAGS"
++    CFLAGS="$CFLAGS -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])])
++    CFLAGS="$_gcc_cflags_save"
++    if test "$gcry_cv_gcc_as_const_division_ok" = "yes" ; then
++      #
++      # Assembly files (*.S) are compiled with CPPFLAGS, not CFLAGS.
++      #
++      CPPFLAGS="$CPPFLAGS -Wa,--divide"
++    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(
+@@ -1094,6 +1129,11 @@ if test $amd64_as_feature_detection = yes; then
+ 		"asmfunc:\n\t"
+                 ".size asmfunc,.-asmfunc;\n\t"
+                 ".type asmfunc, at 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/rules.mak b/contrib/src/gcrypt/rules.mak
index 9f20675..8bb4cec 100644
--- a/contrib/src/gcrypt/rules.mak
+++ b/contrib/src/gcrypt/rules.mak
@@ -12,6 +12,7 @@ $(TARBALLS)/libgcrypt-$(GCRYPT_VERSION).tar.bz2:
 libgcrypt: 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
 	$(MOVE)
 
 DEPS_gcrypt = gpg-error
@@ -42,7 +43,7 @@ endif
 endif
 
 .gcrypt: libgcrypt
-	#$(RECONF)
+	$(RECONF)
 	cd $< && $(HOSTVARS) CFLAGS="$(CFLAGS) $(GCRYPT_EXTRA_CFLAGS)" ./configure $(HOSTCONF) $(GCRYPT_CONF)
 	cd $< && $(MAKE) install
 	touch $@
-- 
1.7.9.2




More information about the vlc-devel mailing list