From 9544e8fbe0c47d5d4e62b2b8cbbcfb4f1a212037 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Thu, 14 Mar 2013 16:08:55 +0100 Subject: [PATCH] scons: Check for known buggy version of SWIG (2.0.9) SWIG version 2.0.9 uses fully qualified module names despite of the importing module being in the same package as the imported module. This has the unfortunate consequence of causing the following error when importing m5.internal.event: Traceback (most recent call last): File "", line 1, in File "src/python/importer.py", line 75, in load_module exec code in mod.__dict__ File "src/python/m5/__init__.py", line 35, in import internal File "src/python/importer.py", line 75, in load_module exec code in mod.__dict__ File "src/python/m5/internal/__init__.py", line 32, in import event File "src/python/importer.py", line 75, in load_module exec code in mod.__dict__ File "build/X86/python/swig/event.py", line 107, in class Event(m5.internal.serialize.Serializable): AttributeError: 'module' object has no attribute 'internal' When 'event' is loaded, it triggers 'serialize' to be loaded. However, it seems like the dictionary of 'm5' isn't updated until after __init__.py terminates, which means that 'event' never sees the 'internal' attribute on 'm5'. Older versions of SWIG didn't include the fully qualified module name if the modules were in the same package. --- SConstruct | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/SConstruct b/SConstruct index 4ca4ae56d..a5a598660 100755 --- a/SConstruct +++ b/SConstruct @@ -713,6 +713,15 @@ if compareVersions(swig_version[2], min_swig_version) < 0: print ' Installed version:', swig_version[2] Exit(1) +if swig_version[2] == "2.0.9": + print '\n' + termcap.Yellow + termcap.Bold + \ + 'Warning: SWIG version 2.0.9 sometimes generates broken code.\n' + \ + termcap.Normal + \ + 'This problem only affects some platforms and some Python\n' + \ + 'versions. See the following SWIG bug report for details:\n' + \ + 'http://sourceforge.net/p/swig/bugs/1297/\n' + + # Set up SWIG flags & scanner swig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS') main.Append(SWIGFLAGS=swig_flags) -- 2.30.2