Skip to content

Commit 7c9cc7c

Browse files
committed
Switch to the git version of the zlib library
1 parent 462d4f4 commit 7c9cc7c

2 files changed

Lines changed: 137 additions & 9 deletions

File tree

build.sh

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ declare nz_directory=""
4545
declare -r zstd_tarball='/tmp/zstd.tar.gz'
4646
declare -r zstd_directory='/tmp/zstd-dev'
4747

48+
declare -r zlib_tarball='/tmp/zlib.tar.gz'
49+
declare -r zlib_directory='/tmp/zlib-develop'
50+
4851
declare -r pieflags='-fPIE'
4952
declare -r ccflags='-w -O2'
5053
declare -r linkflags='-Xlinker -s'
@@ -136,16 +139,19 @@ declare -ra deprecated_targets=(
136139

137140
declare -ra targets=(
138141
'x86_64-unknown-linux-gnu'
139-
'aarch64-unknown-linux-gnu'
140-
'arm-unknown-linux-gnueabi'
141-
'arm-unknown-linux-gnueabihf'
142-
'i386-unknown-linux-gnu'
142+
# 'aarch64-unknown-linux-gnu'
143+
# 'arm-unknown-linux-gnueabi'
144+
# 'arm-unknown-linux-gnueabihf'
145+
# 'i386-unknown-linux-gnu'
143146
)
144147

145148
declare -r PKG_CONFIG_PATH="${toolchain_directory}/lib/pkgconfig"
146149
declare -r PKG_CONFIG_LIBDIR="${PKG_CONFIG_PATH}"
147150
declare -r PKG_CONFIG_SYSROOT_DIR="${toolchain_directory}"
148151

152+
declare -r zlibdir="-I${toolchain_directory}/include"
153+
declare -r zlibinc="-L${toolchain_directory}/lib"
154+
149155
declare -r pkg_cv_ZSTD_CFLAGS="-I${toolchain_directory}/include"
150156
declare -r pkg_cv_ZSTD_LIBS="-L${toolchain_directory}/lib -lzstd"
151157
declare -r ZSTD_CFLAGS="-I${toolchain_directory}/include"
@@ -158,7 +164,9 @@ export \
158164
pkg_cv_ZSTD_CFLAGS \
159165
pkg_cv_ZSTD_LIBS \
160166
ZSTD_CFLAGS \
161-
ZSTD_LIBS
167+
ZSTD_LIBS \
168+
zlibdir \
169+
zlibinc
162170

163171
declare build_type="${1}"
164172

@@ -280,6 +288,25 @@ if ! [ -f "${binutils_tarball}" ]; then
280288
patch --directory="${binutils_directory}" --strip='1' --input="${workdir}/patches/0001-Don-t-warn-about-local-symbols-within-the-globals.patch"
281289
fi
282290

291+
if ! [ -f "${zlib_tarball}" ]; then
292+
curl \
293+
--url 'https://github.com/madler/zlib/archive/refs/heads/develop.tar.gz' \
294+
--retry '30' \
295+
--retry-all-errors \
296+
--retry-delay '0' \
297+
--retry-max-time '0' \
298+
--location \
299+
--silent \
300+
--output "${zlib_tarball}"
301+
302+
tar \
303+
--directory="$(dirname "${zlib_directory}")" \
304+
--extract \
305+
--file="${zlib_tarball}"
306+
307+
patch --directory="${zlib_directory}" --strip='1' --input="${workdir}/patches/0001-Remove-versioned-SONAME-from-libz.patch"
308+
fi
309+
283310
if ! [ -f "${zstd_tarball}" ]; then
284311
curl \
285312
--url 'https://github.com/facebook/zstd/archive/refs/heads/dev.tar.gz' \
@@ -423,6 +450,23 @@ rm --force --recursive ./*
423450
make all --jobs
424451
make install
425452

453+
[ -d "${zlib_directory}/build" ] || mkdir "${zlib_directory}/build"
454+
455+
cd "${zlib_directory}/build"
456+
rm --force --recursive ./*
457+
458+
../configure \
459+
--host="${CROSS_COMPILE_TRIPLET}" \
460+
--prefix="${toolchain_directory}" \
461+
CFLAGS="${ccflags}" \
462+
CXXFLAGS="${ccflags}" \
463+
LDFLAGS="${linkflags}"
464+
465+
make all --jobs
466+
make install
467+
468+
unlink "${toolchain_directory}/lib/libz.a"
469+
426470
[ -d "${zstd_directory}/.build" ] || mkdir "${zstd_directory}/.build"
427471

428472
cd "${zstd_directory}/.build"
@@ -522,9 +566,10 @@ for target in "${targets[@]}"; do
522566
--with-sysroot="${toolchain_directory}/${triplet}" \
523567
--without-static-standard-libraries \
524568
--with-zstd="${toolchain_directory}" \
525-
CFLAGS="${ccflags}" \
526-
CXXFLAGS="${ccflags}" \
527-
LDFLAGS="${linkflags}"
569+
--with-system-zlib \
570+
CFLAGS="-I${toolchain_directory}/include ${ccflags}" \
571+
CXXFLAGS="-I${toolchain_directory}/include ${ccflags}" \
572+
LDFLAGS="-L${toolchain_directory}/lib ${linkflags}"
528573

529574
make all --jobs
530575
make install
@@ -558,6 +603,7 @@ for target in "${targets[@]}"; do
558603
--with-mpfr="${toolchain_directory}" \
559604
--with-isl="${toolchain_directory}" \
560605
--with-zstd="${toolchain_directory}" \
606+
--with-system-zlib \
561607
--with-bugurl='https://github.com/AmanoTeam/obggcc/issues' \
562608
--with-gcc-major-version-only \
563609
--with-pkgversion="OBGGCC v3.5-${revision}" \
@@ -605,7 +651,7 @@ for target in "${targets[@]}"; do
605651
${extra_configure_flags} \
606652
CFLAGS="${ccflags}" \
607653
CXXFLAGS="${ccflags}" \
608-
LDFLAGS="${linkflags}"
654+
LDFLAGS="-L${toolchain_directory}/lib ${linkflags}"
609655

610656
cflags_for_target="${ccflags} ${linkflags}"
611657
cxxflags_for_target="${ccflags} ${linkflags}"
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
From 8a752e79b399219fc50392b39b785b81b2729c33 Mon Sep 17 00:00:00 2001
2+
From: Your Name <you@example.com>
3+
Date: Sat, 23 Aug 2025 22:20:55 +0000
4+
Subject: [PATCH] Remove versioned SONAME from libz
5+
6+
---
7+
Makefile.in | 6 ------
8+
configure | 15 ++++++++-------
9+
2 files changed, 8 insertions(+), 13 deletions(-)
10+
11+
diff --git a/Makefile.in b/Makefile.in
12+
index 7010b25..bf8efd2 100644
13+
--- a/Makefile.in
14+
+++ b/Makefile.in
15+
@@ -282,9 +282,6 @@ gzwrite.lo: $(SRCDIR)gzwrite.c
16+
17+
placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
18+
$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
19+
- rm -f $(SHAREDLIB) $(SHAREDLIBM)
20+
- ln -s $@ $(SHAREDLIB)
21+
- ln -s $@ $(SHAREDLIBM)
22+
-@rmdir objs
23+
24+
example$(EXE): example.o $(STATICLIB)
25+
@@ -321,9 +318,6 @@ install-libs: $(LIBS)
26+
echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \
27+
chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
28+
echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \
29+
- rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
30+
- ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \
31+
- ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
32+
($(LDCONFIG) || true) >/dev/null 2>&1; \
33+
fi
34+
rm -f $(DESTDIR)$(man3dir)/zlib.3
35+
diff --git a/configure b/configure
36+
index 1834659..3c52977 100755
37+
--- a/configure
38+
+++ b/configure
39+
@@ -267,9 +267,9 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
40+
*sparc*)
41+
LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;;
42+
esac
43+
- LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
44+
+ LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so"} ;;
45+
*BSD | *bsd* | DragonFly)
46+
- LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
47+
+ LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so"}
48+
LDCONFIG="ldconfig -m" ;;
49+
CYGWIN* | Cygwin* | cygwin* | *-cygwin* | OS/2*)
50+
EXE='.exe' ;;
51+
@@ -298,9 +298,9 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
52+
Darwin* | darwin* | *-darwin*)
53+
shared_ext='.dylib'
54+
SHAREDLIB=libz$shared_ext
55+
- SHAREDLIBV=libz.$VER$shared_ext
56+
- SHAREDLIBM=libz.$VER1$shared_ext
57+
- LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
58+
+ SHAREDLIBV=libz.$shared_ext
59+
+ SHAREDLIBM=libz.$shared_ext
60+
+ LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM"}
61+
if "${CROSS_PREFIX}libtool" -V 2>&1 | grep Apple > /dev/null; then
62+
AR="${CROSS_PREFIX}libtool"
63+
elif libtool -V 2>&1 | grep Apple > /dev/null; then
64+
@@ -409,8 +409,8 @@ fi
65+
66+
# destination names for shared library if not defined above
67+
SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
68+
-SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
69+
-SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
70+
+SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext"}
71+
+SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext"}
72+
73+
echo >> configure.log
74+
75+
@@ -964,3 +964,4 @@ s/\@VERSION\@/$VER/g;
76+
77+
# done
78+
leave 0
79+
+
80+
--
81+
2.25.1
82+

0 commit comments

Comments
 (0)