From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18004 invoked by alias); 12 Apr 2005 18:25:05 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 17927 invoked from network); 12 Apr 2005 18:24:59 -0000 Received: from unknown (HELO e34.co.us.ibm.com) (32.97.110.132) by sourceware.org with SMTP; 12 Apr 2005 18:24:59 -0000 Received: from westrelay01.boulder.ibm.com (westrelay01.boulder.ibm.com [9.17.195.10]) by e34.co.us.ibm.com (8.12.10/8.12.9) with ESMTP id j3CIOw5b141024 for ; Tue, 12 Apr 2005 14:24:58 -0400 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by westrelay01.boulder.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id j3CIOq5a236606 for ; Tue, 12 Apr 2005 12:24:52 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.12.11/8.12.11) with ESMTP id j3CIOq5C023156 for ; Tue, 12 Apr 2005 12:24:52 -0600 Received: from dyn9047022123-009047022128.beaverton.ibm.com (dyn9047022123-009047022128.beaverton.ibm.com [9.47.22.128]) by d03av01.boulder.ibm.com (8.12.11/8.12.11) with ESMTP id j3CIOql6023150; Tue, 12 Apr 2005 12:24:52 -0600 From: Paul Gilliam Reply-To: pgilliam@us.ibm.com To: gdb-patches@sources.redhat.com Subject: Re: [patch] add testsuite infrastructure to deal with shared libraries (now supports IBM's xlc compiler) Date: Tue, 12 Apr 2005 18:25:00 -0000 User-Agent: KMail/1.6.2 Cc: Daniel Jacobowitz References: <200504011440.16592.pgilliam@us.ibm.com> <20050401231259.GA3382@nevyn.them.org> <200504061049.10971.pgilliam@us.ibm.com> In-Reply-To: <200504061049.10971.pgilliam@us.ibm.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200504121123.27555.pgilliam@us.ibm.com> X-SW-Source: 2005-04/txt/msg00096.txt.bz2 On Wednesday 06 April 2005 10:49, Paul Gilliam wrote: > This patch is a slightly tweeked version of a part of this patch: > http://sources.redhat.com/ml/gdb-patches/2004-11/msg00538.html > > The first part of the patch modifies 'gdb_compile' to add platform-specific options to > 'target_compile' if a shared library was specified using "shlib=librarypath" in the options > argument to 'gdb_compile'. > > The second part of the patch adds the new proc 'gdb_compile_shlib' which is used to > build shared libraries in platform-specific ways. > > The tweek is to use 'test_compile_info' instead of $gcc_compiled. > > -=# Paul #=- > PS: How do I indicate in the change log that this is really the work of Daniel Jacobowitz? Here is a new version of the patch. This version allows for using IBM's xlc compiler. Ok to commit? -=# Paul #=- 2005-04-12 Paul Gilliam * lib/gdb.exp (gdb_compile) (gdb_compile_shlib)(NEW): Add infrustructure for building and using shared libraries Index: lib/gdb.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v retrieving revision 1.59 diff -c -3 -p -r1.59 gdb.exp *** lib/gdb.exp 6 Apr 2005 21:38:48 -0000 1.59 --- lib/gdb.exp 11 Apr 2005 22:10:07 -0000 *************** proc gdb_compile {source dest type optio *** 1335,1340 **** --- 1335,1369 ---- global gdb_wrapper_flags; global gdb_wrapper_initialized; + # Add platform-specific options if a shared library was specified using + # "shlib=librarypath" in OPTIONS. + set new_options "" + set shlib_found 0 + foreach opt $options { + if [regexp {^shlib=(.*)} $opt dummy_var shlib_name] { + if [test_compiler_info "xlc-*"] { + # IBM xlc compiler doesn't accept shared library named other + # than .so: use "-Wl," to bypass this + lappend source "-Wl,$shlib_name" + } else { + lappend source $shlib_name + } + if {$shlib_found == 0} { + set shlib_found 1 + if { ([test_compiler_info "gcc-*"] + && ([istarget "powerpc*-*-aix*"] + || [istarget "rs6000*-*-aix*"] )) } { + lappend options "additional_flags=-L${objdir}/${subdir}" + } elseif { [istarget "mips-sgi-irix*"] } { + lappend options "additional_flags=-rpath ${objdir}/${subdir}" + } + } + } else { + lappend new_options $opt + } + } + set options $new_options + if [target_info exists gdb_stub] { set options2 { "additional_flags=-Dusestubs" } lappend options "libs=[target_info gdb_stub]"; *************** proc gdb_compile_pthreads {source dest t *** 1405,1410 **** --- 1434,1497 ---- } } + # Build a shared library from SOURCES. You must use get_compiler_info + # first. + + proc gdb_compile_shlib {sources dest options} { + + set obj_options $options + + switch -glob [test_compiler_info] { + "xlc-*" { + lappend obj_options "additional_flags=-qpic" + } + "gcc-*" { + if { !([istarget "powerpc*-*-aix*"] + || [istarget "rs6000*-*-aix*"]) } { + lappend obj_options "additional_flags=-fpic" + } + } + default { + switch -glob [istarget] { + "hppa*-hp-hpux*" { + lappend obj_options "additional_flags=+z" + } + "mips-sgi-irix*" { + # Disable SGI compiler's implicit -Dsgi + lappend obj_options "additional_flags=-Usgi" + } + default { + # don't know what the compiler is... + } + } + } + } + + set outdir [file dirname $dest] + set objects "" + foreach source $sources { + set sourcebase [file tail $source] + if {[gdb_compile $source "${outdir}/${sourcebase}.o" object $obj_options] != ""} { + return -1 + } + lappend objects ${outdir}/${sourcebase}.o + } + + if [istarget "hppa*-*-hpux*"] { + remote_exec build "ld -b ${objects} -o ${dest}" + } else { + set link_options options + if [test_compiler_info "xlc-*"] { + lappend link_options "additional_flags=-qmkshrobj" + } else { + lappend link_options "additional_flags=-shared" + } + if {[gdb_compile "${objects}" "${dest}" executable $link_options] != ""} { + return -1 + } + } + } + # This is just like gdb_compile_pthreads, above, except that we always add the # objc library for compiling Objective-C programs proc gdb_compile_objc {source dest type options} {