From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [96.47.72.81]) by sourceware.org (Postfix) with ESMTPS id 9E3DC38344C1 for ; Wed, 8 Jun 2022 19:01:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9E3DC38344C1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 2FC9376430; Wed, 8 Jun 2022 19:01:21 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LJGm10VBWz3HRh; Wed, 8 Jun 2022 19:01:21 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654714881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rcTatnYQJ9C3zvLDVqTklMLRAn6/TzpLD//ENmkKJnE=; b=DP0oggL5BySRvkNXwMer/a24Fsvw4aqKVViStqNTFkOKuPROHxIoD8hvw4DjnRH9QILvWW AVVDq+V8o3Bb04+pXuxOlNUhe16Peitu9OaqKtKeGtnjtGSM406veZ4H+l7znGFmelszZb qGdbpqbdZxyEYfF5GK8Atlc6sQP3nDMDsoMwTk2ZgNrPnQQGOLrvyG4jJSk/zgb1ePPFw3 ukn6X47F1r1Kjp8D61V/pD3jD/ttyMsLLDy5p0EdR8+BcpxyzhCjtav1mUq9NVznMoPx6N njSrv+KAz7t1OnmYBEIfsNa4uLN/R2EvuNyDId2iO6Y5cTah6oxp4zshuoZWIQ== Received: from [IPV6:2601:648:8680:ed60:e0f8:9963:efdb:d103] (unknown [IPv6:2601:648:8680:ed60:e0f8:9963:efdb:d103]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 770E261DF; Wed, 8 Jun 2022 19:01:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <5528f112-1674-0f37-7a80-a77db8d1a31c@FreeBSD.org> Date: Wed, 8 Jun 2022 12:01:18 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 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) Content-Language: en-US To: Pedro Alves , Luis Machado , Andrew Burgess , gdb-patches@sourceware.org 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> From: John Baldwin In-Reply-To: <755636d3-b2b5-9eeb-1b23-6f9830e3edbb@palves.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654714881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rcTatnYQJ9C3zvLDVqTklMLRAn6/TzpLD//ENmkKJnE=; b=SFlS4Owl1ZYoDkofR4T5nvXC5m51ccSuTiBsZf2hLG8grxLWHOr4jwKvf6AQGblHku0qLE l6jWB+4IsAG7kr434akRretPOwxfKIzzZKvELMTGu0revwU9Y8yeQUnlXlW7nVwHqKul8K lkOQ+9DlTYcr2Y8Pa685zUj4uXd3rACsZVcN82FyFcOF/cc8tLpzo5vvIWgXHJgsHcND8u RLZjYVJ9htUA+JEtXB1nZLcL+BSYqQ3U8KlKcjWN4wdz7Cj1iPgCeYZ9CWieYj4oHaPJZC lguweZjiZAICTDmxk72BUH/HIYpoJIZvHoi3YMLUHb6fweRcQLsDQVHkJz7Bag== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1654714881; a=rsa-sha256; cv=none; b=Otl5jEIl9YimWipW5urvj2Nj3j2Ehw0s7U5o786OHHaTmL9nZinhXJ/5WWTXfxS8pTBZBI vidybHnihXh7r2nrbqd1KsL6m8Rh/xJciqHHKujx2Nr0Nh9gCGcOQ5Wog1GHZgKORT1vTl vwOQpXr1A5Oc5oyCnJyTfwQpbLcQJa9/HTTT4w49bh8ex1Dzxw7XkRY5YAW1CMn1pBb//C P/LeVBmzAjS5OxDTVhbMerccgBpTTbq/osLjV76SwTTm/wClxE/w/dXqcWQb78JgGFXVKU ew27qP05VkrbdsvAAAO0srW2Lm7Ee2JiS7WMK9w0J/nz1f2O1SJ9EmTvIhYgHw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, 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 19:01:23 -0000 On 6/8/22 4:20 AM, Pedro Alves wrote: > 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. > > 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. Note that if the target compiler is clang, it will probably already support 32-bit ARM via a -target option. Not sure if you want to try to handle that case here as well? The other wrinkle perhaps is that just because you have a capable compiler around may not mean that you have 32-bit libraries available to link against? I'm not sure if the compilers you list in your patch ensure that you have an ARM libc around as well via dependencies. -- John Baldwin