Skip to content

Commit fe9fca0

Browse files
committed
unix: build mpdecimal from source
This is the first step in providing our own mpdecimal library instead of using the one bundled with CPython. This commit only builds the library: we don't yet use it when building CPython.
1 parent ba9fe19 commit fe9fca0

File tree

6 files changed

+85
-0
lines changed

6 files changed

+85
-0
lines changed

LICENSE.mpdecimal.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions
5+
are met:
6+
7+
1. Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in the
12+
documentation and/or other materials provided with the distribution.
13+
14+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
15+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24+
SUCH DAMAGE.

cpython-unix/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ $(OUTDIR)/libxcb-$(LIBXCB_VERSION)-$(PACKAGE_SUFFIX).tar: $(LIBXCB_DEPENDS)
164164
$(OUTDIR)/m4-$(M4_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-m4.sh
165165
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) m4
166166

167+
$(OUTDIR)/mpdecimal-$(MPDECIMAL_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-mpdecimal.sh
168+
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) mpdecimal
169+
167170
$(OUTDIR)/ncurses-$(NCURSES_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-ncurses.sh
168171
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) ncurses
169172

@@ -245,6 +248,7 @@ PYTHON_DEPENDS := \
245248
$(if $(NEED_LIBEDIT),$(OUTDIR)/libedit-$(LIBEDIT_VERSION)-$(PACKAGE_SUFFIX).tar) \
246249
$(if $(NEED_LIBFFI),$(OUTDIR)/libffi-$(LIBFFI_VERSION)-$(PACKAGE_SUFFIX).tar) \
247250
$(if $(NEED_m4),$(OUTDIR)/m4-$(M4_VERSION)-$(PACKAGE_SUFFIX).tar) \
251+
$(if $(NEED_MPDECIMAL),$(OUTDIR)/mpdecimal-$(MPDECIMAL_VERSION)-$(PACKAGE_SUFFIX).tar) \
248252
$(if $(NEED_NCURSES),$(OUTDIR)/ncurses-$(NCURSES_VERSION)-$(PACKAGE_SUFFIX).tar) \
249253
$(if $(NEED_OPENSSL),$(OUTDIR)/openssl-$(OPENSSL_VERSION)-$(PACKAGE_SUFFIX).tar) \
250254
$(if $(NEED_PATCHELF),$(OUTDIR)/patchelf-$(PATCHELF_VERSION)-$(PACKAGE_SUFFIX).tar) \

cpython-unix/build-mpdecimal.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
# This Source Code Form is subject to the terms of the Mozilla Public
3+
# License, v. 2.0. If a copy of the MPL was not distributed with this
4+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
6+
set -ex
7+
8+
ROOT=`pwd`
9+
10+
export PATH=${TOOLS_PATH}/${TOOLCHAIN}/bin:${TOOLS_PATH}/host/bin:$PATH
11+
12+
tar -xf mpdecimal-${MPDECIMAL_VERSION}.tar.gz
13+
14+
pushd mpdecimal-${MPDECIMAL_VERSION}
15+
16+
CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" CPPFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" ./configure \
17+
--build=${BUILD_TRIPLE} \
18+
--host=${TARGET_TRIPLE} \
19+
--prefix=/tools/deps \
20+
--disable-cxx \
21+
--disable-shared
22+
23+
make -j ${NUM_CPUS}
24+
make -j ${NUM_CPUS} install DESTDIR=${ROOT}/out

cpython-unix/build.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@ def main():
970970
"libffi",
971971
"libpthread-stubs",
972972
"m4",
973+
"mpdecimal",
973974
"ncurses",
974975
"openssl",
975976
"patchelf",

