From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4111 invoked by alias); 11 Mar 2005 00:01:53 -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 4049 invoked from network); 11 Mar 2005 00:01:42 -0000 Received: from unknown (HELO e35.co.us.ibm.com) (32.97.110.133) by sourceware.org with SMTP; 11 Mar 2005 00:01:42 -0000 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by e35.co.us.ibm.com (8.12.10/8.12.9) with ESMTP id j2B01fLg233968 for ; Thu, 10 Mar 2005 19:01:41 -0500 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay05.boulder.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id j2B01f2i156800 for ; Thu, 10 Mar 2005 17:01:41 -0700 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 j2B01eLI014845 for ; Thu, 10 Mar 2005 17:01:41 -0700 Received: from dyn319633.beaverton.ibm.com (DYN319633.beaverton.ibm.com [9.47.22.123]) by d03av01.boulder.ibm.com (8.12.11/8.12.11) with ESMTP id j2B01ehm014829; Thu, 10 Mar 2005 17:01:40 -0700 From: Paul Gilliam Reply-To: pgilliam@us.ibm.com To: gdb-patches@sources.redhat.com Subject: [RFC] get_compiler_info should cache it's results Date: Fri, 11 Mar 2005 00:01:00 -0000 User-Agent: KMail/1.6.2 Cc: Daniel Jacobowitz MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200503101557.05919.pgilliam@us.ibm.com> X-SW-Source: 2005-03/txt/msg00178.txt.bz2 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? -=# 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 just realized that this ignores the second argument to 'get_compiler_info' which defaults to 'c' but could be 'c++' (and someday may be ada, fortran, pascal ...) I guess my 'compile_flags' would need a 'language' argument to pass to 'get_compiler_info', which could cache it's results with an array indexed by 'language'.