office-gobmx/m4/libo_externals.m4
Michael Stahl 0028266e34 configure: default to --with-system-nss on Linux
NSS is very ABI compatible and part of current LSB 5.0 and so it should
just work to use the one from the system, i'm not aware of a Linux that
doesn't ship it.

There used to be some feature patch in external/nss but this was removed
years ago, now it just contains build fixes.

Problems can occur if a mixture of system and bundled NSS libraries is
loaded, if first an old version .so is loaded and then newer version .so
depends on it but can't find some required symbol.

See for example:
https://www.mail-archive.com/libreoffice@lists.freedesktop.org/msg287043.html

Another issue is that e.g. Fedora ships libnsspem.so in the nss-pem
package, which may cause trouble in ASAN builds, where the internal NSS
is built to call __asan_poison_memory_region but the system
libnss-pem.so doesn't call __asan_unpoison_memory_region so we get:

  ==2568944==ERROR: AddressSanitizer: use-after-poison on address 0x61d0019afab0
  WRITE of size 192 at 0x61d0019afab0 thread T28 (utl::Moderator)
    0 in __interceptor_memset.part.0 (instdir/program/soffice.bin+0x466460)
    1  (/lib64/libnsspem.so+0x15f3d)
    2  (/lib64/libnsspem.so+0x16185)
    3  (/lib64/libnsspem.so+0x8a9b)
    4  (/lib64/libnsspem.so+0xe13b)
    5 in secmod_ModuleInit workdir/UnpackedTarball/nss/nss/lib/pk11wrap/pk11load.c:244:11
    ..
    21 in curl_easy_perform workdir/UnpackedTarball/curl/lib/easy.c:715:10

Also, with system NSS, things like p11-kit integration become
responsibility of the OS.

Change-Id: I50caedd46914dd5d6905c5d32d44a599cd78119e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120388
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-04-29 20:24:58 +02:00

133 lines
4.7 KiB
Text

dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; fill-column: 102 -*-
#
# 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/.
#
# <$1 lowercase variable part - used for variables and configure switches>
# <$2 uppercase variable part - used for configure.ac and make variables>
# <$3 pkg-config query string>
# [$4 if optional, default to: enabled, disabled or fixed (default: fixed)]
# [$5 which is preferred: (fixed-|test-)system or (fixed-)internal or system-if-linux (default: internal)]
# [$6 ignore $with_system_libs: TRUE or blank (default: blank/false)]
#
# $4 fixed: fixed-enabled, as fixed-disabled makes no sense.
# $5 test-system: follows $test_system_$1, ignores $with_system_libs; no configure switch
#
# Used configure.ac variables:
# - $2_(CFLAGS|LIBS)_internal: must be filled to match the internal build
# - enable_$1: should normally not be set manually; use test_$1 instead
# - found_$1: other tests already provided external $2_CFLAGS and $2_LIBS
# - test_$1: set to no, if the feature shouldn't be tested at all
# - test_system_$1: set to no, if the system library should not be used
#
# There is currently the AC_SUBST redundancy of
# (SYSTEM_$2,TRUE) == (,$(filter $2,$(BUILD_TYPE)))
#
m4_define([csm_default_with], [
if test "${with_system_$1+set}" != set -a "${with_system_libs+set}" = set -a "$3" != TRUE; then
with_system_$1="$with_system_libs";
else
with_system_$1="$2"
fi
])
m4_define([csm_check_required], [
m4_ifblank([$2],[m4_fatal([$][$1 ($2) must not be blank and $4])])
m4_if([$2],[$3],,[m4_fatal([$][$1 ($2) $3 must be $4])])
])
AC_DEFUN([libo_CHECK_SYSTEM_MODULE], [
# validate arguments as possible
csm_check_required([1],[$1],m4_tolower([$1]),[lowercase])
csm_check_required([2],[$2],m4_toupper([$2]),[uppercase])
m4_ifblank([$3],[m4_fatal([$][3 is the pkg-config query and must not be blank])])
m4_if([$6],[TRUE],[],[m4_ifnblank([$6],[m4_fatal([$][6 must be TRUE or blank])])])
m4_if(
[$4],[enabled],[
AC_ARG_ENABLE([$1],
AS_HELP_STRING([--disable-$1],[Disable $1 support.]),
,[enable_$1="yes"])
],[$4],[disabled],[
AC_ARG_ENABLE([$1],
AS_HELP_STRING([--enable-$1],[Enable $1 support.]),
,[enable_$1="no"])
],[
m4_if([$4],[fixed],,[m4_ifnblank([$4],
[m4_fatal([$$4 ($4) must be "enabled", "disabled", "fixed" or empty (=fixed)])])])
enable_$1="yes";
])
m4_if(
[$5],[system],[
AC_ARG_WITH(system-$1,
AS_HELP_STRING([--without-system-$1],[Build and bundle the internal $1.]),
,[csm_default_with($1,yes,$6)])
],[$5],[test-system],[
with_system_$1="$test_system_$1"
],[$5],[fixed-system],[
with_system_$1=yes
],[$5],[fixed-internal],[
with_system_$1=no
],[$5],[system-if-linux],[
AC_ARG_WITH(system-$1,
AS_HELP_STRING([--with-system-$1],[Use $1 from the operating system.]),
,[case "$_os" in
Linux)
with_system_nss=yes
;;
*)
with_system_nss=no
;;
esac])
],[
m4_if([$5],[internal],,[m4_ifnblank([$5],
[m4_fatal([$$5 ($5) must be "(fixed-|test-)system", "(fixed-)internal", "system-if-linux" or empty (=internal)])])])
AC_ARG_WITH(system-$1,
AS_HELP_STRING([--with-system-$1],[Use $1 from the operating system.]),
,[csm_default_with($1,no,$6)])
])
AC_MSG_CHECKING([which $1 to use])
if test "$test_$1" != no -a "$found_$1" != yes -a "$enable_$1" != no; then
ENABLE_$2=TRUE
if test "$with_system_$1" = yes -a "$test_system_$1" != no; then
AC_MSG_RESULT([external])
SYSTEM_$2=TRUE
PKG_CHECK_MODULES([$2], [$3])
$2_CFLAGS=$(printf '%s' "${$2_CFLAGS}" | sed -e "s/-I/${ISYSTEM?}/g")
FilterLibs "${$2_LIBS}"
$2_LIBS="$filteredlibs"
else
AC_MSG_RESULT([internal])
SYSTEM_$2=
$2_CFLAGS="${$2_CFLAGS_internal}"
$2_LIBS="${$2_LIBS_internal}"
BUILD_TYPE="$BUILD_TYPE $2"
fi
else
if test "$found_$1" = yes -a "$enable_$1" != no -a "$with_system_$1" = yes; then
AC_MSG_RESULT([external])
ENABLE_$2=TRUE
SYSTEM_$2=TRUE
else
ENABLE_$2=
SYSTEM_$2=
$2_CFLAGS=
$2_LIBS=
if test "$test_$1" != no -a "$enable_$1" = no; then
AC_MSG_RESULT([disabled])
else
AC_MSG_RESULT([not tested])
fi
fi
fi
AC_SUBST([ENABLE_$2])
AC_SUBST([SYSTEM_$2])
AC_SUBST([$2_CFLAGS])
AC_SUBST([$2_LIBS])
])
dnl vim:set shiftwidth=4 softtabstop=4 expandtab: