From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 73C7338BE690 for ; Wed, 8 Jun 2022 13:38:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 73C7338BE690 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-85-ycmsR4DzMPCGScmuVDSMYQ-1; Wed, 08 Jun 2022 09:38:18 -0400 X-MC-Unique: ycmsR4DzMPCGScmuVDSMYQ-1 Received: by mail-wr1-f72.google.com with SMTP id i10-20020a5d55ca000000b002103d76ffcaso4866093wrw.17 for ; Wed, 08 Jun 2022 06:38:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=K9miVArO28r9XhRF7iLTsdIcGsyuc1bqOgVstrAs+e4=; b=Dd8aM/OLnl2QzBHHZiDL1hZDjY4Uc5axkVoNLYM8p/dOThHtTPIW+gq87ndWBDr95d boAaukG89lUzn/ba97I+pWuCdsf3PBUQ8eUu5ZqMdJ/HlYyuTr5T7rnnoueUs06DUHw+ L3OgT1iRRaVzn6UsoPimw1g5Ok5UqBmCNmE3bst+Td/ddE2ZJoieRooIj07RIHpQb26Z LnEw/WrPi+M/WVrEepp3vas5fk0EoVt5DlNrTfh8SaxxYs3v/97AHaG7VkazMt/Y2DnI UgxQCS4nBOoYGrKp8A5XMSXkOO6VDqonS8Fjr91PrZ5RGjInTWPlSywz+MPxXD/O9dWW Kgow== X-Gm-Message-State: AOAM532ilIrQq0aA2FV4P5LnfLaKzdO2xa0gPCS2jxEB0s5iqAO7JrDF xry05CJ3Th/obcaSZLx43ZXgc2uvcQGAMfwEAtZZ4m7WHcS1Kyf/Vw5/Q8eU8yWiGTd4Vx64bdQ bbpt3LA6Jc3ORb4bGFTLmlQ== X-Received: by 2002:a1c:f213:0:b0:39b:ad32:5e51 with SMTP id s19-20020a1cf213000000b0039bad325e51mr34478638wmc.72.1654695497520; Wed, 08 Jun 2022 06:38:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw51y16oPKXLuQD7ywoFDpLbWcLjsaPnr7JKdSekaLTwkNNH3fawn01EYNQFMa0dK6SIOIH8A== X-Received: by 2002:a1c:f213:0:b0:39b:ad32:5e51 with SMTP id s19-20020a1cf213000000b0039bad325e51mr34478615wmc.72.1654695497250; Wed, 08 Jun 2022 06:38:17 -0700 (PDT) Received: from localhost (host109-152-215-36.range109-152.btcentralplus.com. [109.152.215.36]) by smtp.gmail.com with ESMTPSA id q17-20020adff951000000b002103bd9c5acsm21318620wrr.105.2022.06.08.06.38.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 06:38:16 -0700 (PDT) Date: Wed, 8 Jun 2022 14:38:15 +0100 From: Andrew Burgess To: Pedro Alves Cc: Luis Machado , John Baldwin , gdb-patches@sourceware.org Subject: Re: [PATCH v2] aarch64: Add fallback if ARM_CC_FOR_TARGET not set (was: Re: [PATCH 5/5] gdb: native target invalid architecture detection) Message-ID: <20220608133815.GA4666@redhat.com> References: <71a986a5-2cfa-543e-4034-70f3af7dfecf@FreeBSD.org> <87ee09d4rt.fsf@redhat.com> <09afe250-9573-45e1-993b-a2f911f03630@arm.com> <87ilpdhn73.fsf@redhat.com> <87ee01hed4.fsf@redhat.com> <12c3913e-186d-b676-fe52-cc3322b00926@arm.com> <5c316bab-c2d3-309e-f938-7480e861b444@palves.net> <9c711ccb-a558-8225-524b-5a1fa93fcee9@arm.com> <22be6164-79d7-c0f7-1b1b-c633be452e81@palves.net> <755636d3-b2b5-9eeb-1b23-6f9830e3edbb@palves.net> MIME-Version: 1.0 In-Reply-To: <755636d3-b2b5-9eeb-1b23-6f9830e3edbb@palves.net> X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 14:36:41 up 2 days, 5:18, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2022 13:38:29 -0000 * Pedro Alves [2022-06-08 12:20:09 +0100]: > On 2022-06-08 11:12, Pedro Alves wrote: > > On 2022-06-08 08:54, Luis Machado wrote: > > > A 64-bit program can always exec a 32-bit program. Likewise the other way around. That should be > > debuggable with a single gdb. > > > > As you say, it's supported. So, better test it routinely. Not testing it doesn't gain us anything, > > other than leading to bitrot, as has happened. > > > >>> > >>> Maybe it would be possible to come up with a way to default ARM_CC_FOR_TARGET to > >>> something that works for most people when testing aarch64, somehow. > >> The problem is that a compiler is not enough to make things run fine. If you have an aarch64 > >> Ubuntu, for example, you'd need to add armhf as an architecture option and install both the > >> compiler and the libraries (libc6:armhf mostly). > > > > That is not an issue specific to aarch64. On x86-64, you need to install extra runtime > > packages to test -m32 too, just the compiler isn't enough, and those packages aren't installed > > by default. > > > >> > >> Another problem is that not every processor/kernel supports running a 32-bit process in a > >> 64-bit environment. This makes things more complicated. > >> > > > > Why "more complicated"? If you're worried about FAILs in the testsuite, then we can e.g. make it run > > the 32-bit program once outside gdb to check that running 32-bits works. If that fails, then > > we don't run the test. Seems simple, not complicated. > > Here's a new version of the patch, doing that. This version also moves the ARM_CC_FOR_TARGET fallback > discovery to lib/gdb.exp so it can be used by gdb.multi/multi-arch-exec.exp as well. I've now tested > this on gcc80 on the GCC compile farm (an aarch64 ubuntu 18.04 machine), and confirmed that it works. As in, > we pick the right compiler (turns out it is arm-linux-gnueabihf-gcc, the third fallback compiler, so the try-to-run > code is exercised). Of course, the testcases actually FAIL, due to > 32-bit support bitrot in gdb itself. Pedro, Thanks for finding the test (and improving it). I have a couple of patches that I'm working on that fixes the ARM on AArch64 functionality, and I'll make sure to test it using this updated test before posting to the m/l. Thanks, Andrew > > From 689671e40f88f1bf29af2433c7b6c7662c8f38c6 Mon Sep 17 00:00:00 2001 > From: Pedro Alves > Date: Tue, 7 Jun 2022 20:11:32 +0100 > Subject: [PATCH] aarch64: Add fallback if ARM_CC_FOR_TARGET not set > > On Aarch64, you can set ARM_CC_FOR_TARGET to point to the 32-bit > compiler to use when testing gdb.multi/multi-arch.exp and > gdb.multi/multi-arch-exec.exp. If you don't set it, then those > testcases don't run. > > I guess that approximately nobody remembers to set ARM_CC_FOR_TARGET. > > This commit adds a fallback. If ARM_CC_FOR_TARGET is not set, and > testing for Linux, try arm-linux-gnueabi-gcc, > arm-none-linux-gnueabi-gcc, arm-linux-gnueabihf-gcc as 32-bit > compilers, making sure that the produced executable runs on the target > machine before claiming that the compiler produces useful executables. > > Change-Id: Iefe5865d5fc84b4032eaff7f4c5c61582bf75c39 > --- > gdb/testsuite/gdb.multi/multi-arch-exec.exp | 4 +- > gdb/testsuite/gdb.multi/multi-arch.exp | 4 +- > gdb/testsuite/lib/gdb.exp | 57 +++++++++++++++++++++ > 3 files changed, 61 insertions(+), 4 deletions(-) > > diff --git a/gdb/testsuite/gdb.multi/multi-arch-exec.exp b/gdb/testsuite/gdb.multi/multi-arch-exec.exp > index a1496fb5571..a8e81e29ee9 100644 > --- a/gdb/testsuite/gdb.multi/multi-arch-exec.exp > +++ b/gdb/testsuite/gdb.multi/multi-arch-exec.exp > @@ -62,8 +62,8 @@ proc append_arch2_options {options_var} { > upvar 1 $options_var options > > if { [istarget "aarch64*-*-*"] } { > - if {[info exists ARM_CC_FOR_TARGET]} { > - lappend options "compiler=${ARM_CC_FOR_TARGET}" > + if {[arm_cc_for_target] != ""} { > + lappend options "compiler=[arm_cc_for_target]" > return 1 > } else { > unsupported "ARM compiler is not known" > diff --git a/gdb/testsuite/gdb.multi/multi-arch.exp b/gdb/testsuite/gdb.multi/multi-arch.exp > index e5c2d9cc161..b564e6caf25 100644 > --- a/gdb/testsuite/gdb.multi/multi-arch.exp > +++ b/gdb/testsuite/gdb.multi/multi-arch.exp > @@ -60,8 +60,8 @@ if { [build_executable "failed to prepare" ${exec1} "${srcfile1}" \ > set options [list debug] > > if [istarget "aarch64*-*-*"] { > - if {[info exists ARM_CC_FOR_TARGET]} { > - lappend options "compiler=${ARM_CC_FOR_TARGET}" > + if {[arm_cc_for_target] != ""} { > + lappend options "compiler=[arm_cc_for_target]" > } else { > unsupported "ARM compiler is not known" > return -1 > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index 402450152ac..ac01a31655f 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -8666,5 +8666,62 @@ proc get_set_option_choices {set_cmd} { > return $values > } > > +# Return the compiler that can generate 32-bit ARM executables. Used > +# when testing biarch support on aarch64. If ARM_CC_FOR_TARGET is > +# set, use that. If not, try a few common compiler names, making sure > +# that the executable they produce can run. > + > +gdb_caching_proc arm_cc_for_target { > + if {[info exists ARM_CC_FOR_TARGET]} { > + # If the user specified the compiler explicitly, then don't > + # check whether the resulting binary runs outside GDB. Assume > + # that it does, and if it turns out it doesn't, then the user > + # should get loud FAILs, instead of UNSUPPORTED. > + return $ARM_CC_FOR_TARGET > + } > + > + # Fallback to a few common compiler names. Also confirm the > + # produced binary actually runs on the system before declaring > + # we've found the right compiler. > + > + if [istarget "*-linux*-*"] { > + set compilers { > + arm-linux-gnueabi-gcc > + arm-none-linux-gnueabi-gcc > + arm-linux-gnueabihf-gcc > + } > + } else { > + set compilers {} > + } > + > + foreach compiler $compilers { > + if {![is_remote host] && [which $compiler] == 0} { > + # Avoid "default_target_compile: Can't find > + # $compiler." warning issued from gdb_compile. > + continue > + } > + > + set src { int main() { return 0; } } > + if {[gdb_simple_compile aarch64-32bit \ > + $src \ > + executable [list compiler=$compiler]]} { > + > + set result [remote_exec target $obj] > + set status [lindex $result 0] > + set output [lindex $result 1] > + > + file delete $obj > + > + if { $output != "" || $status != 0} { > + continue > + } > + > + return $compiler > + } > + } > + > + return "" > +} > + > # Always load compatibility stuff. > load_lib future.exp > > base-commit: bcdbf606bc054bd1fa9a1c8978f2d3a57e42adf4 > -- > 2.36.0 >