[vlc-commits] contrib: gcrypt: Backport upstream patches for fixing building for windows on aarch64

Martin Storsjö git at videolan.org
Fri Mar 30 15:16:08 CEST 2018


vlc | branch: master | Martin Storsjö <martin at martin.st> | Sat Dec 16 22:08:33 2017 +0200| [866f1330568ae4f67b865220ce3c1d108eabc18e] | committer: Martin Storsjö

contrib: gcrypt: Backport upstream patches for fixing building for windows on aarch64

These patches should be part of the next release after 1.8.1.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=866f1330568ae4f67b865220ce3c1d108eabc18e
---

 ...m-Don-t-assume-that-_WIN64-implies-x86_64.patch |  43 +++++
 ...-Fix-building-the-mpi-aarch64-assembly-fo.patch | 207 +++++++++++++++++++++
 contrib/src/gcrypt/rules.mak                       |   2 +
 3 files changed, 252 insertions(+)

diff --git a/contrib/src/gcrypt/0001-random-Don-t-assume-that-_WIN64-implies-x86_64.patch b/contrib/src/gcrypt/0001-random-Don-t-assume-that-_WIN64-implies-x86_64.patch
new file mode 100644
index 0000000000..7eb16ce1bd
--- /dev/null
+++ b/contrib/src/gcrypt/0001-random-Don-t-assume-that-_WIN64-implies-x86_64.patch
@@ -0,0 +1,43 @@
+From ed41d6d6fb4551342b22ef763de1bd60e964e186 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
+Date: Thu, 22 Mar 2018 23:32:36 +0200
+Subject: [PATCH 1/2] random: Don't assume that _WIN64 implies x86_64
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+* random/rndw32.c: Change _WIN64 ifdef into __x86_64__.
+--
+
+This fixes building this file for windows on aarch64.
+
+Signed-off-by: Martin Storsjö <martin at martin.st>
+---
+ random/rndw32.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/random/rndw32.c b/random/rndw32.c
+index 7e9ac50..08a8867 100644
+--- a/random/rndw32.c
++++ b/random/rndw32.c
+@@ -986,7 +986,7 @@ _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t,
+ 
+      On AMD64, TSC is always available and intrinsic is provided for accessing
+      it.  */
+-#ifdef __WIN64__
++#ifdef __x86_64__
+     {
+       unsigned __int64 aint64;
+ 
+@@ -1024,7 +1024,7 @@ _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t,
+           (*add) (&aword, sizeof (aword), origin );
+         }
+     }
+-#endif /*__WIN64__*/
++#endif /*__x86_64__*/
+ 
+ 
+ }
+-- 
+2.7.4
+
diff --git a/contrib/src/gcrypt/0002-aarch64-mpi-Fix-building-the-mpi-aarch64-assembly-fo.patch b/contrib/src/gcrypt/0002-aarch64-mpi-Fix-building-the-mpi-aarch64-assembly-fo.patch
new file mode 100644
index 0000000000..e6858e9724
--- /dev/null
+++ b/contrib/src/gcrypt/0002-aarch64-mpi-Fix-building-the-mpi-aarch64-assembly-fo.patch
@@ -0,0 +1,207 @@
+From ec0a2f25c0f64a7b65b373508ce9081e10461965 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
+Date: Thu, 22 Mar 2018 23:32:37 +0200
+Subject: [PATCH 2/2] aarch64: mpi: Fix building the mpi aarch64 assembly for
+ windows
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+* mpi/aarch64/mpih-add1.S: Use ELF macro.
+* mpi/aarch64/mpih-mul1.S: Use ELF macro.
+* mpi/aarch64/mpih-mul2.S: Use ELF macro.
+* mpi/aarch64/mpih-mul3.S: Use ELF macro.
+* mpi/aarch64/mpih-sub1.S: Use ELF macro.
+* mpi/asm-common-aarch64.h: New.
+--
+
+The mpi aarch64 assembly is enabled as soon as the compiler supports
+inline assembly, without checking for .type and .size, as is done
+for the rest of the assembly in cipher/*.S. (The .type and .size
+directives are only supported on ELF.)
+
+Signed-off-by: Martin Storsjö <martin at martin.st>
+---
+ mpi/aarch64/mpih-add1.S  |  5 +++--
+ mpi/aarch64/mpih-mul1.S  |  5 +++--
+ mpi/aarch64/mpih-mul2.S  |  5 +++--
+ mpi/aarch64/mpih-mul3.S  |  5 +++--
+ mpi/aarch64/mpih-sub1.S  |  5 +++--
+ mpi/asm-common-aarch64.h | 30 ++++++++++++++++++++++++++++++
+ 6 files changed, 45 insertions(+), 10 deletions(-)
+ create mode 100644 mpi/asm-common-aarch64.h
+
+diff --git a/mpi/aarch64/mpih-add1.S b/mpi/aarch64/mpih-add1.S
+index fa8cd01..4ead1c2 100644
+--- a/mpi/aarch64/mpih-add1.S
++++ b/mpi/aarch64/mpih-add1.S
+@@ -22,6 +22,7 @@
+ 
+ #include "sysdep.h"
+ #include "asm-syntax.h"
++#include "asm-common-aarch64.h"
+ 
+ /*******************
+  *  mpi_limb_t
+@@ -34,7 +35,7 @@
+ .text
+ 
+ .globl _gcry_mpih_add_n
+-.type  _gcry_mpih_add_n,%function
++ELF(.type  _gcry_mpih_add_n,%function)
+ _gcry_mpih_add_n:
+ 	and	x5, x3, #3;
+ 	adds	xzr, xzr, xzr; /* clear carry flag */
+@@ -68,4 +69,4 @@ _gcry_mpih_add_n:
+ .Lend:
+ 	adc	x0, xzr, xzr;
+ 	ret;
+-.size _gcry_mpih_add_n,.-_gcry_mpih_add_n;
++ELF(.size _gcry_mpih_add_n,.-_gcry_mpih_add_n;)
+diff --git a/mpi/aarch64/mpih-mul1.S b/mpi/aarch64/mpih-mul1.S
+index 65e98fe..8a86269 100644
+--- a/mpi/aarch64/mpih-mul1.S
++++ b/mpi/aarch64/mpih-mul1.S
+@@ -22,6 +22,7 @@
+ 
+ #include "sysdep.h"
+ #include "asm-syntax.h"
++#include "asm-common-aarch64.h"
+ 
+ /*******************
+  * mpi_limb_t
+@@ -34,7 +35,7 @@
+ .text
+ 
+ .globl _gcry_mpih_mul_1
+-.type  _gcry_mpih_mul_1,%function
++ELF(.type  _gcry_mpih_mul_1,%function)
+ _gcry_mpih_mul_1:
+ 	and	x5, x2, #3;
+ 	mov	x4, xzr;
+@@ -93,4 +94,4 @@ _gcry_mpih_mul_1:
+ .Lend:
+ 	mov	x0, x4;
+ 	ret;
+-.size _gcry_mpih_mul_1,.-_gcry_mpih_mul_1;
++ELF(.size _gcry_mpih_mul_1,.-_gcry_mpih_mul_1;)
+diff --git a/mpi/aarch64/mpih-mul2.S b/mpi/aarch64/mpih-mul2.S
+index bd3b2c9..c7c08e5 100644
+--- a/mpi/aarch64/mpih-mul2.S
++++ b/mpi/aarch64/mpih-mul2.S
+@@ -22,6 +22,7 @@
+ 
+ #include "sysdep.h"
+ #include "asm-syntax.h"
++#include "asm-common-aarch64.h"
+ 
+ /*******************
+  * mpi_limb_t
+@@ -34,7 +35,7 @@
+ .text
+ 
+ .globl _gcry_mpih_addmul_1
+-.type  _gcry_mpih_addmul_1,%function
++ELF(.type  _gcry_mpih_addmul_1,%function)
+ _gcry_mpih_addmul_1:
+ 	and	x5, x2, #3;
+ 	mov	x6, xzr;
+@@ -105,4 +106,4 @@ _gcry_mpih_addmul_1:
+ .Lend:
+ 	mov	x0, x6;
+ 	ret;
+-.size _gcry_mpih_addmul_1,.-_gcry_mpih_addmul_1;
++ELF(.size _gcry_mpih_addmul_1,.-_gcry_mpih_addmul_1;)
+diff --git a/mpi/aarch64/mpih-mul3.S b/mpi/aarch64/mpih-mul3.S
+index a58bc53..ccc961e 100644
+--- a/mpi/aarch64/mpih-mul3.S
++++ b/mpi/aarch64/mpih-mul3.S
+@@ -22,6 +22,7 @@
+ 
+ #include "sysdep.h"
+ #include "asm-syntax.h"
++#include "asm-common-aarch64.h"
+ 
+ /*******************
+  * mpi_limb_t
+@@ -34,7 +35,7 @@
+ .text
+ 
+ .globl _gcry_mpih_submul_1
+-.type  _gcry_mpih_submul_1,%function
++ELF(.type  _gcry_mpih_submul_1,%function)
+ _gcry_mpih_submul_1:
+ 	and	x5, x2, #3;
+ 	mov	x7, xzr;
+@@ -118,4 +119,4 @@ _gcry_mpih_submul_1:
+ .Loop_end:
+ 	cinc	x0, x7, cc;
+ 	ret;
+-.size _gcry_mpih_submul_1,.-_gcry_mpih_submul_1;
++ELF(.size _gcry_mpih_submul_1,.-_gcry_mpih_submul_1;)
+diff --git a/mpi/aarch64/mpih-sub1.S b/mpi/aarch64/mpih-sub1.S
+index cbf2f08..4a66373 100644
+--- a/mpi/aarch64/mpih-sub1.S
++++ b/mpi/aarch64/mpih-sub1.S
+@@ -22,6 +22,7 @@
+ 
+ #include "sysdep.h"
+ #include "asm-syntax.h"
++#include "asm-common-aarch64.h"
+ 
+ /*******************
+  *  mpi_limb_t
+@@ -34,7 +35,7 @@
+ .text
+ 
+ .globl _gcry_mpih_sub_n
+-.type  _gcry_mpih_sub_n,%function
++ELF(.type  _gcry_mpih_sub_n,%function)
+ _gcry_mpih_sub_n:
+ 	and	x5, x3, #3;
+ 	subs	xzr, xzr, xzr; /* prepare carry flag for sub */
+@@ -68,4 +69,4 @@ _gcry_mpih_sub_n:
+ .Lend:
+ 	cset	x0, cc;
+ 	ret;
+-.size _gcry_mpih_sub_n,.-_gcry_mpih_sub_n;
++ELF(.size _gcry_mpih_sub_n,.-_gcry_mpih_sub_n;)
+diff --git a/mpi/asm-common-aarch64.h b/mpi/asm-common-aarch64.h
+new file mode 100644
+index 0000000..1269413
+--- /dev/null
++++ b/mpi/asm-common-aarch64.h
+@@ -0,0 +1,30 @@
++/* asm-common-aarch64.h  -  Common macros for AArch64 assembly
++ *
++ * Copyright (C) 2018 Martin Storsjö <martin at martin.st>
++ *
++ * This file is part of Libgcrypt.
++ *
++ * Libgcrypt is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU Lesser General Public License as
++ * published by the Free Software Foundation; either version 2.1 of
++ * the License, or (at your option) any later version.
++ *
++ * Libgcrypt is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#ifndef MPI_ASM_COMMON_AARCH64_H
++#define MPI_ASM_COMMON_AARCH64_H
++
++#ifdef __ELF__
++# define ELF(...) __VA_ARGS__
++#else
++# define ELF(...) /*_*/
++#endif
++
++#endif /* MPI_ASM_COMMON_AARCH64_H */
+-- 
+2.7.4
+
diff --git a/contrib/src/gcrypt/rules.mak b/contrib/src/gcrypt/rules.mak
index 5510efb886..018080a66f 100644
--- a/contrib/src/gcrypt/rules.mak
+++ b/contrib/src/gcrypt/rules.mak
@@ -13,6 +13,8 @@ gcrypt: libgcrypt-$(GCRYPT_VERSION).tar.bz2 .sum-gcrypt
 	$(UNPACK)
 	$(APPLY) $(SRC)/gcrypt/disable-tests-compilation.patch
 	$(APPLY) $(SRC)/gcrypt/fix-pthread-detection.patch
+	$(APPLY) $(SRC)/gcrypt/0001-random-Don-t-assume-that-_WIN64-implies-x86_64.patch
+	$(APPLY) $(SRC)/gcrypt/0002-aarch64-mpi-Fix-building-the-mpi-aarch64-assembly-fo.patch
 ifdef HAVE_WINSTORE
 	$(APPLY) $(SRC)/gcrypt/winrt.patch
 endif



More information about the vlc-commits mailing list