From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 96CBE385840C for ; Fri, 23 Sep 2022 17:34:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 96CBE385840C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D7EFC113E; Fri, 23 Sep 2022 10:34:45 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CCBD53F5A1; Fri, 23 Sep 2022 10:34:38 -0700 (PDT) From: Richard Sandiford To: =?utf-8?Q?Torbj=C3=B6rn?= SVENSSON via Gcc-patches Mail-Followup-To: =?utf-8?Q?Torbj=C3=B6rn?= SVENSSON via Gcc-patches , =?utf-8?Q?Torbj=C3=B6rn?= SVENSSON , richard.sandiford@arm.com Cc: =?utf-8?Q?Torbj=C3=B6rn?= SVENSSON Subject: Re: [PATCH v2] testsuite: Only run test on target if VMA == LMA References: <20220920132515.844262-1-torbjorn.svensson@foss.st.com> Date: Fri, 23 Sep 2022 18:34:37 +0100 In-Reply-To: <20220920132515.844262-1-torbjorn.svensson@foss.st.com> (=?utf-8?Q?=22Torbj=C3=B6rn?= SVENSSON via Gcc-patches"'s message of "Tue, 20 Sep 2022 15:25:15 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-47.1 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,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 List-Id: Torbj=C3=B6rn SVENSSON via Gcc-patches writes: > Checking that the triplet matches arm*-*-eabi (or msp430-*-*) is not > enough to know if the execution will enter an endless loop, or if it > will give a meaningful result. As the execution test only work when > VMA and LMA are equal, make sure that this condition is met. > > 2022-09-16 Torbj=C3=B6rn SVENSSON > > gcc/testsuite/ChangeLog: > > * lib/target-supports.exp (check_effective_target_vma_equals_lma): New. > * c-c++-common/torture/attr-noinit-1.c: Requre VMA =3D=3D LMA to = run. > * c-c++-common/torture/attr-noinit-2.c: Likewise. > * c-c++-common/torture/attr-noinit-3.c: Likewise. > * c-c++-common/torture/attr-persistent-1.c: Likewise. > * c-c++-common/torture/attr-persistent-3.c: Likewise. Looks like a nice thing to have. Could you add an entry to doc/sourcebuild.texi too? A couple of comments below... > Co-Authored-By: Yvan ROUX > Signed-off-by: Torbj=C3=B6rn SVENSSON > --- > .../c-c++-common/torture/attr-noinit-1.c | 3 +- > .../c-c++-common/torture/attr-noinit-2.c | 3 +- > .../c-c++-common/torture/attr-noinit-3.c | 3 +- > .../c-c++-common/torture/attr-persistent-1.c | 3 +- > .../c-c++-common/torture/attr-persistent-3.c | 3 +- > gcc/testsuite/lib/target-supports.exp | 49 +++++++++++++++++++ > 6 files changed, 59 insertions(+), 5 deletions(-) > > diff --git a/gcc/testsuite/c-c++-common/torture/attr-noinit-1.c b/gcc/tes= tsuite/c-c++-common/torture/attr-noinit-1.c > index 877e7647ac9..f84eba0b649 100644 > --- a/gcc/testsuite/c-c++-common/torture/attr-noinit-1.c > +++ b/gcc/testsuite/c-c++-common/torture/attr-noinit-1.c > @@ -1,4 +1,5 @@ > -/* { dg-do run } */ > +/* { dg-do link } */ > +/* { dg-do run { target { vma_equals_lma } } } */ > /* { dg-require-effective-target noinit } */ > /* { dg-skip-if "data LMA !=3D VMA" { msp430-*-* } { "-mlarge" } } */ > /* { dg-options "-save-temps" } */ > diff --git a/gcc/testsuite/c-c++-common/torture/attr-noinit-2.c b/gcc/tes= tsuite/c-c++-common/torture/attr-noinit-2.c > index befa2a0bd52..4528b9e3cfa 100644 > --- a/gcc/testsuite/c-c++-common/torture/attr-noinit-2.c > +++ b/gcc/testsuite/c-c++-common/torture/attr-noinit-2.c > @@ -1,4 +1,5 @@ > -/* { dg-do run } */ > +/* { dg-do link } */ > +/* { dg-do run { target { vma_equals_lma } } } */ > /* { dg-require-effective-target noinit } */ > /* { dg-options "-fdata-sections -save-temps" } */ > /* { dg-skip-if "data LMA !=3D VMA" { msp430-*-* } { "-mlarge" } } */ > diff --git a/gcc/testsuite/c-c++-common/torture/attr-noinit-3.c b/gcc/tes= tsuite/c-c++-common/torture/attr-noinit-3.c > index 519e88a59a6..2f1745694c9 100644 > --- a/gcc/testsuite/c-c++-common/torture/attr-noinit-3.c > +++ b/gcc/testsuite/c-c++-common/torture/attr-noinit-3.c > @@ -1,4 +1,5 @@ > -/* { dg-do run } */ > +/* { dg-do link } */ > +/* { dg-do run { target { vma_equals_lma } } } */ > /* { dg-require-effective-target noinit } */ > /* { dg-options "-flto -save-temps" } */ > /* { dg-skip-if "data LMA !=3D VMA" { msp430-*-* } { "-mlarge" } } */ > diff --git a/gcc/testsuite/c-c++-common/torture/attr-persistent-1.c b/gcc= /testsuite/c-c++-common/torture/attr-persistent-1.c > index 72dc3c27192..b11a515cef8 100644 > --- a/gcc/testsuite/c-c++-common/torture/attr-persistent-1.c > +++ b/gcc/testsuite/c-c++-common/torture/attr-persistent-1.c > @@ -1,4 +1,5 @@ > -/* { dg-do run } */ > +/* { dg-do link } */ > +/* { dg-do run { target { vma_equals_lma } } } */ > /* { dg-require-effective-target persistent } */ > /* { dg-skip-if "data LMA !=3D VMA" { msp430-*-* } { "-mlarge" } } */ > /* { dg-options "-save-temps" } */ > diff --git a/gcc/testsuite/c-c++-common/torture/attr-persistent-3.c b/gcc= /testsuite/c-c++-common/torture/attr-persistent-3.c > index 3e4fd28618d..068a72af5c8 100644 > --- a/gcc/testsuite/c-c++-common/torture/attr-persistent-3.c > +++ b/gcc/testsuite/c-c++-common/torture/attr-persistent-3.c > @@ -1,4 +1,5 @@ > -/* { dg-do run } */ > +/* { dg-do link } */ > +/* { dg-do run { target { vma_equals_lma } } } */ > /* { dg-require-effective-target persistent } */ > /* { dg-options "-flto -save-temps" } */ > /* { dg-skip-if "data LMA !=3D VMA" { msp430-*-* } { "-mlarge" } } */ > diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/ta= rget-supports.exp > index 703aba412a6..df8141a15d8 100644 > --- a/gcc/testsuite/lib/target-supports.exp > +++ b/gcc/testsuite/lib/target-supports.exp > @@ -370,6 +370,55 @@ proc check_weak_override_available { } { > return [check_weak_available] > } >=20=20 > +# Return 1 if VMA is equal to LMA for the .data section, 0 > +# otherwise. Cache the result. > + > +proc check_effective_target_vma_equals_lma { } { > + global tool > + > + return [check_cached_effective_target vma_equals_lma { > + set src vma_equals_lma[pid].c > + set exe vma_equals_lma[pid].exe > + verbose "check_effective_target_vma_equals_lma compiling testfile $src= " 2 > + set f [open $src "w"] > + puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n" > + puts $f "int foo =3D 42; void main() {}" > + close $f > + set lines [${tool}_target_compile $src $exe executable ""] > + file delete $src > + > + if [string match "" $lines] then { > + # No error messages > + > + set objdump_name [find_binutils_prog objdump] > + set output [remote_exec host "$objdump_name" "--section-head= ers --section=3D.data $exe"] > + set output [lindex $output 1] > + > + remote_file build delete $exe > + > + # Example output of objdump: > + #vma_equals_lma9059.exe: file format elf32-littlearm > + # > + #Sections: > + #Idx Name Size VMA LMA File off A= lgn > + # 6 .data 00000558 20000000 08002658 00020000 2= **3 > + # CONTENTS, ALLOC, LOAD, DATA > + > + # Capture LMA and VMA columns for .data section > + if ![ regexp "\d*\d+\s+\.data\s+\d+\s+(\d+)\s+(\d+)" $output= dummy vma lma ] { Maybe my Tcl is getting rusty, but I'm surprised this quoting works. I'd have expected single backslashes to be interpreted as C-style sequences (for \n etc) and so be eaten before regexp sees them. Quoting with {...} instead of "..." would avoid that. > + verbose "Could not parse objdump output" 2 > + return 0 > + } else { > + return [string equal $vma $lma] > + } > + } else { > + remote_file build delete $exe > + verbose "Could not determine if VMA is equal to LMA. Assumin= g not equal." 2 > + return 0 > + } Would it be more conservative to return 1 on failure rather than 0? That way, a faulty test would trigger XFAILs rather than UNSUPPORTEDs, with XFAILs being more likely to get attention. On the other hand, I suppose we don't lose much if these tests are run on common targets only. So either way is OK, just asking. ;-) Thanks, Richard > + }] > +} > + > # The "noinit" attribute is only supported by some targets. > # This proc returns 1 if it's supported, 0 if it's not.