From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1551) id 92CB7387477F; Wed, 8 Jun 2022 13:07:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92CB7387477F Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pedro Alves To: gdb-cvs@sourceware.org Subject: [binutils-gdb] aarch64: Add fallback if ARM_CC_FOR_TARGET not set X-Act-Checkin: binutils-gdb X-Git-Author: Pedro Alves X-Git-Refname: refs/heads/master X-Git-Oldrev: 57698478b75319a962b899c3f8d3a03baa5eaab4 X-Git-Newrev: bc2220c89de813bf67d4172a4c483d1e2b843366 Message-Id: <20220608130720.92CB7387477F@sourceware.org> Date: Wed, 8 Jun 2022 13:07:20 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2022 13:07:20 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dbc2220c89de8= 13bf67d4172a4c483d1e2b843366 commit bc2220c89de813bf67d4172a4c483d1e2b843366 Author: Pedro Alves Date: Tue Jun 7 20:11:32 2022 +0100 aarch64: Add fallback if ARM_CC_FOR_TARGET not set =20 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. =20 I guess that approximately nobody remembers to set ARM_CC_FOR_TARGET. =20 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. =20 Change-Id: Iefe5865d5fc84b4032eaff7f4c5c61582bf75c39 Diff: --- gdb/testsuite/gdb.multi/multi-arch-exec.exp | 4 +-- gdb/testsuite/gdb.multi/multi-arch.exp | 4 +-- gdb/testsuite/lib/gdb.exp | 55 +++++++++++++++++++++++++= ++++ 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/gdb.multi/multi-arch-exec.exp b/gdb/testsuite/gd= b.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 =20 if { [istarget "aarch64*-*-*"] } { - if {[info exists ARM_CC_FOR_TARGET]} { - lappend options "compiler=3D${ARM_CC_FOR_TARGET}" + if {[arm_cc_for_target] !=3D ""} { + lappend options "compiler=3D[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.mul= ti/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} "${sr= cfile1}" \ set options [list debug] =20 if [istarget "aarch64*-*-*"] { - if {[info exists ARM_CC_FOR_TARGET]} { - lappend options "compiler=3D${ARM_CC_FOR_TARGET}" + if {[arm_cc_for_target] !=3D ""} { + lappend options "compiler=3D[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..6a3fed110a8 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -8666,5 +8666,60 @@ proc get_set_option_choices {set_cmd} { return $values } =20 +# 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] =3D=3D 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=3D$compiler]]} { + + set result [remote_exec target $obj] + set status [lindex $result 0] + set output [lindex $result 1] + + file delete $obj + + if { $output =3D=3D "" && $status =3D=3D 0} { + return $compiler + } + } + } + + return "" +} + # Always load compatibility stuff. load_lib future.exp