I too am experiencing the exact problem described below. I'm running Linux 
2.4.21-47.ELsmp x86_64, g++ 3.4.0, Python 2.4, scons-local 0.96.92, and SWIG 
1.3.28.

It seems that something funny is going on since importing struct in the 
standalone interpreter works fine:

$ python
Python 2.4 (#3, Feb 23 2005, 12:16:30)
[GCC 3.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import struct
>>> struct.__name__
'struct'
>>>

And it looks like the executable was linked correctly since the symbol is 
defined:

$ nm m5.debug | grep PyString_Type
000000000082d480 D PyString_Type


I should also mention that getting m5 to build wasn't straightforward since g++ 
didn't like the "new SimLoopExitEvent(...)" in cache_impl.hh:

g++ -o build/ALPHA_SE/mem/cache/cache.do -c -pipe -fno-strict-aliasing -Wall 
-Wno-sign-compare -Werror -Wundef -g3 -gdwarf-2 -O0 -DTHE_ISA=ALPHA_ISA -DDEBUG 
-Iext/dnet -I/tool/pandora64/.package/python-2.4/include/python2.4 
-Ibuild/libelf/include -Ibuild/ALPHA_SE build/ALPHA_SE/mem/cache/cache.cc
In file included from build/ALPHA_SE/mem/cache/cache.cc:75:
build/ALPHA_SE/mem/cache/cache_impl.hh: In member function `bool 
Cache<TagStore, Buffering, Coherence>::access(Packet*&)':
build/ALPHA_SE/mem/cache/cache_impl.hh:243: warning: statement has no effect
scons: *** [build/ALPHA_SE/mem/cache/cache.do] Error 1
scons: building terminated because of errors.

I got around this with a kludgey fix to fool the compiler:
  if (missCount == 0)
  {
    SimLoopExitEvent *e = new SimLoopExitEvent(curTick, "A cache reached the 
maximum miss count");
    SimLoopExitEvent *z = e;  //UGLY HACK
    e = z;
  }

But then the linker complained about undefined references

/tool/pandora64/.package/python-2.4/lib/python2.4/config/libpython2.4.a(posixmodule.o):
 In function `posix_tmpnam':
posix_statvfs/./Modules/posixmodule.c:6158: the use of `tmpnam_r' is dangerous, 
better use `mkstemp'
/tool/pandora64/.package/python-2.4/lib/python2.4/config/libpython2.4.a(posixmodule.o):
 In function `posix_tempnam':
posix_statvfs/./Modules/posixmodule.c:6113: the use of `tempnam' is dangerous, 
better use `mkstemp'
/tool/pandora64/.package/python-2.4/lib/python2.4/config/libpython2.4.a(dynload_shlib.o):
 In function `_PyImport_GetDynLoadFunc':
st_ctim/Python/dynload_shlib.c:138: undefined reference to `dlsym'
st_ctim/Python/dynload_shlib.c:130: undefined reference to `dlopen'
st_ctim/Python/dynload_shlib.c:133: undefined reference to `dlerror'

...(etc, etc)...

collect2: ld returned 1 exit status
scons: *** [build/ALPHA_SE/m5.debug.bin] Error 1
scons: building terminated because of errors.


I ran this in the python standalone and it gave a list of libraries that my 
Python installation seems to need:
>>> from distutils.sysconfig import get_config_var
>>> print get_config_var("LIBS") + get_config_var("SYSLIBS")
-lpthread -ldl  -lutil -lm

So I had to add these lines to the SConscript after the point where LIBS=['z'] 
gets appended to env (line ~221)
    env.Append(LIBS=['pthread'])
    env.Append(LIBS=['dl'])
    env.Append(LIBS=['util'])
    env.Append(LIBS=['m'])

And only then did it compile and give the error that Michael is also seeing. I 
think I'm going to have to try a new installation of Python...

-Kalim


-----Original Message-----
From: Nathan Binkert [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 23, 2006 8:19 AM
To: M5 users mailing list
Subject: Re: [m5-users] Python version for M5 2.0b1


I actually had this problem the other day on my mac using darwinports. 
It seems that the problem has to do with a messed up python install.  At 
least things were fixed when I downgraded python to 2.4.2.  I'm guessing 
that it is a packaging problem of some sort.

   Nate

> That's very bizarre... we have 2.4.3 and have no problems.  I'm sure it has 
> more to do with how your Python is installed on your system than what version 
> it is.  What OS/distro are you using?  Did you install Python from a standard 
> package/rpm or from source?  Do you have multiple versions of Python 
> installed on the machine?
>
> The scons script tries to deduce the correct Python directories by querying 
> the Python interpreter that's running scons itself, using what I think are 
> the standard, official methods, so I'd say that at best your Python install 
> is unusual (in which case we'd want to fix our scons scripts to deal with it) 
> and at worst maybe you need to reinstall Python.
>
> Keep us posted.
>
> Steve
>
> Michael Van Biesbrouck wrote:
>> I attempted to build M5 using Python 2.4.3 (the current stable
>> release), but have run into problems suggesting that this version is
>> not compatible with M5.  First, the scons scripts auto-generated the
>> wrong directory for linking to libpython2.4.a.  That I was able to
>> fix, but I also need to add dl, pthread and util to the libraries
>> linked.  After those changes I was able to build M5 but it fails to
>> run correctly during the dynamic loading of Python modules.  The build
>> tests fail with this message:
>> 
>> Traceback (most recent call last):
>>  File "<string>", line 1, in ?
>>  File "build/ALPHA_SE/python/m5/__init__.py", line 79, in ?
>>    from main import options, arguments, main
>>  File "build/ALPHA_SE/python/m5/main.py", line 30, in ?
>>    import code, optparse, os, socket, sys
>>  File "/projects/mvanbies/m5_2.0_b1/tools//lib/python2.4/optparse.py",
>> line 72, in ?
>>    from gettext import gettext as _
>>  File "/projects/mvanbies/m5_2.0_b1/tools//lib/python2.4/gettext.py",
>> line 49, in ?
>>    import locale, copy, os, re, struct, sys
>> ImportError: 
>> /projects/mvanbies/m5_2.0_b1/tools/lib/python2.4/lib-dynload/struct.so:
>> undefined symbol: PyString_Type
>> Traceback (most recent call last):
>>  File "<string>", line 1, in ?
>> NameError: name 'm5' is not defined
>> 
>> Michael
>> _______________________________________________
>> m5-users mailing list
>> [email protected]
>> http://m5sim.org/cgi-bin/mailman/listinfo/m5-users
> _______________________________________________
> m5-users mailing list
> [email protected]
> http://m5sim.org/cgi-bin/mailman/listinfo/m5-users
>



_______________________________________________
m5-users mailing list
[email protected]
http://m5sim.org/cgi-bin/mailman/listinfo/m5-users

Reply via email to