From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id E89973858D34 for ; Wed, 12 Jun 2024 02:02:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E89973858D34 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 E89973858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::633 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718157782; cv=none; b=uC4GlwqYEvVlYUYptDG/O5JYdRr+/8spDG3O+gXCG0RT2UslfVseeaSa6ADGjorjBByzdqwVpioD8E1tUZ4cUEZIRcO3EVLHijT7vjh1L5A4hZu8eoeIRuCq7A5fjXiOR3ZLvTjNM82/VakGvBxhmK4bHLCTdfxBvuzsHcQeBHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718157782; c=relaxed/simple; bh=2f+lBd3FLDcQzYTA/GZwu9iH9F+RdR17GbOuZxsMLW8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gquIutxwIL1TCogMR3arj9HHTyzY29ivfZ+TxfMphHWqPsj3cIwBqMrdjujAl54TsmwjFesRtAbVYgi36/VRfXPgJs65R29zht0MHlV7Hn2f2ni12CKhUf007ScTFWi4jBqoupfgZKY2PcW0HGyByBnRzIf06ziVY2BYEnOvCT8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1f8395a530dso3490645ad.0 for ; Tue, 11 Jun 2024 19:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718157771; x=1718762571; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:date:organization:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=mB+VMa/1vUo5X3iF5KSqiIHNmwvxTEOz6d82o3O+w0Y=; b=bmnQpNnJJ/7WKACQ6EtGMjXsxWkZMPQDyoAyGbGNPhUCq1Be7xyOhPmD16eITF9Ozh GO6bjbfBishgDur1/YxROlJ+/vK7kfYVnuuHQeBgpy2dcmr/mxH7s1hbQwjFJIqXp+jv 0Rx/lNnhjW5RU57hr2+n87VrHQR3wXc1669uANxAtPTlyC7uqyQNl3OzgZvegxzeHALn B+a8Gk3gbYGOLIz8f7xlMNDUQWQgNiBLkTBBuhecNCs60js+6DrFam4NxSU0EwnYQWaZ 3R7xD2RzgRTX222b4GfPe3y/UPLGlMVBUMsJfWnFwF3pWmUXJIa6VRdfORLA0NYeiDPD qoDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718157771; x=1718762571; h=mime-version:user-agent:message-id:date:organization:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mB+VMa/1vUo5X3iF5KSqiIHNmwvxTEOz6d82o3O+w0Y=; b=AZ5unnJqa0WbTJ09OFrQtcn9vPeEOvp4QByGLlzy5QXhnkOJFqLdeUkW2odarxyLzz uQumlgzHRBgheLpQMqYYepkfjVN8iRHvSy4eF5Z9ZV3lj6iTTGp576D/3eOt4sN6VmKi EGqmZ+FKJltgYdudpHFsgpPuqzCVkAuV/vZnM0emAqHOqoNW5xWqWs7qG/3/4M1LpwHE KoNp2y5H5j7n6EPJI3dOG+I3uT9OOT3E01M0rmG2AeX5XO2d18Zc2ze4EVkei8YWOnPK 5ybDMqWq+qXfhT7UPoMLSK06I+RvhxgDWuysi3VbSuteM5X6Yz2fptI4iarQ21GjSdFN /jHQ== X-Gm-Message-State: AOJu0YyLTEHtYr0c+NnnLMNzcYuZhUPBBD8AAYEuT5E666KPxUe/HTa9 Iw1O2HoI/Cif9IbGB3LqJ2Gi+5hX0zdhB8lGqfExMx7wtteVO9nviu/zZd9rqkJSUugTztbOz1s oEQ== X-Google-Smtp-Source: AGHT+IErzM3i/heQ8+RRw90EZAEwtvw/yavjrXYtJKVu/g8EDkfbIcIEArK0XmyuGy0UuOF6WDVVCA== X-Received: by 2002:a17:902:e841:b0:1f3:453f:1372 with SMTP id d9443c01a7336-1f83b610a30mr6905795ad.30.1718157770583; Tue, 11 Jun 2024 19:02:50 -0700 (PDT) Received: from free.home ([2804:7f1:218b:1961:ef8:d680:5399:8b1a]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6eaab40f2sm78991305ad.246.2024.06.11.19.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 19:02:50 -0700 (PDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 45C22Ybs1125496 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Jun 2024 23:02:35 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Cc: Rainer Orth , Mike Stump Subject: [PATCH] [testsuite] add linkonly to dg-additional-sources [PR115295] Organization: Free thinker, does not speak for AdaCore Date: Tue, 11 Jun 2024 23:02:34 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-11.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,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 List-Id: 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, so that its additional sources get discarded when vector tests downgrade to compile-only. Regstrapped on x86_64-linux-gnu. Also tested with 'dg-do compile' in pr95401.cc. Ok to install? for gcc/ChangeLog * doc/sourcebuild.texi (dg-additional-sources): Add linkonly. for gcc/testsuite/ChangeLog * g++.dg/vect/pr95401.cc: Add linkonly to dg-additional-sources. * lib/gcc-defs (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/pr95401.cc | 2 +- gcc/testsuite/lib/gcc-defs.exp | 35 +++++++++++++++++++++++++++------- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index e997dbec3334b..08c178db674c8 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/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/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" -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer More tolerance and less prejudice are key for inclusion and diversity Excluding neuro-others for not behaving ""normal"" is *not* inclusive