From patchwork Tue Sep 19 13:39:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 19059 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 6DF73C326B for ; Tue, 19 Sep 2023 13:39:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C515861DE9; Tue, 19 Sep 2023 15:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1695130772; bh=WI68LWN9mTTayG8DJzCdoND8Gfky1LXPXpknrGL/Tig=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=zaXQxKdXYiT2VpNU/Is7kCOs+pxR0tQ1Vh6azXLEo4VM2+T6QnWNf9r1ESuhtcIVN koRc6jtqnAqQgB0kQU4T8Ms2bAV9RWWxxWgBMXlXc/NUjdbbgX/rIp6rkf1ne/vwEk TLHN0ysfwYfXwCeE1PB54zqSG5Ye4q72n4uNPjtYINBwUiczEYsp4iA6h84HBfnMu9 lLtYmgzk+Xye9VvAwtc2GSpLpXp0cHox4iYgL+c3m5FLp6LuJ3w/7Z0lF5A+k1Lfky HqnydAT9R2GZEcW8GgEdwOAzG280OV1skvQhKWODSZhk0oIAhpi4g9Z8Wavua/ej+X tVfw0FhpaSf+A== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 59F2C61DE8 for ; Tue, 19 Sep 2023 15:39:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jKIez08I"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EA3A9BB2; Tue, 19 Sep 2023 15:37:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1695130675; bh=WI68LWN9mTTayG8DJzCdoND8Gfky1LXPXpknrGL/Tig=; h=From:To:Cc:Subject:Date:From; b=jKIez08Iq7UC9bpo6+u9D4b6Z/f25+imZAEURIuG0osZ551P/YINxydAZahRmY5qF Xu6sOqvksUSauNmE/U8wuwov0ZNYEhEjLKChWokMVVcuyrZfJtd5oo0AC7VLwP/XdK Lk9DWLHzvcpYRqNUXiHH8fb8NMLBY8HqDxGVhmsU= To: libcamera-devel@lists.libcamera.org Date: Tue, 19 Sep 2023 16:39:43 +0300 Message-ID: <20230919133943.32035-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] meson: Simplify check for _FORTIFY_SOURCE X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: George Burgess IV Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use the compiler.get_define() function to get the value of _FORTIFY_SOURCE instead of iterating over the cpp_args. This simplies the code, but also guarantees to return the actual value of _FORTIFY_SOURCE, even if defined through other means than through the meson cpp_args. Signed-off-by: Laurent Pinchart Reviewed-by: George Burgess IV Reviewed-by: Jacopo Mondi --- meson.build | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) base-commit: 9c5eb9237cf6ae170086f0d4d87a025aa052cc9f diff --git a/meson.build b/meson.build index 2e8342630332..e9a1c7e360ce 100644 --- a/meson.build +++ b/meson.build @@ -104,17 +104,9 @@ if cc.get_id() == 'clang' # result in macro redefinition errors if the user already has a setting for # `-D_FORTIFY_SOURCE`. Do not enable FORTIFY in either of those cases. if get_option('optimization') != '0' - has_fortify_define = false - # Assume that if the user requests a FORTIFY level in cpp_args, they - # do the same for c_args. - foreach flag : get_option('cpp_args') - if flag == '-U_FORTIFY_SOURCE' - has_fortify_define = false - elif flag.startswith('-D_FORTIFY_SOURCE=') - has_fortify_define = true - endif - endforeach - if not has_fortify_define + fortify = cc.get_define('_FORTIFY_SOURCE') + if fortify == '' + message('Adding _FORTIFY_SOURCE') common_arguments += [ '-D_FORTIFY_SOURCE=2', ]