From nobody Mon Feb 9 07:57:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594893735; cv=none; d=zohomail.com; s=zohoarc; b=mHE8Xf86fcRtqcio3KYxixF8Lfw8OjWRv2QyTtHQvtQZtfSHNygmNjf8U3lwZaGSBDIBTSUwohl+wb1RH+frbHiO2NXn8ZvxOKKZHQjkTOWouCNPXTGUyjLT8BU8El9MVdRg9fGXAwbuJRmU82jOIIU8KBC16LC6YaMDjkpUUBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594893735; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CLhrvt/iXWa1p7cN9NTPYnD1ZnHofNalHP1D0y6diQY=; b=S1HLWyu9nIV8Glqigc8eUanYwc6Ru3ahbikn3JYQSbjUKx2CQUds+7PUYYYfZdpwoPefi9nEuea06UfrRf4a6lemGhNo4+/GI6aKzDbEZffGSXnc9zRW0Qp6A5zT999UuMoBSEsPPUJSoNWUSIQC3AchaOlcJ247vgOgiKw0UEM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594893735006579.0582727079404; Thu, 16 Jul 2020 03:02:15 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-183-WxzEtopzMgCeLHd0__8SbQ-1; Thu, 16 Jul 2020 06:00:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9417910059C2; Thu, 16 Jul 2020 10:00:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 707C078490; Thu, 16 Jul 2020 10:00:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 39554180531D; Thu, 16 Jul 2020 10:00:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06GA0eRQ015407 for ; Thu, 16 Jul 2020 06:00:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id BDA942DE69; Thu, 16 Jul 2020 10:00:40 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36CB92B6E2 for ; Thu, 16 Jul 2020 10:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594893733; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=CLhrvt/iXWa1p7cN9NTPYnD1ZnHofNalHP1D0y6diQY=; b=BUKraOHoAYdNhTxNbFeqmWkR8PLrr2Zqyjm+BzMlRs3wyBFJaJocIQ85BDTQUlCC+eWLfo +GDovKI7gvfT4BIWnvoYc/A7OWsDHJBfyvSS58HXOsHZ74kTQQ8sfPCTLRnuN2uaUjHGYu aFNOYJNxubn1RObIdkDoTP0SMHDq3Ss= X-MC-Unique: WxzEtopzMgCeLHd0__8SbQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 022/351] meson: add linker checks Date: Thu, 16 Jul 2020 11:54:18 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Pavel Hrdina --- configure.ac | 41 -------------------------------- m4/virt-linker-no-indirect.m4 | 32 ------------------------- m4/virt-linker-no-undefined.m4 | 32 ------------------------- m4/virt-linker-relro.m4 | 35 --------------------------- meson.build | 43 ++++++++++++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 140 deletions(-) delete mode 100644 m4/virt-linker-no-indirect.m4 delete mode 100644 m4/virt-linker-no-undefined.m4 delete mode 100644 m4/virt-linker-relro.m4 diff --git a/configure.ac b/configure.ac index 56a471fc3ab..cb1aed73828 100644 --- a/configure.ac +++ b/configure.ac @@ -64,43 +64,6 @@ m4_ifndef([LT_INIT], [ AM_PROG_CC_C_O AM_PROG_LD =20 -AC_MSG_CHECKING([for how to mark DSO non-deletable at runtime]) -LIBVIRT_NODELETE=3D -`$LD --help 2>&1 | grep -- "-z nodelete" >/dev/null` && \ - LIBVIRT_NODELETE=3D"-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 .de= f file - # instead to work properly, therefore clear --version-script here and = use - # -Wl, to pass the .def file to the linker - VERSION_SCRIPT_FLAGS=3D"-Wl," - ;; - * ) - VERSION_SCRIPT_FLAGS=3D-Wl,--version-script=3D - `$LD --help 2>&1 | grep -- --version-script >/dev/null` || \ - VERSION_SCRIPT_FLAGS=3D"-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=3D-Wl,-flat_namespace - ;; - * ) - FLAT_NAMESPACE_FLAGS=3D"" - ;; -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=3Dno @@ -161,10 +124,6 @@ fi =20 # Check for compiler and library settings. =20 -LIBVIRT_LINKER_RELRO -LIBVIRT_LINKER_NO_INDIRECT -LIBVIRT_LINKER_NO_UNDEFINED - LIBVIRT_ARG_APPARMOR LIBVIRT_ARG_ATTR LIBVIRT_ARG_AUDIT diff --git a/m4/virt-linker-no-indirect.m4 b/m4/virt-linker-no-indirect.m4 deleted file mode 100644 index b344f708539..00000000000 --- a/m4/virt-linker-no-indirect.m4 +++ /dev/null @@ -1,32 +0,0 @@ -dnl -dnl Check for --no-copy-dt-needed-entries -dnl -dnl Copyright (C) 2013 Guido G=C3=BCnther -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 . -dnl - -AC_DEFUN([LIBVIRT_LINKER_NO_INDIRECT],[ - AC_MSG_CHECKING([for how to avoid indirect lib deps]) - - NO_INDIRECT_LDFLAGS=3D - case `$LD --help 2>&1` in - *"--no-copy-dt-needed-entries"*) - NO_INDIRECT_LDFLAGS=3D"-Wl,--no-copy-dt-needed-entries" ;; - esac - AC_SUBST([NO_INDIRECT_LDFLAGS]) - - AC_MSG_RESULT([$NO_INDIRECT_LDFLAGS]) -]) diff --git a/m4/virt-linker-no-undefined.m4 b/m4/virt-linker-no-undefined.m4 deleted file mode 100644 index 532b0de212c..00000000000 --- a/m4/virt-linker-no-undefined.m4 +++ /dev/null @@ -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 . -dnl - -AC_DEFUN([LIBVIRT_LINKER_NO_UNDEFINED],[ - AC_MSG_CHECKING([for how to stop undefined symbols at link time]) - - NO_UNDEFINED_LDFLAGS=3D - ld_help=3D`$LD --help 2>&1` - case $ld_help in - *"-z defs"*) NO_UNDEFINED_LDFLAGS=3D"-Wl,-z -Wl,defs" ;; - esac - AC_SUBST([NO_UNDEFINED_LDFLAGS]) - - AC_MSG_RESULT([$NO_UNDEFINED_LDFLAGS]) -]) diff --git a/m4/virt-linker-relro.m4 b/m4/virt-linker-relro.m4 deleted file mode 100644 index 079a095feed..00000000000 --- a/m4/virt-linker-relro.m4 +++ /dev/null @@ -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 . -dnl - -AC_DEFUN([LIBVIRT_LINKER_RELRO],[ - AC_MSG_CHECKING([for how to force completely read-only GOT table]) - - RELRO_LDFLAGS=3D - ld_help=3D`$LD --help 2>&1` - case $ld_help in - *"-z relro"*) RELRO_LDFLAGS=3D"-Wl,-z -Wl,relro" ;; - esac - case $ld_help in - *"-z now"*) RELRO_LDFLAGS=3D"$RELRO_LDFLAGS -Wl,-z -Wl,now" ;; - esac - AC_SUBST([RELRO_LDFLAGS]) - - AC_MSG_RESULT([$RELRO_LDFLAGS]) -]) diff --git a/meson.build b/meson.build index 2450a8bdd79..d1237c10875 100644 --- a/meson.build +++ b/meson.build @@ -574,6 +574,49 @@ cc_flags_relaxed_frame_limit =3D [ ] =20 =20 +# various linker checks + +libvirt_relro =3D cc.get_supported_link_arguments([ + '-Wl,-z,relro', + '-Wl,-z,now', +]) + +libvirt_nodelete =3D cc.get_supported_link_arguments([ + '-Wl,-z,nodelete', +]) + +libvirt_no_undefined =3D cc.get_supported_link_arguments([ + '-Wl,-z,defs', +]) + +libvirt_no_indirect =3D cc.get_supported_link_arguments([ + '-Wl,--no-copy-dt-needed-entries', +]) + +if host_machine.system() =3D=3D 'windows' + version_script_flags =3D '-Wl,' +else + test_file =3D '@0@/src/libvirt_qemu.syms'.format(meson.source_root()) + if cc.has_link_argument('-Wl,--version-script=3D@0@'.format(test_file)) + version_script_flags =3D '-Wl,--version-script=3D' + elif cc.has_link_argument('-Wl,-M,') + version_script_flags =3D '-Wl,-M,' + else + error('No supported version script link argument found.') + endif +endif + +libvirt_flat_namespace =3D [] +if host_machine.system() =3D=3D 'darwin' + libvirt_flat_namespace =3D '-Wl,-flat_namespace' +endif + +libvirt_export_dynamic =3D cc.first_supported_link_argument([ + '-Wl,-export-dynamic', + '-Wl,-export_dynamic', +]) + + # define top include directory =20 top_inc_dir =3D include_directories('.') --=20 2.26.2