From patchwork Wed Jun 12 05:56:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 1946656 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=edupKcy+; 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 4VzZbl1Cs9z20KL for ; Wed, 12 Jun 2024 15:58:40 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0E397385DC1E for ; Wed, 12 Jun 2024 05:58:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 19CDE3858D34 for ; Wed, 12 Jun 2024 05:58:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 19CDE3858D34 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 19CDE3858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::429 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718171897; cv=none; b=HQpGnGg0b6RMtwSGOr7OFqgbwPDWEjDWESwBUhvUlXO0ti9qtJl44+AZwuNrDRR94ngwatYhrFLdPYAZ/8BoDBG47MObpcUb+RNvZOMQ5ejzFxLbN9saHGzfJmOTwu84CCvjIDPdLv4B3aejZAEQqwACyEJ8epol+f1dH2ouxmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718171897; c=relaxed/simple; bh=P9Lw2SUB98RwqoF9j71WBYtX43BxenRYZj6o7W74fDo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=t77WLKomjRr5K7RKqKPz4Tm9fbHU85U6XLIC6mAhSYJk22GK0hNDKDd8rf76F5558Bt+bafQMk8Ic9XTvFgHYU39IJ+xrC3h/EGJl/kAFm8XRAXOc6IkgJ9IrczPR8rBqRUTmaDpIkdqAmgcgWwDYDKakpZrq7FMAIf2hHqjZuA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6f8ec7e054dso1424474b3a.2 for ; Tue, 11 Jun 2024 22:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718171894; x=1718776694; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=VxCRCXYJypw0SsWHECbYlqzw1tyZlJ8nZf3fcD5MsKY=; b=edupKcy+SCXea5c9xfbpc5H3Sfd+mtXQ23xefIzZbq0UOIxTUo2QL2V9B3RvdGQ7LL W+y/SIgu6nEhIEW4ZkADlY4PHz8gCrjavnUN+/O3KHtsjpi6MOvwIAa+3Fqcm2viyXcw 9dltw6cKod3RhEyPuw1TMtHGimmPNQ+5OKKeaYWm40DXz1zWR/anKshUB4xN4hxalbN2 49shVJgX0LZvgCyzdjAFjKX7EM2QO6UEsVPCeAgodLkOwfQSuUgWcBIFIe+iKVnHOIaG 2k0pfc3xvMKsph33WdPdfhNWC8LT47mCvl/vPwPUZzBbCcewe96JjnRcJ97iV6ffu/QE iTHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718171894; x=1718776694; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VxCRCXYJypw0SsWHECbYlqzw1tyZlJ8nZf3fcD5MsKY=; b=qega6LuGR9i+VIXxxldGWPKuEJAhcivQqQor72chVUIGQ/SaATRf4VYbXWNICLEgjn kNRKMfFVD1Xh6X0uwp42+6cS3wI9wVBPtEXhJ0nUTnREqaqMUv6lbWRVilKF6XMxq189 CXnBnovgwBC9jPR/ZrcFaw4gWC0CRqOmd6ifjUoi+ZH1pCRLXdBgrflZcvEqvxvFNj2C HcRb3mqXVLYwcMnF8df3quiZ8EqilVIYFEjybN8ksowEV7UNKOfgbHRE2DCJ/PEUEDaZ 5SkZiRPg/ayBxEwdA/RbeyCzrGgRDsuwwfWUomzRGqwWX/CcM9thplpBdEIPA1TnThTN qY1A== X-Gm-Message-State: AOJu0YwyD1y8pIdiidqKGEvdilxDiLmzazL6RaQzySe0BxBzmKC01lky 3doC3IC0edVhEcCzyxpcR/o5SSLoyl5xSc0sTNkv+5/kO+rqkebOPZxS0kHBOQ== X-Google-Smtp-Source: AGHT+IE1T/AQ56kxcpkNoLv0HaNkCeQUj8UIKgqQ6L7KeZScXY4ZqmBVXDFIHh8pwDCkZGWqnuhx2A== X-Received: by 2002:a05:6a00:a92:b0:702:301f:e513 with SMTP id d2e1a72fcca58-705bce2f635mr1188989b3a.13.1718171893591; Tue, 11 Jun 2024 22:58:13 -0700 (PDT) Received: from free.home ([187.106.42.20]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-703fd4dbaabsm9984280b3a.160.2024.06.11.22.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 22:58:12 -0700 (PDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 45C5urS21132826 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 12 Jun 2024 02:56:54 -0300 From: Alexandre Oliva To: Andrew Pinski Cc: gcc-patches@gcc.gnu.org, Rainer Orth , Mike Stump Subject: [PATCH v2] [testsuite] add linkonly to dg-additional-sources [PR115295] Organization: Free thinker, does not speak for AdaCore References: Date: Wed, 12 Jun 2024 02:56:53 -0300 In-Reply-To: (Andrew Pinski's message of "Tue, 11 Jun 2024 19:41:43 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_QUOTING 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org On Jun 11, 2024, Andrew Pinski wrote: > I think we should just fully revert the changes to > dg-additional-sources and add an explicit `dg-do run` to pr95401.cc I don't suppose an explicit "dg-do run" would make things work reliably, after we've detected that hardware or runtime support for vectors is missing. I'd much rather extend the solution to the other potentially affected tests, as in this revised patch. Regstrapped on x86_64-linux-gnu. Ok to install? The D testsuite shows it was a mistake to assume that dg-additional-sources are never to be used for compilation tests. Even if an output file is specified for compilation, extra module files can be named and used in the compilation without being flagged as errors. Introduce a 'linkonly' flag for dg-additional-sources, and use it in pr95401.cc and other vector tests that default to run, so that its additional sources get discarded when vector tests downgrade to compile-only. This reverts previous workarounds for this very circumstance, that relied on being able to run vector tests anyway, even after failing to detect runtime or hardware vector support. for gcc/ChangeLog PR d/115295 * doc/sourcebuild.texi (dg-additional-sources): Add linkonly. for gcc/testsuite/ChangeLog PR d/115295 * g++.dg/vect/pr95401.cc: Add linkonly to dg-additional-sources. * g++.dg/vect/pr68762-1.cc: Likewise. * g++.dg/vect/simd-clone-3.cc: Likewise. * g++.dg/vect/simd-clone-5.cc: Likewise. * gcc.dg/vect/vect-simd-clone-10.c: Likewise. Drop dg-do run. * gcc.dg/vect/vect-simd-clone-12.c: Likewise. Likewise. * lib/gcc-defs.exp (additional_sources_omit_on_compile): New. (dg-additional-sources): Add to it on linkonly. (dg-additional-files-options): Omit select sources on compile. --- gcc/doc/sourcebuild.texi | 9 +++--- gcc/testsuite/g++.dg/vect/pr68762-1.cc | 2 + gcc/testsuite/g++.dg/vect/pr95401.cc | 2 + gcc/testsuite/g++.dg/vect/simd-clone-3.cc | 2 + gcc/testsuite/g++.dg/vect/simd-clone-5.cc | 2 + gcc/testsuite/gcc.dg/vect/vect-simd-clone-10.c | 4 +-- gcc/testsuite/gcc.dg/vect/vect-simd-clone-12.c | 4 +-- gcc/testsuite/lib/gcc-defs.exp | 35 +++++++++++++++++++----- 8 files changed, 39 insertions(+), 21 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index e37fb85f3b316..22fc5dca6ce73 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -1320,15 +1320,16 @@ to @var{var_value} before execution of the program created by the test. Specify additional files, other than source files, that must be copied to the system where the compiler runs. -@item @{ dg-additional-sources "@var{filelist}" [@{ target @var{selector} @}] @} +@item @{ dg-additional-sources "@var{filelist}" [@{ \[linkonly\] \[target @var{selector}\] @}] @} Specify additional source files to appear in the compile line following the main test file. If the directive includes the optional @samp{@{ @var{selector} @}} then the additional sources are only added if the target system matches the @var{selector}. -Additional sources are generally used only in @samp{link} and @samp{run} -tests; they are reported as unsupported and discarded in other kinds of -tests that direct the compiler to output to a single file. +If @samp{linkonly} is specified, additional sources are used only in +@samp{link} and @samp{run} tests; they are reported as unsupported and +discarded in other kinds of tests that direct the compiler to output to +a single file. @end table @subsubsection Add checks at the end of a test diff --git a/gcc/testsuite/g++.dg/vect/pr68762-1.cc b/gcc/testsuite/g++.dg/vect/pr68762-1.cc index 118a301ab90d5..53cc6e4c6dfa7 100644 --- a/gcc/testsuite/g++.dg/vect/pr68762-1.cc +++ b/gcc/testsuite/g++.dg/vect/pr68762-1.cc @@ -2,7 +2,7 @@ // { dg-require-effective-target vect_simd_clones } // { dg-additional-options "-fopenmp-simd -fno-inline" } // { dg-additional-options "-mavx" { target avx_runtime } } -// { dg-additional-sources "pr68762-2.cc" } +// { dg-additional-sources "pr68762-2.cc" linkonly } #include "pr68762.h" diff --git a/gcc/testsuite/g++.dg/vect/pr95401.cc b/gcc/testsuite/g++.dg/vect/pr95401.cc index 6a56dab095722..8b1be4f242521 100644 --- a/gcc/testsuite/g++.dg/vect/pr95401.cc +++ b/gcc/testsuite/g++.dg/vect/pr95401.cc @@ -1,5 +1,5 @@ // { dg-additional-options "-mavx2 -O3" { target avx2_runtime } } -// { dg-additional-sources pr95401a.cc } +// { dg-additional-sources pr95401a.cc linkonly } extern int var_9; extern unsigned var_14; diff --git a/gcc/testsuite/g++.dg/vect/simd-clone-3.cc b/gcc/testsuite/g++.dg/vect/simd-clone-3.cc index 1057a7eb5f6a5..4dd9d15d1a3bd 100644 --- a/gcc/testsuite/g++.dg/vect/simd-clone-3.cc +++ b/gcc/testsuite/g++.dg/vect/simd-clone-3.cc @@ -1,7 +1,7 @@ // { dg-require-effective-target vect_simd_clones } // { dg-additional-options "-fopenmp-simd -fno-inline" } // { dg-additional-options "-mavx" { target avx_runtime } } -// { dg-additional-sources "simd-clone-2.cc" } +// { dg-additional-sources "simd-clone-2.cc" linkonly } #include "simd-clone-2.h" diff --git a/gcc/testsuite/g++.dg/vect/simd-clone-5.cc b/gcc/testsuite/g++.dg/vect/simd-clone-5.cc index 07ec8a8079efc..aca64a03c3aa9 100644 --- a/gcc/testsuite/g++.dg/vect/simd-clone-5.cc +++ b/gcc/testsuite/g++.dg/vect/simd-clone-5.cc @@ -1,7 +1,7 @@ // { dg-require-effective-target vect_simd_clones } // { dg-additional-options "-fopenmp-simd -fno-inline" } // { dg-additional-options "-mavx" { target avx_runtime } } -// { dg-additional-sources "simd-clone-4.cc" } +// { dg-additional-sources "simd-clone-4.cc" linkonly } #include "simd-clone-4.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-10.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-10.c index 009c849b7e7ea..06fbdef1da9c6 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-10.c +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-10.c @@ -1,9 +1,7 @@ -/* Since this uses dg-additional-sources, need to specify `dg-do run` instead of the default. */ -/* { dg-do run } */ /* { dg-require-effective-target vect_simd_clones } */ /* { dg-additional-options "-fopenmp-simd" } */ /* { dg-additional-options "-mavx" { target avx_runtime } } */ -/* { dg-additional-sources vect-simd-clone-10a.c } */ +/* { dg-additional-sources vect-simd-clone-10a.c linkonly } */ #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-12.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-12.c index 4699a3f3c8001..f640c8bc9dd8b 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-12.c +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-12.c @@ -1,9 +1,7 @@ -/* Since this uses dg-additional-sources, need to specify `dg-do run` instead of the default. */ -/* { dg-do run } */ /* { dg-require-effective-target vect_simd_clones } */ /* { dg-additional-options "-fopenmp-simd" } */ /* { dg-additional-options "-mavx" { target avx_runtime } } */ -/* { dg-additional-sources vect-simd-clone-12a.c } */ +/* { dg-additional-sources vect-simd-clone-12a.c linkonly } */ #include "vect-simd-clone-10.c" diff --git a/gcc/testsuite/lib/gcc-defs.exp b/gcc/testsuite/lib/gcc-defs.exp index cdca4c254d6ec..c6ec490f0092e 100644 --- a/gcc/testsuite/lib/gcc-defs.exp +++ b/gcc/testsuite/lib/gcc-defs.exp @@ -303,18 +303,26 @@ proc dg-additional-options { args } { # main source file. set additional_sources "" +set additional_sources_omit_on_compile "" set additional_sources_used "" proc dg-additional-sources { args } { global additional_sources + global additional_sources_omit_on_compile if { [llength $args] > 3 } { error "[lindex $args 0]: too many arguments" return } - if { [llength $args] >= 3 } { - switch [dg-process-target [lindex $args 2]] { + set target [lindex $args 2] + if { [llength $args] >= 3 && [lindex $target 0] == "linkonly" } { + append additional_sources_omit_on_compile " [lindex $args 1]" + set target [lreplace $target 0 1] + } + + if { [llength $args] >= 3 && $target != ""} { + switch [dg-process-target $target] { "S" { append additional_sources " [lindex $args 1]" } "N" { } "F" { error "[lindex $args 0]: `xfail' not allowed here" } @@ -407,16 +415,29 @@ proc dg-additional-files-options { options source dest type } { gcc_adjust_linker_flags global additional_sources + global additional_sources_omit_on_compile global additional_sources_used global additional_files set to_download [list] - if { $additional_sources == "" } then { - } elseif { $type != "executable" && $dest != "" } then { + if { $additional_sources_omit_on_compile != "" \ + && $additional_sources != "" \ + && $type != "executable" && $dest != "" } then { + set linkonly "" foreach s $additional_sources { - unsupported "$s: additional-source will not be used to build $dest" + foreach s2 $additional_sources_omit_on_compile { + if { $s == $s2 } { + unsupported "$s: additional-source will not be used to build $dest" + set s "" + break + } + } + if { $s != "" } { + append linkonly " $s" + } } - set additional_sources_used "" - set additional_sources "" + set additional_sources "$linkonly" + } + if { $additional_sources == "" } then { } else { if [is_remote host] { lappend options "additional_flags=$additional_sources"