Skip to content

Commit 735402c

Browse files
committed
unix: build expat from source
Similar deal as mpdecimal. We want to link against a standalone built library instead of using the version in CPython.
1 parent 89d29a5 commit 735402c

File tree

6 files changed

+88
-0
lines changed

6 files changed

+88
-0
lines changed

LICENSE.expat.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper
2+
Copyright (c) 2001-2022 Expat maintainers
3+
4+
Permission is hereby granted, free of charge, to any person obtaining
5+
a copy of this software and associated documentation files (the
6+
"Software"), to deal in the Software without restriction, including
7+
without limitation the rights to use, copy, modify, merge, publish,
8+
distribute, sublicense, and/or sell copies of the Software, and to
9+
permit persons to whom the Software is furnished to do so, subject to
10+
the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included
13+
in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

cpython-unix/Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ $(OUTDIR)/bdb-$(BDB_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE
108108
$(OUTDIR)/bzip2-$(BZIP2_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-bzip2.sh
109109
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) bzip2
110110

111+
$(OUTDIR)/expat-$(EXPAT_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-expat.sh
112+
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) expat
113+
111114
$(OUTDIR)/gdbm-$(GDBM_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-gdbm.sh
112115
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) gdbm
113116

@@ -244,6 +247,7 @@ PYTHON_DEPENDS := \
244247
$(if $(NEED_AUTOCONF),$(OUTDIR)/autoconf-$(AUTOCONF_VERSION)-$(PACKAGE_SUFFIX).tar) \
245248
$(if $(NEED_BDB),$(OUTDIR)/bdb-$(BDB_VERSION)-$(PACKAGE_SUFFIX).tar) \
246249
$(if $(NEED_BZIP2),$(OUTDIR)/bzip2-$(BZIP2_VERSION)-$(PACKAGE_SUFFIX).tar) \
250+
$(if $(NEED_EXPAT),$(OUTDIR)/expat-$(EXPAT_VERSION)-$(PACKAGE_SUFFIX).tar) \
247251
$(if $(NEED_GDBM),$(OUTDIR)/gdbm-$(GDBM_VERSION)-$(PACKAGE_SUFFIX).tar) \
248252
$(if $(NEED_LIBEDIT),$(OUTDIR)/libedit-$(LIBEDIT_VERSION)-$(PACKAGE_SUFFIX).tar) \
249253
$(if $(NEED_LIBFFI),$(OUTDIR)/libffi-$(LIBFFI_VERSION)-$(PACKAGE_SUFFIX).tar) \

cpython-unix/build-expat.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 expat-${EXPAT_VERSION}.tar.xz
13+
14+
pushd expat-${EXPAT_VERSION}
15+
16+
# xmlwf isn't needed by CPython.
17+
# Disable -fexceptions because we don't need it and it adds a dependency on libgcc_s, which
18+
# is softly undesirable.
19+
CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" CPPFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" ./configure \
20+
--build=${BUILD_TRIPLE} \
21+
--host=${TARGET_TRIPLE} \
22+
--prefix=/tools/deps \
23+
--disable-shared \
24+
--without-examples \
25+
--without-tests \
26+
--without-xmlwf \
27+
ax_cv_check_cflags___fexceptions=no
28+
29+
make -j ${NUM_CPUS}
30+
make -j ${NUM_CPUS} install DESTDIR=${ROOT}/out

cpython-unix/build.py

+1
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,7 @@ def main():
964964
elif action in (
965965
"bdb",
966966
"bzip2",
967+
"expat",
967968
"gdbm",
968969
"inputproto",
969970
"kbproto",

cpython-unix/targets.yml

+23
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ aarch64-apple-darwin:
8686
needs:
8787
- autoconf
8888
- bzip2
89+
- expat
8990
- libffi
9091
- m4
9192
- mpdecimal
@@ -129,6 +130,7 @@ aarch64-apple-ios:
129130
needs:
130131
- autoconf
131132
- bzip2
133+
- expat
132134
- libffi
133135
- m4
134136
- mpdecimal
@@ -154,6 +156,7 @@ aarch64-unknown-linux-gnu:
154156
- binutils
155157
- bzip2
156158
- gdbm
159+
- expat
157160
- libedit
158161
- libffi
159162
- libX11
@@ -206,6 +209,7 @@ arm64-apple-tvos:
206209
needs:
207210
- autoconf
208211
- bzip2
212+
- expat
209213
- m4
210214
- mpdecimal
211215
- openssl
@@ -228,6 +232,7 @@ armv7-unknown-linux-gnueabi:
228232
- bdb
229233
- binutils
230234
- bzip2
235+
- expat
231236
- gdbm
232237
- libedit
233238
- libffi
@@ -264,6 +269,7 @@ armv7-unknown-linux-gnueabihf:
264269
- bdb
265270
- binutils
266271
- bzip2
272+
- expat
267273
- gdbm
268274
- libedit
269275
- libffi
@@ -308,6 +314,7 @@ i686-unknown-linux-gnu:
308314
- bzip2
309315
# TODO cross-compiling has issues.
310316
# - gdbm
317+
- expat
311318
- libedit
312319
- libffi
313320
- libX11
@@ -343,6 +350,7 @@ mips-unknown-linux-gnu:
343350
- bdb
344351
- binutils
345352
- bzip2
353+
- expat
346354
- gdbm
347355
- libedit
348356
- libffi
@@ -379,6 +387,7 @@ mipsel-unknown-linux-gnu:
379387
- bdb
380388
- binutils
381389
- bzip2
390+
- expat
382391
- gdbm
383392
- libedit
384393
- libffi
@@ -415,6 +424,7 @@ s390x-unknown-linux-gnu:
415424
- bdb
416425
- binutils
417426
- bzip2
427+
- expat
418428
- gdbm
419429
- libedit
420430
- libffi
@@ -468,6 +478,7 @@ thumb7k-apple-watchos:
468478
needs:
469479
- autoconf
470480
- bzip2
481+
- expat
471482
- m4
472483
- mpdecimal
473484
- openssl
@@ -513,6 +524,7 @@ x86_64-apple-darwin:
513524
needs:
514525
- autoconf
515526
- bzip2
527+
- expat
516528
- libffi
517529
- m4
518530
- mpdecimal
@@ -556,6 +568,7 @@ x86_64-apple-ios:
556568
needs:
557569
- autoconf
558570
- bzip2
571+
- expat
559572
- libffi
560573
- m4
561574
- mpdecimal
@@ -596,6 +609,7 @@ x86_64-apple-tvos:
596609
needs:
597610
- autoconf
598611
- bzip2
612+
- expat
599613
- m4
600614
- mpdecimal
601615
- openssl
@@ -635,6 +649,7 @@ x86_64-apple-watchos:
635649
needs:
636650
- autoconf
637651
- bzip2
652+
- expat
638653
- m4
639654
- mpdecimal
640655
- openssl
@@ -660,6 +675,7 @@ x86_64-unknown-linux-gnu:
660675
- bdb
661676
- binutils
662677
- bzip2
678+
- expat
663679
- gdbm
664680
- libedit
665681
- libffi
@@ -700,6 +716,7 @@ x86_64_v2-unknown-linux-gnu:
700716
- bdb
701717
- binutils
702718
- bzip2
719+
- expat
703720
- gdbm
704721
- libedit
705722
- libffi
@@ -740,6 +757,7 @@ x86_64_v3-unknown-linux-gnu:
740757
- bdb
741758
- binutils
742759
- bzip2
760+
- expat
743761
- gdbm
744762
- libedit
745763
- libffi
@@ -780,6 +798,7 @@ x86_64_v4-unknown-linux-gnu:
780798
- bdb
781799
- binutils
782800
- bzip2
801+
- expat
783802
- gdbm
784803
- libedit
785804
- libffi
@@ -819,6 +838,7 @@ x86_64-unknown-linux-musl:
819838
- bdb
820839
- binutils
821840
- bzip2
841+
- expat
822842
- gdbm
823843
- libedit
824844
- libffi
@@ -860,6 +880,7 @@ x86_64_v2-unknown-linux-musl:
860880
- bdb
861881
- binutils
862882
- bzip2
883+
- expat
863884
- gdbm
864885
- libedit
865886
- libffi
@@ -901,6 +922,7 @@ x86_64_v3-unknown-linux-musl:
901922
- bdb
902923
- binutils
903924
- bzip2
925+
- expat
904926
- gdbm
905927
- libedit
906928
- libffi
@@ -942,6 +964,7 @@ x86_64_v4-unknown-linux-musl:
942964
- bdb
943965
- binutils
944966
- bzip2
967+
- expat
945968
- gdbm
946969
- libedit
947970
- libffi

pythonbuild/downloads.py

+9
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@
6161
"license_file": "LICENSE.cpython.txt",
6262
"python_tag": "cp310",
6363
},
64+
"expat": {
65+
"url": "https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-2.5.0.tar.xz",
66+
"size": 460560,
67+
"sha256": "ef2420f0232c087801abf705e89ae65f6257df6b7931d37846a193ef2e8cdcbe",
68+
"version": "2.5.0",
69+
"library_names": ["expat"],
70+
"licenses": ["MIT"],
71+
"license_file": "LICENSE.expat.txt",
72+
},
6473
"gdbm": {
6574
"url": "https://ftp.gnu.org/gnu/gdbm/gdbm-1.21.tar.gz",
6675
"size": 1005982,

0 commit comments

Comments
 (0)