cpython-unix/targets.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ aarch64-apple-darwin:
8888
- bzip2
8989
- libffi
9090
- m4
91+
- mpdecimal
9192
- openssl
9293
- sqlite
9394
- tcl
@@ -130,6 +131,7 @@ aarch64-apple-ios:
130131
- bzip2
131132
- libffi
132133
- m4
134+
- mpdecimal
133135
- openssl
134136
- sqlite
135137
- xz
@@ -158,6 +160,7 @@ aarch64-unknown-linux-gnu:
158160
- libXau
159161
- libxcb
160162
- m4
163+
- mpdecimal
161164
- ncurses
162165
- openssl
163166
- patchelf
@@ -204,6 +207,7 @@ arm64-apple-tvos:
204207
- autoconf
205208
- bzip2
206209
- m4
210+
- mpdecimal
207211
- openssl
208212
- sqlite
209213
- xz
@@ -231,6 +235,7 @@ armv7-unknown-linux-gnueabi:
231235
- libXau
232236
- libxcb
233237
- m4
238+
- mpdecimal
234239
- ncurses
235240
- openssl
236241
- patchelf
@@ -266,6 +271,7 @@ armv7-unknown-linux-gnueabihf:
266271
- libXau
267272
- libxcb
268273
- m4
274+
- mpdecimal
269275
- ncurses
270276
- openssl
271277
- patchelf
@@ -308,6 +314,7 @@ i686-unknown-linux-gnu:
308314
- libXau
309315
- libxcb
310316
- m4
317+
- mpdecimal
311318
- ncurses
312319
- openssl
313320
- patchelf
@@ -343,6 +350,7 @@ mips-unknown-linux-gnu:
343350
- libXau
344351
- libxcb
345352
- m4
353+
- mpdecimal
346354
- ncurses
347355
- openssl
348356
- patchelf
@@ -378,6 +386,7 @@ mipsel-unknown-linux-gnu:
378386
- libXau
379387
- libxcb
380388
- m4
389+
- mpdecimal
381390
- ncurses
382391
- openssl
383392
- patchelf
@@ -413,6 +422,7 @@ s390x-unknown-linux-gnu:
413422
- libXau
414423
- libxcb
415424
- m4
425+
- mpdecimal
416426
- ncurses
417427
- openssl
418428
- patchelf
@@ -459,6 +469,7 @@ thumb7k-apple-watchos:
459469
- autoconf
460470
- bzip2
461471
- m4
472+
- mpdecimal
462473
- openssl
463474
- sqlite
464475
- xz
@@ -504,6 +515,7 @@ x86_64-apple-darwin:
504515
- bzip2
505516
- libffi
506517
- m4
518+
- mpdecimal
507519
- openssl
508520
- sqlite
509521
- tcl
@@ -546,6 +558,7 @@ x86_64-apple-ios:
546558
- bzip2
547559
- libffi
548560
- m4
561+
- mpdecimal
549562
- openssl
550563
- sqlite
551564
- xz
@@ -584,6 +597,7 @@ x86_64-apple-tvos:
584597
- autoconf
585598
- bzip2
586599
- m4
600+
- mpdecimal
587601
- openssl
588602
- sqlite
589603
- xz
@@ -622,6 +636,7 @@ x86_64-apple-watchos:
622636
- autoconf
623637
- bzip2
624638
- m4
639+
- mpdecimal
625640
- openssl
626641
- sqlite
627642
- xz
@@ -652,6 +667,7 @@ x86_64-unknown-linux-gnu:
652667
- libXau
653668
- libxcb
654669
- m4
670+
- mpdecimal
655671
- ncurses
656672
- openssl
657673
- patchelf
@@ -691,6 +707,7 @@ x86_64_v2-unknown-linux-gnu:
691707
- libXau
692708
- libxcb
693709
- m4
710+
- mpdecimal
694711
- ncurses
695712
- openssl
696713
- patchelf
@@ -730,6 +747,7 @@ x86_64_v3-unknown-linux-gnu:
730747
- libXau
731748
- libxcb
732749
- m4
750+
- mpdecimal
733751
- ncurses
734752
- openssl
735753
- patchelf
@@ -769,6 +787,7 @@ x86_64_v4-unknown-linux-gnu:
769787
- libXau
770788
- libxcb
771789
- m4
790+
- mpdecimal
772791
- ncurses
773792
- openssl
774793
- patchelf
@@ -807,6 +826,7 @@ x86_64-unknown-linux-musl:
807826
- libXau
808827
- libxcb
809828
- m4
829+
- mpdecimal
810830
- musl
811831
- ncurses
812832
- openssl
@@ -847,6 +867,7 @@ x86_64_v2-unknown-linux-musl:
847867
- libXau
848868
- libxcb
849869
- m4
870+
- mpdecimal
850871
- musl
851872
- ncurses
852873
- openssl
@@ -887,6 +908,7 @@ x86_64_v3-unknown-linux-musl:
887908
- libXau
888909
- libxcb
889910
- m4
911+
- mpdecimal
890912
- musl
891913
- ncurses
892914
- openssl
@@ -927,6 +949,7 @@ x86_64_v4-unknown-linux-musl:
927949
- libXau
928950
- libxcb
929951
- m4
952+
- mpdecimal
930953
- musl
931954
- ncurses
932955
- openssl

pythonbuild/downloads.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,15 @@
165165
"sha256": "63aede5c6d33b6d9b13511cd0be2cac046f2e70fd0a07aa9573a04a82783af96",
166166
"version": "1.4.19",
167167
},
168+
"mpdecimal": {
169+
"url": "https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-2.5.1.tar.gz",
170+
"size": 2584021,
171+
"sha256": "9f9cd4c041f99b5c49ffb7b59d9f12d95b683d88585608aa56a6307667b2b21f",
172+
"version": "2.5.1",
173+
"library_names": ["mpdec"],
174+
"licenses": ["BSD-2-Clause"],
175+
"license_file": "LICENSE.mpdecimal.txt",
176+
},
168177
"musl": {
169178
"url": "https://musl.libc.org/releases/musl-1.2.3.tar.gz",
170179
"size": 1058642,

0 commit comments

Comments
 (0)