external/freetype: Avoid duplicate zlib symbols

After 7229a380d3 "Update freetype to 2.12.0", my
--without-system-freetype --without-system-zlib Linux build started to fail to
link Library_skia with

> ld.lld: error: duplicate symbol: zlibVersion
> >>> defined at zutil.c:28 (workdir/UnpackedTarball/zlib/zutil.c:28)
> >>>            zutil.o:(zlibVersion) in archive core/workdir/LinkTarget/StaticLibrary/libzlib.a
> >>> defined at zutil.c:28 (src/gzip/zutil.c:28)
> >>>            ftgzip.o:(.text+0x0) in archive workdir/UnpackedTarball/freetype/instdir/lib/libfreetype.a

etc. because both those non-system libraries are provided as static archives.

There is also provisioning for symbol renaming in
workdir/UnpackedTarball/freetype/src/gzip/ftzconf.h via -DZ_PREFIX, so enable
that.  But three symbols were missing and would still produce linker failures,
so add them with external/freetype/zlib-duplicates.patch.

Change-Id: Ibe876d4e38e3e44ce00c64fb70c88fb0b1e3a910
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142788
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann 2022-11-16 18:11:18 +01:00
parent c81d66e96c
commit e515267602
3 changed files with 24 additions and 0 deletions

View file

@ -30,6 +30,7 @@ $(call gb_ExternalProject_get_state_target,freetype,build) :
$(call gb_ExternalProject_get_build_flags,freetype) \
$(gb_VISIBILITY_FLAGS) \
$(gb_EMSCRIPTEN_CPPFLAGS)" \
CPPFLAGS='$(CPPFLAGS) -DZ_PREFIX' \
LDFLAGS="$(call gb_ExternalProject_get_link_flags,freetype)" \
&& $(MAKE) install \
&& touch $@ )

View file

@ -14,6 +14,7 @@ $(eval $(call gb_UnpackedTarball_set_tarball,freetype,$(FREETYPE_TARBALL),,freet
$(eval $(call gb_UnpackedTarball_add_patches,freetype,\
external/freetype/freetype-2.6.5.patch.1 \
external/freetype/ubsan.patch \
external/freetype/zlib-duplicates.patch \
))
$(eval $(call gb_UnpackedTarball_set_patchlevel,freetype,0))

22
external/freetype/zlib-duplicates.patch vendored Normal file
View file

@ -0,0 +1,22 @@
--- src/gzip/ftzconf.h
+++ src/gzip/ftzconf.h
@@ -130,10 +130,8 @@
# define uncompress2 z_uncompress2
# endif
# define zError z_zError
-# ifndef Z_SOLO
# define zcalloc z_zcalloc
# define zcfree z_zcfree
-# endif
# define zlibCompileFlags z_zlibCompileFlags
# define zlibVersion z_zlibVersion
@@ -163,6 +161,8 @@
# define gz_header_s z_gz_header_s
# define internal_state z_internal_state
+#define z_errmsg z_z_errmsg
+
#endif
#if defined(__MSDOS__) && !defined(MSDOS)