From patchwork Tue Jun 20 16:56:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1797469 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=xIYLhC07; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qlt7w6vJRz20XS for ; Wed, 21 Jun 2023 02:56:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F0D023858C5E for ; Tue, 20 Jun 2023 16:56:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0D023858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687280187; bh=F9TaJanDtm0p1mhtMqKPvsTydZf1effT3r2PmZZa3og=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xIYLhC07sjTrAe1VGYcGhP8EEPebxFLbfkr2ZapDkcXcS0dyKNX9Vc+jSkMNQpL1X 3MsANcaCcACz3c2b8IrK4+BOrVbZl4srvk6REz+7vwzDnLy+/XimHGIOhGuknSSNDD nI1i5Xd4eA26cHnlFS+vSMUFq1fgwKEiXR6uJYRg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id B5EFC3858D1E for ; Tue, 20 Jun 2023 16:56:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B5EFC3858D1E Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-39eab4bbe8aso3135389b6e.1 for ; Tue, 20 Jun 2023 09:56:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687280169; x=1689872169; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=F9TaJanDtm0p1mhtMqKPvsTydZf1effT3r2PmZZa3og=; b=jbo9rRJl69uOKTrcoMQD8iZE9tXeoqPrHMOSLXRlcGiFkWtGMl9Kxw5uI99ll5J3bi eygC25FP0wLSJZxn6SUpbMXXOjeRk9ug8Hr8fUzaQfRa7ad5LHCujiLku/4TGDLVKOhD XbNFVRXAOi6a3zwyDcL9tm+0FAtrsZaNm2TAZb8Mi9znrgtLsKMAba764R8Y3LS78d8n aD+dCqHbCqruy3kvdtjS7FqNX93UEQgyxTnzYni9YJTIALZZYanDZqzyuJJEocaOSZXK kyNiuMRfrweg1OjB0w8bCYiP/CHDmgkizQw12JmbU4qZTUvDAZhJeBHuGivGHeVgVOun 7vrg== X-Gm-Message-State: AC+VfDxzyhZZfFc6pCsx1Ud8mCwVF0qVV0tTo/PPIq3W6dlFcilslT+k ct+Lqhva0GOM757FC+dcdq51r+fs3+MU4IVVZa/nlA== X-Google-Smtp-Source: ACHHUZ5tpBC9tABvM0+c9fo7NscsQvZYAl2Xg5mIMkdWwEgPAsynKJX1eC0NngmADTJMzYbhRMMzeA== X-Received: by 2002:a05:6808:1284:b0:39a:b0a:db35 with SMTP id a4-20020a056808128400b0039a0b0adb35mr18014648oiw.25.1687280169158; Tue, 20 Jun 2023 09:56:09 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:a14c:8683:1fa3:da2c:c7dc]) by smtp.gmail.com with ESMTPSA id t16-20020a056808159000b003941c3b9f0dsm1240754oiw.41.2023.06.20.09.56.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 09:56:08 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] scripts: Add forify checks on installed headers Date: Tue, 20 Jun 2023 13:56:04 -0300 Message-Id: <20230620165604.2042316-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" The check-installed-headers.sh does not handle _FORTIFY_SOURCE, and it is now defined as default for some system toolchain if optimization is defined. So currently there is no way to check if some fortify extension does trigger any conformance issue. Checked on x86_64-linux-gnu. --- scripts/check-installed-headers.sh | 36 +++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/scripts/check-installed-headers.sh b/scripts/check-installed-headers.sh index 5a50a491ca..23506a2514 100644 --- a/scripts/check-installed-headers.sh +++ b/scripts/check-installed-headers.sh @@ -29,6 +29,9 @@ cxx_modes="-std=c++98 -std=gnu++98 -std=c++11 -std=gnu++11" # These are probably the most commonly used three. lib_modes="-D_DEFAULT_SOURCE=1 -D_GNU_SOURCE=1 -D_XOPEN_SOURCE=700" +# Also check for fortify modes, since it might be enabled as default. +fortify_modes="1 2 3" + if [ $# -lt 3 ]; then echo "usage: $0 c|c++ \"compile command\" header header header..." >&2 exit 2 @@ -100,29 +103,36 @@ EOF echo :: "$header" for lang_mode in "" $lang_modes; do for lib_mode in "" $lib_modes; do - echo :::: $lang_mode $lib_mode - if [ -z "$lib_mode" ]; then - expanded_lib_mode='/* default library mode */' - else - expanded_lib_mode=$(echo : $lib_mode | \ - sed 's/^: -D/#define /; s/=/ /') - fi - cat >"$cih_test_c" <"$cih_test_c" < int avoid_empty_translation_unit; EOF - if $cc_cmd -finput-charset=ascii -fsyntax-only $lang_mode \ - "$cih_test_c" 2>&1 - then : - else failed=1 - fi + if $cc_cmd -finput-charset=ascii -fsyntax-only $lang_mode \ + "$cih_test_c" 2>&1 + then : + else failed=1 + fi + done done done done