Skip to content

Commit 8cea424

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

2 files changed

Lines changed: 123 additions & 0 deletions

File tree

build.sh

Lines changed: 41 additions & 0 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'
@@ -280,6 +283,25 @@ if ! [ -f "${binutils_tarball}" ]; then
280283
patch --directory="${binutils_directory}" --strip='1' --input="${workdir}/patches/0001-Don-t-warn-about-local-symbols-within-the-globals.patch"
281284
fi
282285

286+
if ! [ -f "${zlib_tarball}" ]; then
287+
curl \
288+
--url 'https://github.com/madler/zlib/archive/refs/heads/develop.tar.gz' \
289+
--retry '30' \
290+
--retry-all-errors \
291+
--retry-delay '0' \
292+
--retry-max-time '0' \
293+
--location \
294+
--silent \
295+
--output "${zlib_tarball}"
296+
297+
tar \
298+
--directory="$(dirname "${zlib_directory}")" \
299+
--extract \
300+
--file="${zlib_tarball}"
301+
302+
patch --directory="${zlib_directory}" --strip='1' --input="${workdir}/patches/0001-Remove-versioned-SONAME-from-libz.patch"
303+
fi
304+
283305
if ! [ -f "${zstd_tarball}" ]; then
284306
curl \
285307
--url 'https://github.com/facebook/zstd/archive/refs/heads/dev.tar.gz' \
@@ -423,6 +445,23 @@ rm --force --recursive ./*
423445
make all --jobs
424446
make install
425447

448+
[ -d "${zlib_directory}/build" ] || mkdir "${zlib_directory}/build"
449+
450+
cd "${zlib_directory}/build"
451+
rm --force --recursive ./*
452+
453+
../configure \
454+
--host="${CROSS_COMPILE_TRIPLET}" \
455+
--prefix="${toolchain_directory}" \
456+
CFLAGS="${ccflags}" \
457+
CXXFLAGS="${ccflags}" \
458+
LDFLAGS="${linkflags}"
459+
460+
make all --jobs
461+
make install
462+
463+
unlink "${toolchain_directory}/lib/libz.a"
464+
426465
[ -d "${zstd_directory}/.build" ] || mkdir "${zstd_directory}/.build"
427466

428467
cd "${zstd_directory}/.build"
@@ -522,6 +561,7 @@ for target in "${targets[@]}"; do
522561
--with-sysroot="${toolchain_directory}/${triplet}" \
523562
--without-static-standard-libraries \
524563
--with-zstd="${toolchain_directory}" \
564+
--with-system-zlib \
525565
CFLAGS="${ccflags}" \
526566
CXXFLAGS="${ccflags}" \
527567
LDFLAGS="${linkflags}"
@@ -558,6 +598,7 @@ for target in "${targets[@]}"; do
558598
--with-mpfr="${toolchain_directory}" \
559599
--with-isl="${toolchain_directory}" \
560600
--with-zstd="${toolchain_directory}" \
601+
--with-system-zlib \
561602
--with-bugurl='https://github.com/AmanoTeam/obggcc/issues' \
562603
--with-gcc-major-version-only \
563604
--with-pkgversion="OBGGCC v3.5-${revision}" \
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)