mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
meson: add linker checks
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Neal Gompa <ngompa13@gmail.com>
This commit is contained in:
parent
c9d0ef07ed
commit
30b301c6ea
41
configure.ac
41
configure.ac
@ -64,43 +64,6 @@ m4_ifndef([LT_INIT], [
|
||||
AM_PROG_CC_C_O
|
||||
AM_PROG_LD
|
||||
|
||||
AC_MSG_CHECKING([for how to mark DSO non-deletable at runtime])
|
||||
LIBVIRT_NODELETE=
|
||||
`$LD --help 2>&1 | grep -- "-z nodelete" >/dev/null` && \
|
||||
LIBVIRT_NODELETE="-Wl,-z -Wl,nodelete"
|
||||
AC_MSG_RESULT([$LIBVIRT_NODELETE])
|
||||
AC_SUBST([LIBVIRT_NODELETE])
|
||||
|
||||
AC_MSG_CHECKING([for how to set DSO symbol versions])
|
||||
case "$host" in
|
||||
*-*-mingw* | *-*-msvc* )
|
||||
# mingw's ld has the --version-script parameter, but it requires a .def file
|
||||
# instead to work properly, therefore clear --version-script here and use
|
||||
# -Wl, to pass the .def file to the linker
|
||||
VERSION_SCRIPT_FLAGS="-Wl,"
|
||||
;;
|
||||
* )
|
||||
VERSION_SCRIPT_FLAGS=-Wl,--version-script=
|
||||
`$LD --help 2>&1 | grep -- --version-script >/dev/null` || \
|
||||
VERSION_SCRIPT_FLAGS="-Wl,-M -Wl,"
|
||||
;;
|
||||
esac
|
||||
AC_MSG_RESULT([$VERSION_SCRIPT_FLAGS])
|
||||
AC_SUBST([VERSION_SCRIPT_FLAGS])
|
||||
|
||||
dnl macOS has two-level namespaces by default.
|
||||
dnl Override it to allow symbol replacement with DYLD_INSERT_LIBRARIES
|
||||
case "$host" in
|
||||
*-*-darwin*)
|
||||
FLAT_NAMESPACE_FLAGS=-Wl,-flat_namespace
|
||||
;;
|
||||
* )
|
||||
FLAT_NAMESPACE_FLAGS=""
|
||||
;;
|
||||
esac
|
||||
AC_MSG_RESULT([$FLAT_NAMESPACE_FLAGS])
|
||||
AC_SUBST([FLAT_NAMESPACE_FLAGS])
|
||||
|
||||
dnl Specify if we rely on ifconfig instead of iproute2 (e.g. in case
|
||||
dnl we're working on BSD)
|
||||
want_ifconfig=no
|
||||
@ -161,10 +124,6 @@ fi
|
||||
|
||||
# Check for compiler and library settings.
|
||||
|
||||
LIBVIRT_LINKER_RELRO
|
||||
LIBVIRT_LINKER_NO_INDIRECT
|
||||
LIBVIRT_LINKER_NO_UNDEFINED
|
||||
|
||||
LIBVIRT_ARG_APPARMOR
|
||||
LIBVIRT_ARG_ATTR
|
||||
LIBVIRT_ARG_AUDIT
|
||||
|
@ -1,32 +0,0 @@
|
||||
dnl
|
||||
dnl Check for --no-copy-dt-needed-entries
|
||||
dnl
|
||||
dnl Copyright (C) 2013 Guido Günther <agx@sigxcpu.org>
|
||||
dnl
|
||||
dnl This library is free software; you can redistribute it and/or
|
||||
dnl modify it under the terms of the GNU Lesser General Public
|
||||
dnl License as published by the Free Software Foundation; either
|
||||
dnl version 2.1 of the License, or (at your option) any later version.
|
||||
dnl
|
||||
dnl This library is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
dnl Lesser General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU Lesser General Public
|
||||
dnl License along with this library. If not, see
|
||||
dnl <http://www.gnu.org/licenses/>.
|
||||
dnl
|
||||
|
||||
AC_DEFUN([LIBVIRT_LINKER_NO_INDIRECT],[
|
||||
AC_MSG_CHECKING([for how to avoid indirect lib deps])
|
||||
|
||||
NO_INDIRECT_LDFLAGS=
|
||||
case `$LD --help 2>&1` in
|
||||
*"--no-copy-dt-needed-entries"*)
|
||||
NO_INDIRECT_LDFLAGS="-Wl,--no-copy-dt-needed-entries" ;;
|
||||
esac
|
||||
AC_SUBST([NO_INDIRECT_LDFLAGS])
|
||||
|
||||
AC_MSG_RESULT([$NO_INDIRECT_LDFLAGS])
|
||||
])
|
@ -1,32 +0,0 @@
|
||||
dnl
|
||||
dnl Check for -z defs linker flag
|
||||
dnl
|
||||
dnl Copyright (C) 2013-2018 Red Hat, Inc.
|
||||
dnl
|
||||
dnl This library is free software; you can redistribute it and/or
|
||||
dnl modify it under the terms of the GNU Lesser General Public
|
||||
dnl License as published by the Free Software Foundation; either
|
||||
dnl version 2.1 of the License, or (at your option) any later version.
|
||||
dnl
|
||||
dnl This library is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
dnl Lesser General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU Lesser General Public
|
||||
dnl License along with this library. If not, see
|
||||
dnl <http://www.gnu.org/licenses/>.
|
||||
dnl
|
||||
|
||||
AC_DEFUN([LIBVIRT_LINKER_NO_UNDEFINED],[
|
||||
AC_MSG_CHECKING([for how to stop undefined symbols at link time])
|
||||
|
||||
NO_UNDEFINED_LDFLAGS=
|
||||
ld_help=`$LD --help 2>&1`
|
||||
case $ld_help in
|
||||
*"-z defs"*) NO_UNDEFINED_LDFLAGS="-Wl,-z -Wl,defs" ;;
|
||||
esac
|
||||
AC_SUBST([NO_UNDEFINED_LDFLAGS])
|
||||
|
||||
AC_MSG_RESULT([$NO_UNDEFINED_LDFLAGS])
|
||||
])
|
@ -1,35 +0,0 @@
|
||||
dnl
|
||||
dnl Check for -z now and -z relro linker flags
|
||||
dnl
|
||||
dnl Copyright (C) 2013 Red Hat, Inc.
|
||||
dnl
|
||||
dnl This library is free software; you can redistribute it and/or
|
||||
dnl modify it under the terms of the GNU Lesser General Public
|
||||
dnl License as published by the Free Software Foundation; either
|
||||
dnl version 2.1 of the License, or (at your option) any later version.
|
||||
dnl
|
||||
dnl This library is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
dnl Lesser General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU Lesser General Public
|
||||
dnl License along with this library. If not, see
|
||||
dnl <http://www.gnu.org/licenses/>.
|
||||
dnl
|
||||
|
||||
AC_DEFUN([LIBVIRT_LINKER_RELRO],[
|
||||
AC_MSG_CHECKING([for how to force completely read-only GOT table])
|
||||
|
||||
RELRO_LDFLAGS=
|
||||
ld_help=`$LD --help 2>&1`
|
||||
case $ld_help in
|
||||
*"-z relro"*) RELRO_LDFLAGS="-Wl,-z -Wl,relro" ;;
|
||||
esac
|
||||
case $ld_help in
|
||||
*"-z now"*) RELRO_LDFLAGS="$RELRO_LDFLAGS -Wl,-z -Wl,now" ;;
|
||||
esac
|
||||
AC_SUBST([RELRO_LDFLAGS])
|
||||
|
||||
AC_MSG_RESULT([$RELRO_LDFLAGS])
|
||||
])
|
43
meson.build
43
meson.build
@ -587,6 +587,49 @@ cc_flags_relaxed_frame_limit = [
|
||||
]
|
||||
|
||||
|
||||
# various linker checks
|
||||
|
||||
libvirt_relro = cc.get_supported_link_arguments([
|
||||
'-Wl,-z,relro',
|
||||
'-Wl,-z,now',
|
||||
])
|
||||
|
||||
libvirt_nodelete = cc.get_supported_link_arguments([
|
||||
'-Wl,-z,nodelete',
|
||||
])
|
||||
|
||||
libvirt_no_undefined = cc.get_supported_link_arguments([
|
||||
'-Wl,-z,defs',
|
||||
])
|
||||
|
||||
libvirt_no_indirect = cc.get_supported_link_arguments([
|
||||
'-Wl,--no-copy-dt-needed-entries',
|
||||
])
|
||||
|
||||
if host_machine.system() == 'windows'
|
||||
version_script_flags = '-Wl,'
|
||||
else
|
||||
test_file = '@0@/src/libvirt_qemu.syms'.format(meson.source_root())
|
||||
if cc.has_link_argument('-Wl,--version-script=@0@'.format(test_file))
|
||||
version_script_flags = '-Wl,--version-script='
|
||||
elif cc.has_link_argument('-Wl,-M,')
|
||||
version_script_flags = '-Wl,-M,'
|
||||
else
|
||||
error('No supported version script link argument found.')
|
||||
endif
|
||||
endif
|
||||
|
||||
libvirt_flat_namespace = []
|
||||
if host_machine.system() == 'darwin'
|
||||
libvirt_flat_namespace = '-Wl,-flat_namespace'
|
||||
endif
|
||||
|
||||
libvirt_export_dynamic = cc.first_supported_link_argument([
|
||||
'-Wl,-export-dynamic',
|
||||
'-Wl,-export_dynamic',
|
||||
])
|
||||
|
||||
|
||||
# define top include directory
|
||||
|
||||
top_inc_dir = include_directories('.')
|
||||
|
Loading…
Reference in New Issue
Block a user