Opened 14 years ago

Closed 14 years ago

#68 closed enhancement (fixed)

SystemC library directory not detected correctly

Reported by: philipp.hartmann@… Owned by: Nicolas Pouillon
Priority: minor Component: soclib-cc
Keywords: Cc:

Description

If not explicitly set in the user's config, the SystemC library dir is not detected correctly. This is due to _platform() in source:trunk/soclib/utils/lib/python/soclib_cc/config/built-in.conf#L23.

For the officially supported achitectures, the following fail currently:

  • 64-bit Linux
  • Sun Solaris
  • HPUX

For "newer" versions of SystemC, the follwing are most probably not working as well:

  • Mac OSX (i386)
  • Windows (with MinGW)
  • FreeBSD (and FreeBSD 64-bit)

In our local scripts, we currently use the following mapping (with SYSTEM_ARCH defined by Autoconf):

 case "${SYSTEM_ARCH}" in
    sparc-sun-solaris*)               echo 'gccsparcOS5'  ;;
    x86_64*linux*)                    echo 'linux64'      ;;
    *linux*)                          echo 'linux'        ;;
    i?86-apple-macosx*)               echo 'macosx386'    ;;
    powerpc-apple-macosx*)            echo 'macosx'       ;;
    amd64*freebsd* | x86_64*freebsd*) echo 'freebsd64'    ;;
    *freebsd*)                        echo 'freebsd'      ;;
    *cygwin*)                         echo 'cygwin'       ;;
    *mingw*)                          echo 'mingw'        ;;
    *hpux11*)                         echo 'gcchpux11'    ;;
  esac

Attachments (2)

built-in.conf.diff (2.1 KB) - added by Nicolas Pouillon 14 years ago.
First attempt
built-in.conf.2.diff (2.2 KB) - added by Nicolas Pouillon 14 years ago.
Second attempt

Download all attachments as: .zip

Change History (11)

comment:1 Changed 14 years ago by Nicolas Pouillon

Type: defectenhancement

This table is interesting. Unfortunately, SYSTEM_ARCH is the kind of output spilled from config.guess (a beautiful but bloated shell script from GNU). I'm not quite sure calling config.guess each time soclib-cc is loaded is a good idea.

So I don't know any equivalent way of producing the SYSTEM_ARCH value expected here.

If you know an equivalent of this table, but indexed by an easy-to-obtain data (like output from python's os.uname() and sys.platform), I'll happily integrate it.

Other option I considered some day
make the default path "magic" in the way it looks into the filesystem and finds all the lib-* in ${SYSTEMC}…

Comments welcome

comment:2 Changed 14 years ago by Philipp A. Hartmann <philipp.hartmann@…>

I agree with your concerns of calling config.guess each time. To be honest, we obtain the architecture currently via the (GCC) compiler:

SYSTEM_ARCH:=`${CXX} -dumpmachine`

We actually only use it in case the environment variable SYSTEMC_LIB is not already set to the proper library directory.

"Porting" the table to a Python version based on platform.machine() and platform.system() should be possible, though. At least for the most popular platforms.

Changed 14 years ago by Nicolas Pouillon

Attachment: built-in.conf.diff added

First attempt

comment:3 Changed 14 years ago by Nicolas Pouillon

Integration proposal in built-in.conf.diff, does this improve anything ?

comment:4 Changed 14 years ago by philipp.hartmann@…

Looks good (although not tested yet, a colleague of mine will try it later). You might need to separate the FreeBSD64 case to two lines, though:

# might not work
  ("amd64*freebsd* | x86_64*freebsd*",  'freebsd64'  ),
# this should do it
  ("amd64*freebsd*",   'freebsd64'  ),
  ("x86_64*freebsd*",  'freebsd64'  ),

comment:5 Changed 14 years ago by philipp.hartmann@…

Another comment: In _guess_directory you fall back to the first lib- directory. Maybe it is safer to do this only in case of a unique match. For instance, we have shared installations, that contain several lib- directories for various architectures. Therefore, the first match is not always correct.

Something like:

from fnmatch import fnmatch

systemc = os.getenv('SYSTEMC')

if systemc:
    dirs = fnmatch.filter( os.listdir(systemc), 'lib-*' )
    if len(dirs) == 1:
        return dirs[0][4:]

return None

comment:6 Changed 14 years ago by Nicolas Pouillon

Sure, taking both remarks.

Changed 14 years ago by Nicolas Pouillon

Attachment: built-in.conf.2.diff added

Second attempt

comment:7 Changed 14 years ago by philipp.hartmann@…

Typo :-)

  if len(candidates) == 1: 
-     return d[0][4:]
+     return candidates[0][4:]

comment:8 Changed 14 years ago by Nicolas Pouillon

You were too fast, I fixed it meanwhile :)

comment:9 Changed 14 years ago by Nicolas Pouillon

Resolution: fixed
Status: newclosed

Attempt #2 integrated in [1849]

Note: See TracTickets for help on using tickets.