Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
47a1a72
* add arm64:windows asm optimization compatibility
Sep 12, 2022
1b98bfe
* update version
Sep 12, 2022
4b10959
* using clang-cl to compile arm64 gas assembly
Sep 13, 2022
606779d
* fix portfile configuration for arm target
Sep 13, 2022
5116efe
Merge branch 'microsoft:master' into gmp-arm64-windows-asm-optimization
eukarpov Sep 13, 2022
367a4c1
* fix portfile configuration for arm target
Sep 13, 2022
7f0a155
* update version
Sep 13, 2022
9060d64
Merge branch 'gmp-arm64-windows-asm-optimization' of https://github.c…
Sep 13, 2022
5efb2e6
* arm64 patch and portfile refactoring
Sep 14, 2022
8c19de4
* update version
Sep 14, 2022
68ed75f
* add "find or download" requirement for clang
Sep 15, 2022
d3b45d4
* update version
Sep 15, 2022
f888ed8
* refactor arm64.patch
Sep 30, 2022
513b561
* update version
Sep 30, 2022
0f6022c
* changes from upstream
Oct 12, 2022
ecd1aaa
* update version
Oct 12, 2022
844d822
Merge branch 'microsoft:master' into gmp-arm64-windows-asm-optimization
eukarpov Oct 13, 2022
5feb5ec
* add path to clang-cl from Visuao Studio on arm64 host
Oct 13, 2022
abcb618
* update version
Oct 13, 2022
d331aaf
Merge branch 'gmp-arm64-windows-asm-optimization' of https://github.c…
Oct 13, 2022
5c3d162
Merge remote-tracking branch 'origin/master' into HEAD
BillyONeal Oct 21, 2022
eb299f2
Reduce the patch size by downloading most of the patch from upstream'…
BillyONeal Oct 21, 2022
80661de
Version database.
BillyONeal Oct 21, 2022
f0e7878
Use a better name for the patch download.
BillyONeal Oct 21, 2022
ee37e13
* add clang-cl check
Nov 11, 2022
f696c88
* Update version
Nov 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions ports/gmp/arm64-coff.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
diff --git a/configure.ac b/configure.ac
index bd92bc4..bd2c0af 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3704,6 +3704,8 @@ if test "$gmp_asm_syntax_testing" != no; then
case $host in
*-*-darwin*)
GMP_INCLUDE_MPN(arm64/darwin.m4) ;;
+ *-pc-mingw32)
+ GMP_INCLUDE_MPN(arm64/coff.m4) ;;
*)
GMP_INCLUDE_MPN(arm64/arm64-defs.m4) ;;
esac
diff --git a/mpn/arm64/coff.m4 b/mpn/arm64/coff.m4
new file mode 100644
index 0000000..88605b3
--- /dev/null
+++ b/mpn/arm64/coff.m4
@@ -0,0 +1,54 @@
+divert(-1)
+
+dnl m4 macros for ARM64 COFF assembler.
+
+dnl Copyright 2020 Free Software Foundation, Inc.
+
+dnl This file is part of the GNU MP Library.
+dnl
+dnl The GNU MP Library is free software; you can redistribute it and/or modify
+dnl it under the terms of either:
+dnl
+dnl * the GNU Lesser General Public License as published by the Free
+dnl Software Foundation; either version 3 of the License, or (at your
+dnl option) any later version.
+dnl
+dnl or
+dnl
+dnl * the GNU General Public License as published by the Free Software
+dnl Foundation; either version 2 of the License, or (at your option) any
+dnl later version.
+dnl
+dnl or both in parallel, as here.
+dnl
+dnl The GNU MP Library is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+dnl for more details.
+dnl
+dnl You should have received copies of the GNU General Public License and the
+dnl GNU Lesser General Public License along with the GNU MP Library. If not,
+dnl see https://www.gnu.org/licenses/.
+
+
+dnl Standard commenting is with @, the default m4 # is for constants and we
+dnl don't want to disable macro expansions in or after them.
+
+changecom
+
+
+dnl LEA_HI(reg,gmp_symbol), LEA_LO(reg,gmp_symbol)
+dnl
+dnl Load the address of gmp_symbol into a register. We split this into two
+dnl parts to allow separation for manual insn scheduling.
+
+define(`LEA_HI', `ldr $1, =$2')dnl
+define(`LEA_LO')dnl
+
+dnl Usage: ALIGN(bytes)
+dnl
+dnl Emit a ".align" directive.
+
+define(`ALIGN', ` .align 8')dnl
+
+divert`'dnl
55 changes: 36 additions & 19 deletions ports/gmp/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,41 @@ vcpkg_download_distfile(
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
set(PATCHES yasm.patch
msvc_symbol.patch)

if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
# Hint to use clang x86/x64 version in emulation mode on an ARM device
vcpkg_add_to_path("$ENV{VCINSTALLDIR}/Tools/Llvm/bin")

find_program(clang-cl-check clang-cl)
if (NOT clang-cl-check)
message(FATAL_ERROR "${PORT} requires Clang installed for ${VCPKG_TARGET_ARCHITECTURE} target architecture. For instance, Clang can be installed by using Visual Studio or LLVM installers")
endif()

set(ENV{CCAS} "clang-cl --target=arm64-pc-win32 -c")
# Avoid the x18 register since it is reserved on Darwin.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The x18 register is a platform register based on ARM64 ABI for Windows convention. It turned out that Darwin has the same issue. I would change the comment to avoid confusion why Darwin patch is used to avoid issue on ARM64 Windows.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine; I was just copying the upstream comment.

vcpkg_download_distfile(
ARM64PATCH
URLS https://gmplib.org/repo/gmp/raw-rev/5f32dbc41afc
FILENAME gmp-arm64-asm-fix-5f32dbc41afc.patch
SHA512 4a7c50dc0a78e6c297c0ac53129ed367dbf669100a613653987d0eddf175376296254ed26ecce15d02b0544b99e44719af49635e54982b22e745f22e2f8d1eda
)

list(APPEND PATCHES "${ARM64PATCH}" arm64-coff.patch)
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
list(APPEND OPTIONS --enable-assembly=no)
else()
set(ENV{CCAS} "${CURRENT_HOST_INSTALLED_DIR}/tools/yasm/yasm${VCPKG_HOST_EXECUTABLE_SUFFIX}")
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(asmflag win64)
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
set(asmflag win32)
endif()
set(ENV{ASMFLAGS} "-Xvc -f ${asmflag} -pgas -rraw")
endif()

list(APPEND OPTIONS ac_cv_func_memset=yes
"gmp_cv_asm_w32=.word"
)
endif()

vcpkg_extract_source_archive_ex(
Expand All @@ -23,30 +58,12 @@ vcpkg_extract_source_archive_ex(
tools.patch
)

if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
set(ENV{CCAS} "${CURRENT_HOST_INSTALLED_DIR}/tools/yasm/yasm${VCPKG_HOST_EXECUTABLE_SUFFIX}")
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(asmflag win64)
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
set(asmflag win32)
endif()
set(ENV{ASMFLAGS} "-Xvc -f ${asmflag} -pgas -rraw")
set(OPTIONS ac_cv_func_memset=yes
"gmp_cv_asm_w32=.word"
)

endif()

if(VCPKG_CROSSCOMPILING)
# Silly trick to make configure accept CC_FOR_BUILD but in reallity CC_FOR_BUILD is deactivated.
# Silly trick to make configure accept CC_FOR_BUILD but in reallity CC_FOR_BUILD is deactivated.
set(ENV{CC_FOR_BUILD} "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true")
set(ENV{CPP_FOR_BUILD} "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true")
endif()

if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_TARGET_ARCHITECTURE MATCHES "^(arm|arm64)$")
list(APPEND OPTIONS --enable-assembly=no)
endif()

vcpkg_configure_make(
SOURCE_PATH "${SOURCE_PATH}"
AUTOCONFIG
Expand Down
2 changes: 1 addition & 1 deletion ports/gmp/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gmp",
"version": "6.2.1",
"port-version": 13,
"port-version": 14,
"description": "The GNU Multiple Precision Arithmetic Library",
"homepage": "https://gmplib.org",
"license": "LGPL-3.0-only OR GPL-2.0-only",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2690,7 +2690,7 @@
},
"gmp": {
"baseline": "6.2.1",
"port-version": 13
"port-version": 14
},
"gmsh": {
"baseline": "4.9.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/g-/gmp.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "bbdf09a738d5ead125ea27d5b4cd6ffd957b2fae",
"version": "6.2.1",
"port-version": 14
},
{
"git-tree": "28b5b46e27a69da50c1cd0a8be5d0a32cbca120b",
"version": "6.2.1",
Expand Down