This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] get_compiler_info should cache it's results


On Thu, Mar 10, 2005 at 03:57:05PM -0800, Paul Gilliam wrote:
> Hi all,
> 
> We are trying to use IBM's xlc compiler with the testsuite and have found 
> severial places that break because of differences if flags.  For example, gcc 
> uses '-shared' but xlc uses '-qmkshrobj' in order to indicate that a shared 
> object is to be produced.
> 
> I have written a tcl proc that will make this easyer.  It's kind of like a 
> special front-end to 'test_compiler_info', which depends on 
> 'get_compiler_info' being run first.
> 
> I would like to run get_compiler_info from within this new proc, but that 
> could result in running it multiple times in a given test.
> 
> For this reason, I would like 'get_compiler_info' to cache its resluts by 
> simply starting the proc with something like:
> 
> if [info exists compiler_info] {return 0}
> 
> Does anyone see any problems with this?

You need to be slightly more specific - cache it within $board, or
invalidate it somehow.  I don't know precisely when.  GDB's testsuite
isn't very good about this, but you are supposed to be able to run the
testsuite with multiple compilers in one invocation.

I like the idea though!

> 
> -=# Paul #=-
> 
> Here is the new proc (so far ;-):  
> 
> proc compile_flags { arg1 {arg2 ""} } {
>   if {"$arg2" == ""} then {
>     set list $arg1
>   } else {
>     upvar $arg1 lvar
>     set list $arg2
>   }
>   if ![info exists lvar] { set lvar {} }
>   get_compiler_info not-used
>   foreach {pat flist} $list {
>     if {$pat == {default}} {
>        return [eval $flist]
>     } elseif {[test_compiler_info $pat]} {
>       foreach flag $flist {
>         set lvar "$lvar additional_flags=$flag"
>       }
>       set lvar [string trim $lvar]
>       return $lvar
>     }
>   }
>   return {}
> }

I'm not sure about this bit, though.  Could you explain what you want
it to do, and how it would be used?  More informative variable names
might help too.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]