From nobody Tue Nov 26 22:41:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1704012752; cv=none; d=zohomail.com; s=zohoarc; b=luoY+1hX3OMQxEycZGfvOjQw8pcMljDoGjlbD7TS3o1EURZ1aagf1in+Mm/QrIYTZq4mNelTkgY/AgWBurzxpI9WvA6nmWW6lhpxtylxQAi/wpiLrmBy0o5+1YIPkagaLNXfKnzJ5WcQGvmHaqHPOkxRGJayPCCiX67jt7Ru+54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704012752; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=olqbeujUty4FiDauTxIFpk1yhoyxF/2nypGlxWalccQ=; b=M3CHclLMRVhU7ikmBgjgME2Ae2de7UCfVzRFlcMiKyarChKcuM9f5pkrAeRZSyBKuIJqwloB7tDeIQEmPfwD6Xi7yxFB4Ksxyvx7ZhcdR1pz7jliwt0orJpz38/tyXdKskiIoDjCufNwXFYeoaN82zspPlQ6k4uTSx1dlfqHjRM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704012752800148.01699044854377; Sun, 31 Dec 2023 00:52:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rJrUv-0008CQ-Md; Sun, 31 Dec 2023 03:48:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rJrT6-0005GS-Du for qemu-devel@nongnu.org; Sun, 31 Dec 2023 03:46:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rJrT2-0000rw-Ep for qemu-devel@nongnu.org; Sun, 31 Dec 2023 03:46:46 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-v7E3emXkOQOeyHn1W90tzg-1; Sun, 31 Dec 2023 03:46:40 -0500 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-40d5ab2fbc9so36805505e9.3 for ; Sun, 31 Dec 2023 00:46:39 -0800 (PST) Received: from [192.168.10.118] ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id t18-20020a5d4612000000b003367bb8898dsm23237065wrq.66.2023.12.31.00.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Dec 2023 00:46:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704012403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=olqbeujUty4FiDauTxIFpk1yhoyxF/2nypGlxWalccQ=; b=MFoOyu3HlFrIZPqv6z2DnFT4mYzZ1qJQG2f/pFBGcBNUiODeYEdje3z6pcDAZcICCCvELO dtiejxafry5pixz3xqQzFzAyMGo8TkmN4A2Sp1anGUeHX++3Hw3bXft+SbiKJ4PDqlC/j8 cYN6ZodJuptg+yk6cV0Zh4pzcNUzRjM= X-MC-Unique: v7E3emXkOQOeyHn1W90tzg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704012398; x=1704617198; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=olqbeujUty4FiDauTxIFpk1yhoyxF/2nypGlxWalccQ=; b=pywh1hekTEuQtVp+zinLXw8RGSV6emcSi6XtEtqzDPKApLsW0s9XCnyaArj+5g3GAC rc4qa4DPDHEWDBvEed72aeeiBvVH70MeMuVmXkbepef4CMPaI/kmTHhFCCiRmSXAor3U jEqERPzFNnVpKeel+4d7OxBg30e0xrBHPlk8fvNjf4op4FzSCX6pqRMnS2acxxlfbmaK vfhOFdZCWA83N2DMjB9CzoyPhAZEU2FPPR6g/zwF+CkI+1JtokoYFc/eHO4uE6i61Wd7 7qFOVOonr5GzKby7yfG416e2dcobS2J5itLfXjw2nIT85sxeNQzU0UEfRTPo6NO/9x5G J9OA== X-Gm-Message-State: AOJu0YygA8wkGIWoCbQ1udBzIrzLfk/2gYMyAMr9B/DOrnkjXgrrDMlH 9EiE0I8l17LItizco4YoxKzJY2EmTz6TT1QsCjKvpNgJrpW28qjFoKhzGNp22M/p7Fd/BSZc85q 36Q+rR5sg5UcZ0qJKaVTWa5Oih4vFZFjH8S3+JYPn8sOCBJvbZM6aDXwcfnhTf22x6546PzbewM 2z9k0AFF8= X-Received: by 2002:a05:600c:35c8:b0:40d:5d4b:ab35 with SMTP id r8-20020a05600c35c800b0040d5d4bab35mr3703621wmq.16.1704012398143; Sun, 31 Dec 2023 00:46:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvM4z7H1H7f+97tieYbR6ATxI/RtOasFbbkZxL0yH0hAqec66xuXlW+OWl/y/0eKnLqoe5xQ== X-Received: by 2002:a05:600c:35c8:b0:40d:5d4b:ab35 with SMTP id r8-20020a05600c35c800b0040d5d4bab35mr3703612wmq.16.1704012397750; Sun, 31 Dec 2023 00:46:37 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 36/46] meson: move CFI detection code with other compiler flags Date: Sun, 31 Dec 2023 09:44:52 +0100 Message-ID: <20231231084502.235366-37-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231231084502.235366-1-pbonzini@redhat.com> References: <20231231084502.235366-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -47 X-Spam_score: -4.8 X-Spam_bar: ---- X-Spam_report: (-4.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.667, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1704012753296100001 Keep it together with the other compiler modes, and before dependencies. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- meson.build | 80 ++++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/meson.build b/meson.build index efb36c762e9..5c54441a3cd 100644 --- a/meson.build +++ b/meson.build @@ -517,6 +517,46 @@ if get_option('fuzzing') endif endif =20 +if get_option('cfi') + cfi_flags=3D[] + # Check for dependency on LTO + if not get_option('b_lto') + error('Selected Control-Flow Integrity but LTO is disabled') + endif + if enable_modules + error('Selected Control-Flow Integrity is not compatible with modules') + endif + # Check for cfi flags. CFI requires LTO so we can't use + # get_supported_arguments, but need a more complex "compiles" which allo= ws + # custom arguments + if cc.compiles('int main () { return 0; }', name: '-fsanitize=3Dcfi-ical= l', + args: ['-flto', '-fsanitize=3Dcfi-icall'] ) + cfi_flags +=3D '-fsanitize=3Dcfi-icall' + else + error('-fsanitize=3Dcfi-icall is not supported by the compiler') + endif + if cc.compiles('int main () { return 0; }', + name: '-fsanitize-cfi-icall-generalize-pointers', + args: ['-flto', '-fsanitize=3Dcfi-icall', + '-fsanitize-cfi-icall-generalize-pointers'] ) + cfi_flags +=3D '-fsanitize-cfi-icall-generalize-pointers' + else + error('-fsanitize-cfi-icall-generalize-pointers is not supported by th= e compiler') + endif + if get_option('cfi_debug') + if cc.compiles('int main () { return 0; }', + name: '-fno-sanitize-trap=3Dcfi-icall', + args: ['-flto', '-fsanitize=3Dcfi-icall', + '-fno-sanitize-trap=3Dcfi-icall'] ) + cfi_flags +=3D '-fno-sanitize-trap=3Dcfi-icall' + else + error('-fno-sanitize-trap=3Dcfi-icall is not supported by the compil= er') + endif + endif + add_global_arguments(cfi_flags, native: false, language: all_languages) + add_global_link_arguments(cfi_flags, native: false, language: all_langua= ges) +endif + add_global_arguments(qemu_common_flags, native: false, language: all_langu= ages) add_global_link_arguments(qemu_ldflags, native: false, language: all_langu= ages) =20 @@ -2009,46 +2049,6 @@ endif config_host_data.set('CONFIG_AUDIO_DRIVERS', '"' + '", "'.join(audio_drivers_selected) + '", ') =20 -if get_option('cfi') - cfi_flags=3D[] - # Check for dependency on LTO - if not get_option('b_lto') - error('Selected Control-Flow Integrity but LTO is disabled') - endif - if enable_modules - error('Selected Control-Flow Integrity is not compatible with modules') - endif - # Check for cfi flags. CFI requires LTO so we can't use - # get_supported_arguments, but need a more complex "compiles" which allo= ws - # custom arguments - if cc.compiles('int main () { return 0; }', name: '-fsanitize=3Dcfi-ical= l', - args: ['-flto', '-fsanitize=3Dcfi-icall'] ) - cfi_flags +=3D '-fsanitize=3Dcfi-icall' - else - error('-fsanitize=3Dcfi-icall is not supported by the compiler') - endif - if cc.compiles('int main () { return 0; }', - name: '-fsanitize-cfi-icall-generalize-pointers', - args: ['-flto', '-fsanitize=3Dcfi-icall', - '-fsanitize-cfi-icall-generalize-pointers'] ) - cfi_flags +=3D '-fsanitize-cfi-icall-generalize-pointers' - else - error('-fsanitize-cfi-icall-generalize-pointers is not supported by th= e compiler') - endif - if get_option('cfi_debug') - if cc.compiles('int main () { return 0; }', - name: '-fno-sanitize-trap=3Dcfi-icall', - args: ['-flto', '-fsanitize=3Dcfi-icall', - '-fno-sanitize-trap=3Dcfi-icall'] ) - cfi_flags +=3D '-fno-sanitize-trap=3Dcfi-icall' - else - error('-fno-sanitize-trap=3Dcfi-icall is not supported by the compil= er') - endif - endif - add_global_arguments(cfi_flags, native: false, language: all_languages) - add_global_link_arguments(cfi_flags, native: false, language: all_langua= ges) -endif - have_host_block_device =3D (targetos !=3D 'darwin' or cc.has_header('IOKit/storage/IOMedia.h')) =20 --=20 2.43.0