office-gobmx/external/poppler/UnpackedTarball_poppler.mk
Stephan Bergmann c36fa9f86e external/poppler: Avoid missing typeinfo in UBSan builds
After 03bc0f9720 "poppler: upgrade to release
21.11.0", my Linux Clang UBSan build started to fail to link
Executable_xpdfimport with

> ld.lld: error: undefined symbol: SplashOutputDev::SplashOutputDev(SplashColorMode, int, bool, unsigned char*, bool, SplashThinLineMode, bool)
> >>> referenced by PSOutputDev.cc:3197 (workdir/UnpackedTarball/poppler/poppler/PSOutputDev.cc:3197)
> >>>               PSOutputDev.o:(PSOutputDev::checkPageSlice(Page*, double, double, int, bool, bool, int, int, int, int, bool, bool (*)(void*), void*, bool (*)(Annot*, void*), void*)) in archive workdir/LinkTarget/StaticLibrary/libpoppler.a
>
> ld.lld: error: undefined symbol: SplashOutputDev::startDoc(PDFDoc*)
> >>> referenced by PSOutputDev.cc:3206 (workdir/UnpackedTarball/poppler/poppler/PSOutputDev.cc:3206)
> >>>               PSOutputDev.o:(PSOutputDev::checkPageSlice(Page*, double, double, int, bool, bool, int, int, int, int, bool, bool (*)(void*), void*, bool (*)(Annot*, void*), void*)) in archive workdir/LinkTarget/StaticLibrary/libpoppler.a
>
> ld.lld: error: undefined symbol: typeinfo for SplashOutputDev
> >>> referenced by PSOutputDev.cc
> >>>               PSOutputDev.o:(.data+0x16208) in archive workdir/LinkTarget/StaticLibrary/libpoppler.a
> >>> referenced by PSOutputDev.cc
> >>>               PSOutputDev.o:(.data+0x162A8) in archive workdir/LinkTarget/StaticLibrary/libpoppler.a
> >>> referenced by PSOutputDev.cc
> >>>               PSOutputDev.o:(.data+0x16348) in archive workdir/LinkTarget/StaticLibrary/libpoppler.a
> >>> referenced 6 more times

because external/poppler/StaticLibrary_poppler.mk apparently only builds a
curated subset of poppler source files, but in a UBSan build the implementation
of

  GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps)

in workdir/UnpackedTarball/poppler/poppler/GfxFont.cc (being the only place in
Executable_xpdfimport that mentions PSOutputDev, i.e., which is
apparently never instantiated in Executable_xpdfimport, and that ps argument is
apparently always null) needs the PSOutputDev typeinfo, thus pulling in
PSOutputDev.o from StaticLibrary_poppler (which contains the virtual PSOutputDev
dtor and thus its typeinfo), which in turn needs the SplashOutputDev ctor and
SplashOutputDev::startDoc from within PSOutputDev::checkPageSlice.

The obvious fix would be to extend the curated list of source files to
include the missing SplashOutputDev symbols, and any symbols recursively needed
by those, but that would quickly lead to inclusion of
workdir/UnpackedTarball/poppler/splash/SplashFontEngine.cc which would fail to
compile due to a missing

  #include <ft2build.h>

from FreeType.  So instead of going down that road of adding in ever more stuff,
lets try to leave out the problematic definition of
PSOutputDev::checkPageSlice (which is apparently never called anyway, see
above).  But leaving that virtual function out completely would cause missing
symbols in the PSOutputDev vtable emitted alongside the PSOputput dtor, but also
leaving out that dtor (which is apparently never called anyway, either) would
then suppress emission of the PSOutputDev typeinfo, which started this whole
exercise.

So, just for the UBSan builds, define PSOutputDev::checkPageSlice (never called
anyway, see above) with an empty body, as the least invasive approach to avoid
the missing typeinfo symbol.

Change-Id: Ifcb80501b71f22d8f14ee29fd8e4480871ee36d1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125071
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-11-11 22:36:31 +01:00

27 lines
829 B
Makefile

# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_UnpackedTarball_UnpackedTarball,poppler))
$(eval $(call gb_UnpackedTarball_set_tarball,poppler,$(POPPLER_TARBALL),,poppler))
$(eval $(call gb_UnpackedTarball_set_patchlevel,poppler,0))
$(eval $(call gb_UnpackedTarball_add_patches,poppler,\
external/poppler/poppler-config.patch.1 \
external/poppler/pch.patch.0 \
))
ifneq ($(filter -fsanitize=%,$(CC)),)
$(eval $(call gb_UnpackedTarball_add_patches,poppler, \
external/poppler/sanitizer.patch \
))
endif
# vim: set noet sw=4 ts=4: