From patchwork Fri Aug 18 02:30:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 1822641 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=uIGFUFIL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RRm8R2p4cz1yZd for ; Fri, 18 Aug 2023 12:31:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D855F3851ABD for ; Fri, 18 Aug 2023 02:31:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D855F3851ABD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692325874; bh=Bs/g1nf2mDEODZiXz9y/IouzhquygDRsRZrqoXrnOgg=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=uIGFUFILElmx8sPyyRM37vl1abyJ7hM2xf9VLEWObZxTWz5OM1sdCGpgAjAguddTc 95IfdfAwKX3h/nwBDOpbwRgh8/gm+KUfZupAspTclwlEVpajibmkyDcAiahYiFRsv/ j2SYnKv2SiLImifXjWJohkMdQ8vJgstCr3ZIu8GU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by sourceware.org (Postfix) with ESMTPS id A0E0F3853D11 for ; Fri, 18 Aug 2023 02:30:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A0E0F3853D11 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-1c8c44053e8so266555fac.1 for ; Thu, 17 Aug 2023 19:30:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692325853; x=1692930653; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Bs/g1nf2mDEODZiXz9y/IouzhquygDRsRZrqoXrnOgg=; b=EjrvM5fMomJxFlyRl4VYiM6OAG8oVMJwEThIu4IT0FfXoECZDA5fEkRNIyWXqD9dO2 9n6FDGkl6ZudiowQS5DzbKkJ3Su2K3BTfashkLT7iSJegL1ij0/haf0Mt2AXsguFYuwG 9867MlBcKjmn0Hqwz7oFN5QHy38+FptLjRG0der2YHJLabwWgQXpkiyIoS9t9CMVfFJ1 8bjkCNsfhCBXCp6mkJOhS93pvxr1lCy/OMgWcpVxu+SoML/eflAEZiZ2dVdwS4qnkbEm J6WoHe7IP3ah2Njr0YWOC/3jCUwlgsBA/SdcXaMxyCncL+PtND0ohplnD5hRfqphsO7j 1XhQ== X-Gm-Message-State: AOJu0YxcT0bvw1bJQVUCyiErPWX2InlmVYsXs0OKcpaCzKfnoUUmwMyJ 4UoeF+IeItFvfDqmYWG6rSf/Hii0x/xhnxVsA/k= X-Google-Smtp-Source: AGHT+IEqgR0yATrGnde1urF4FTE8aTzXeT0pcfk+LdluHgM5UA86IyKGCyrLcSfZXAEmftfJFUV8IA== X-Received: by 2002:a05:6871:520b:b0:1bf:cec2:6aff with SMTP id ht11-20020a056871520b00b001bfcec26affmr3292182oac.5.1692325853441; Thu, 17 Aug 2023 19:30:53 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:7043:d206:cd2a:51ba]) by smtp.gmail.com with ESMTPSA id ds5-20020a0568705b0500b001c50fb56845sm556127oab.16.2023.08.17.19.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 19:30:52 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Eric Feng , David Malcolm Subject: [PATCH] testsuite: Improve test in dg-require-python-h Date: Thu, 17 Aug 2023 23:30:50 -0300 Message-ID: <20230818023050.98368-1-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 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 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Thiago Jung Bauermann via Gcc-patches From: Thiago Jung Bauermann Reply-To: Thiago Jung Bauermann Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" If GCC is tested with a sysroot which doesn't contain a Python installation (e.g., with a command such as "make check-gcc-c FLAGS_UNDER_TEST="--sysroot=/some/path"), but there's a python3-config in $PATH, then the testsuite will pick up the host's Python.h which can't actually be used: Executing on host: python3-config --includes (timeout = 300) spawn -ignore SIGHUP python3-config --includes -I/usr/include/python3.10 -I/usr/include/python3.10 Executing on host: /some/sysroot/bin/aarch64-unknown-linux-gnu-gcc --sysroot=/some/sysroot/libc -Wl,-dynamic-linker=/some/sysroot/libc/lib/ld-linux-aarch64.so.1 -Wl,-rpath=/some/sysroot/libc/lib /some/src/gcc.git/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-2.c -fdiagnostics-plain-output -fplugin=./analyzer_cpython_plugin.so -fanalyzer -I/usr/include/python3.10 -I/usr/include/python3.10 -S -o cpython-plugin-test-2.s (timeout = 600) spawn -ignore SIGHUP /some/sysroot/bin/aarch64-unknown-linux-gnu-gcc --sysroot=/some/sysroot/libc -Wl,-dynamic-linker=/some/sysroot/libc/lib/ld-linux-aarch64.so.1 -Wl,-rpath=/some/sysroot/libc/lib /some/src/gcc.git/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-2.c -fdiagnostics-plain-output -fplugin=./analyzer_cpython_plugin.so -fanalyzer -I/usr/include/python3.10 -I/usr/include/python3.10 -S -o cpython-plugin-test-2.s In file included from /usr/include/python3.10/Python.h:8, from /some/src/gcc.git/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-2.c:8: /usr/include/python3.10/pyconfig.h:9:12: fatal error: aarch64-linux-gnu/python3.10/pyconfig.h: No such file or directory compilation terminated. compiler exited with status 1 This problem causes these testsuite failures: FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 17) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 18) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 21) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 31) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 32) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 35) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 45) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 55) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 63) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 66) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 68) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 69) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for excess errors) Excess errors: /usr/include/python3.10/pyconfig.h:9:12: fatal error: aarch64-linux-gnu/python3.10/pyconfig.h: No such file or directory compilation terminated. So try to compile a test file so that the testcase can be marked as unsupported instead. gcc/testsuite/ChangeLog: * gcc/testsuite/lib/target-supports.exp (dg-require-python-h): Test whether Python.h can really be used. --- gcc/testsuite/lib/target-supports.exp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) base-commit: 1eb2433ff9e85008a289db03ff7eb802d51c42a8 diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 92b6f69730e9..5b5f86551844 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -12570,11 +12570,21 @@ proc dg-require-python-h { args } { verbose "ENTER dg-require-python-h" 2 + set supported 0 set result [remote_exec host "python3-config --includes"] set status [lindex $result 0] if { $status == 0 } { - set python_flags [lindex $result 1] - } else { + # Remove trailing newline from python3-config output. + set python_flags [string trim [lindex $result 1]] + if [check_no_compiler_messages python_h assembly { + #include + int main (void) { return 0; } + } $python_flags] { + set supported 1 + } + } + + if { $supported == 0 } { verbose "Python.h not supported" 2 upvar dg-do-what dg-do-what set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]