From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id uI7sF+Ydzl9CQgAAWB0awg (envelope-from ) for ; Mon, 07 Dec 2020 07:19:50 -0500 Received: by simark.ca (Postfix, from userid 112) id 5FEEC1F096; Mon, 7 Dec 2020 07:19:50 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 692931EFBB for ; Mon, 7 Dec 2020 07:19:49 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E2913833025; Mon, 7 Dec 2020 12:19:49 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 632C6385783D for ; Mon, 7 Dec 2020 12:19:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 632C6385783D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 786D9AC9A; Mon, 7 Dec 2020 12:19:45 +0000 (UTC) Date: Mon, 7 Dec 2020 13:19:43 +0100 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb/testsuite] Handle ada in gdb_compile_shlib Message-ID: <20201207121942.GA14289@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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: , Cc: Tom Tromey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Hi, The single test-case in the testsuite that creates an ada shared library is gdb.ada/catch_ex_std.exp. The test-case does use gdb_compile_shlib, but with a few tweaks that make sure things are properly handled for ada. Move the ada-specific code to gdb_compile_shlib, such that gdb_compile_sh can be used for ada shared libs without tweaks. Tested on x86_64-linux. Any comments? Thanks, - Tom [gdb/testsuite] Handle ada in gdb_compile_shlib gdb/testsuite/ChangeLog: 2020-12-07 Tom de Vries * lib/gdb.exp (gdb_compile_shlib): Handle ada. * gdb.ada/catch_ex_std.exp: Use gdb_compile_shlib to compile from source to shared lib. Add ada to options. --- gdb/testsuite/gdb.ada/catch_ex_std.exp | 21 +++-------------- gdb/testsuite/lib/gdb.exp | 41 +++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/gdb/testsuite/gdb.ada/catch_ex_std.exp b/gdb/testsuite/gdb.ada/catch_ex_std.exp index 31f062425b..c8acd70241 100644 --- a/gdb/testsuite/gdb.ada/catch_ex_std.exp +++ b/gdb/testsuite/gdb.ada/catch_ex_std.exp @@ -24,28 +24,13 @@ if { [skip_ada_tests] } { return -1 } standard_ada_testfile foo set srcfile2 [file join [file dirname $srcfile] some_package.adb] -set ofile2 [standard_output_file some_package.o] set sofile [standard_output_file libsome_package.so] set outdir [file dirname $binfile] -# To make an Ada shared library we have to jump through a number of -# hoops. - -# First compile to a .o. We can't compile directly to a .so because -# GCC rejects that: -# $ gcc -g -shared -fPIC -o qqz.o some_package.adb -# gcc: error: -c or -S required for Ada -# And, we can't compile in "ada" mode because dejagnu will try to -# invoke gnatmake, which we don't want. -if {[target_compile_ada_from_dir $outdir $srcfile2 $ofile2 \ - object {debug additional_flags=-fPIC}] != ""} { - return -1 -} - -# Now turn the .o into a shared library. -if {[gdb_compile_shlib $ofile2 $sofile \ - {debug additional_flags=-fPIC}] != ""} { +# Create the shared library. +if {[gdb_compile_shlib $srcfile2 $sofile \ + {ada debug additional_flags=-fPIC}] != ""} { return -1 } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index f2954fd519..e413bab93c 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4286,6 +4286,11 @@ proc gdb_compile_pthreads {source dest type options} { proc gdb_compile_shlib {sources dest options} { set obj_options $options + set ada 0 + if { [lsearch -exact $options "ada"] >= 0 } { + set ada 1 + } + set info_options "" if { [lsearch -exact $options "c++"] >= 0 } { set info_options "c++" @@ -4324,19 +4329,45 @@ proc gdb_compile_shlib {sources dest options} { set outdir [file dirname $dest] set objects "" foreach source $sources { - set sourcebase [file tail $source] if {[file extension $source] == ".o"} { # Already a .o file. lappend objects $source - } elseif {[gdb_compile $source "${outdir}/${sourcebase}.o" object \ - $obj_options] != ""} { - return -1 + continue + } + + set sourcebase [file tail $source] + + if { $ada } { + # Gnatmake doesn't like object name foo.adb.o, use foo.o. + set sourcebase [file rootname $sourcebase] + } + set object ${outdir}/${sourcebase}.o + + if { $ada } { + # Use gdb_compile_ada_1 instead of gdb_compile_ada to avoid the + # PASS message. + if {[gdb_compile_ada_1 $source $object object \ + $obj_options] != ""} { + return -1 + } } else { - lappend objects ${outdir}/${sourcebase}.o + if {[gdb_compile $source $object object \ + $obj_options] != ""} { + return -1 + } } + + lappend objects $object } set link_options $options + if { $ada } { + # If we try to use gnatmake for the link, it will interpret the + # object file as an .adb file. Remove ada from the options to + # avoid it. + set idx [lsearch $link_options "ada"] + set link_options [lreplace $link_options $idx $idx] + } if [test_compiler_info "xlc-*"] { lappend link_options "additional_flags=-qmkshrobj" } else {