Gentoo Archives: gentoo-commits

From: Michael Orlitzky <mjo@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sci-mathematics/flint/files/
Date: Fri, 28 May 2021 19:27:56
Message-Id: 1622230066.23c86f8f7da0613fef04521842168147f21bfc62.mjo@gentoo
1 commit: 23c86f8f7da0613fef04521842168147f21bfc62
2 Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
3 AuthorDate: Fri May 28 19:09:42 2021 +0000
4 Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
5 CommitDate: Fri May 28 19:27:46 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=23c86f8f
7
8 sci-mathematics/flint: update GMP detection patch.
9
10 The new patch to fix detection of GMP was unnecessarily hostile to
11 cross-compiling, but someone was nice enough to point it out on the
12 upstream pull request. Here's the patch that was accepted upstream.
13
14 Closes: https://bugs.gentoo.org/771663
15 Package-Manager: Portage-3.0.18, Repoman-3.0.2
16 Signed-off-by: Michael Orlitzky <mjo <AT> gentoo.org>
17
18 .../files/flint-2.7.1-fix-cmake-findgmp.patch | 72 ++++++++++------------
19 1 file changed, 33 insertions(+), 39 deletions(-)
20
21 diff --git a/sci-mathematics/flint/files/flint-2.7.1-fix-cmake-findgmp.patch b/sci-mathematics/flint/files/flint-2.7.1-fix-cmake-findgmp.patch
22 index d94d65c08d7..ca6e56ce197 100644
23 --- a/sci-mathematics/flint/files/flint-2.7.1-fix-cmake-findgmp.patch
24 +++ b/sci-mathematics/flint/files/flint-2.7.1-fix-cmake-findgmp.patch
25 @@ -1,4 +1,4 @@
26 -From 9f1ef23f34a7ceca1063606cfc749e4d32bef81c Mon Sep 17 00:00:00 2001
27 +From 41c4a0869d68d894cbe74a63612df75fd1e93bdf Mon Sep 17 00:00:00 2001
28 From: Michael Orlitzky <michael@××××××××.com>
29 Date: Mon, 19 Apr 2021 16:56:54 -0400
30 Subject: [PATCH 1/1] CMake/FindGMP.cmake: compile a test program to check the
31 @@ -7,18 +7,18 @@ Subject: [PATCH 1/1] CMake/FindGMP.cmake: compile a test program to check the
32 The existing GMP version check consists of grepping the contents of
33 the gmp.h header to parse out a few constants. This test fails, at
34 least, on Gentoo, where the usual header file is a wrapper that
35 -includes the true header (to allow for simultaneous 32/64-bit
36 -support).
37 +includes the true header to allow for simultaneous 32/64-bit
38 +support.
39
40 -This commit updates the FindGMP check to compile a test program
41 -against gmp.h that compares the version bounds within C, and reports
42 -success or failure as the return value from main().
43 +This commit updates FindGMP to compile a test program against gmp.h
44 +that compares version constants using the C preprocessor. If GMP is
45 +too old, the test program will fail to compile and CMake will know.
46 ---
47 - CMake/FindGMP.cmake | 97 +++++++++++++++++++++++++--------------------
48 - 1 file changed, 53 insertions(+), 44 deletions(-)
49 + CMake/FindGMP.cmake | 91 +++++++++++++++++++++++----------------------
50 + 1 file changed, 47 insertions(+), 44 deletions(-)
51
52 diff --git a/CMake/FindGMP.cmake b/CMake/FindGMP.cmake
53 -index ce4df70f5..bd2871ca3 100644
54 +index ce4df70f5..951151274 100644
55 --- a/CMake/FindGMP.cmake
56 +++ b/CMake/FindGMP.cmake
57 @@ -2,28 +2,23 @@
58 @@ -55,7 +55,7 @@ index ce4df70f5..bd2871ca3 100644
59 endif()
60 if(NOT GMP_FIND_VERSION_PATCH)
61 set(GMP_FIND_VERSION_PATCH 0)
62 -@@ -32,43 +27,57 @@ if(NOT GMP_FIND_VERSION)
63 +@@ -32,43 +27,51 @@ if(NOT GMP_FIND_VERSION)
64 "${GMP_FIND_VERSION_MAJOR}.${GMP_FIND_VERSION_MINOR}.${GMP_FIND_VERSION_PATCH}")
65 endif()
66
67 @@ -102,42 +102,36 @@ index ce4df70f5..bd2871ca3 100644
68 +
69 +if(GMP_INCLUDE_DIRS AND GMP_LIBRARIES)
70 +
71 -+ # Return "1" if the version is OK, or "0" otherwise. This is
72 -+ # opposite the usual C program conventions, but makes the purpose of
73 -+ # the result variable semantically clear. We create an integer using
74 -+ # a few basic GMP functions to ensure that we can actually link against
75 -+ # the GMP library.
76 ++ # This program will fail to compile if GMP is too old.
77 ++ # We prefer to perform this "test" at compile-time to
78 ++ # avoid problems with e.g. try_run() during cross-compilation.
79 + file(WRITE ${PROJECT_BINARY_DIR}/gmp-version-check.c ""
80 + "#include <gmp.h>\n"
81 + "\n"
82 -+ "int main(int argc, char **argv) {\n"
83 -+ " mpz_t x;\n"
84 -+ " mpz_init_set_str(x, \"7612058254738945\", 10);\n"
85 -+ " mpz_clear(x);\n"
86 -+ " if (__GNU_MP_VERSION < ${GMP_FIND_VERSION_MAJOR}) {\n"
87 -+ " return 0;\n"
88 -+ " }\n"
89 -+ " else {\n"
90 -+ " if (__GNU_MP_VERSION_MINOR < ${GMP_FIND_VERSION_MINOR}) {\n"
91 -+ " return 0;\n"
92 -+ " }\n"
93 -+ " else {\n"
94 -+ " if (__GNU_MP_VERSION_PATCHLEVEL < ${GMP_FIND_VERSION_PATCH}) {\n"
95 -+ " return 0;\n"
96 -+ " }\n"
97 -+ " }\n"
98 -+ " }\n"
99 -+ " return 1;\n"
100 -+ "}\n")
101 ++ "#define GMP_FIND_VERSION_MAJOR ${GMP_FIND_VERSION_MAJOR}\n"
102 ++ "#define GMP_FIND_VERSION_MINOR ${GMP_FIND_VERSION_MINOR}\n"
103 ++ "#define GMP_FIND_VERSION_PATCH ${GMP_FIND_VERSION_PATCH}\n"
104 ++ "\n"
105 ++ "#if __GNU_MP_VERSION < GMP_FIND_VERSION_MAJOR\n"
106 ++ "#error insufficient GMP major version\n"
107 ++ "#elif __GNU_MP_VERSION == GMP_FIND_VERSION_MAJOR\n"
108 ++ "#if __GNU_MP_VERSION_MINOR < GMP_FIND_VERSION_MINOR\n"
109 ++ "#error insufficient GMP minor version\n"
110 ++ "#elif __GNU_MP_VERSION_MINOR == GMP_FIND_VERSION_MINOR\n"
111 ++ "#if __GNU_MP_VERSION_PATCH < GMP_FIND_VERSION_PATCH\n"
112 ++ "#error insufficient GMP patch version\n"
113 ++ "#endif\n"
114 ++ "#endif\n"
115 ++ "#endif\n"
116 ++ "\n"
117 ++ "int main(int argc, char** argv) { return 0; }\n")
118 +
119 -+ # Try to run the test program above with the appropriate version
120 ++ # Try to compile the test program above with the appropriate version
121 + # strings substituted in.
122 -+ try_run(GMP_VERSION_OK
123 -+ GMP_VERSION_COMPILE_OK
124 ++ try_compile(GMP_VERSION_OK
125 + "${PROJECT_BINARY_DIR}"
126 + "${PROJECT_BINARY_DIR}/gmp-version-check.c"
127 -+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${GMP_INCLUDE_DIRS}"
128 -+ LINK_LIBRARIES "${GMP_LIBRARIES}")
129 ++ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${GMP_INCLUDE_DIRS}")
130 endif()
131
132 -find_library(GMP_LIBRARIES gmp PATHS $ENV{GMPDIR} ${LIB_INSTALL_DIR})