Hi Andreas, I think my local python lib is static-only. The old configuration allows me to do the compilation and end up with a very large gem5.opt binary (~200MB). Is that true that your new configuration only supports dynamic link? If so, I will reinstall my local python with --enabled-shared.
Thank you! Best, Xiangyu -----Original Message----- From: Rio Xiangyu Dong [mailto:[email protected]] Sent: Thursday, July 18, 2013 6:05 PM To: 'gem5 Developer List'; [email protected] Subject: RE: [gem5-dev] changeset in gem5: scons: Use python-config instead of distutils Hi Andreas, Both python and python-config point to my local python path (****), and the return values are: > python-config --includes -I****/usr/include/python2.6 > python-config --ldflags -L****/usr/lib/python2.6/config -lpthread -ldl -lutil -lm -lpython2.6 Best, Xiangyu -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Andreas Hansson Sent: Thursday, July 18, 2013 3:27 PM To: gem5 Developer List; [email protected] Subject: Re: [gem5-dev] changeset in gem5: scons: Use python-config instead of distutils Hi Xiangyu, Sorry to hear about the issues. Could you confirm that python/scons and python-config are pointing to the same python version? Also, could you check what python-config --includes and python-config --ldflags return? Thanks, Andreas On 7/18/13 11:02 PM, "Rio Xiangyu Dong" <[email protected]> wrote: >Hi Andreas, > >After applying this patch, I got a warning message during compilation: >(**** is my local python lib path) > >****/usr/lib/python2.6/config/libpython2.6.a(posixmodule.o): In >function >`posix_tmpnam': >****/Python-2.6.7/./Modules/posixmodule.c:7261: warning: the use of >`tmpnam_r' is dangerous, better use >`mkstemp'****/usr/lib/python2.6/config/libpython2.6.a(posixmodule.o): >In function `posix_tempnam': >****/Python-2.6.7/./Modules/posixmodule.c:7216: warning: the use of >`tempnam' is dangerous, better use `mkstemp' > >AND, I got an error message during runtime > >Traceback (most recent call last): > File "<string>", line 1, in <module> > File "/local_gem5/src/python/importer.py", line 80, in load_module > exec code in mod.__dict__ > File "/local_gem5/src/python/m5/__init__.py", line 44, in <module> > import SimObject > File "/local_gem5/src/python/importer.py", line 80, in load_module > exec code in mod.__dict__ > File "/local_gem5/src/python/m5/SimObject.py", line 48, in <module> > from m5.util import * > File "/local_gem5/src/python/importer.py", line 80, in load_module > exec code in mod.__dict__ > File "/local_gem5/src/python/m5/util/__init__.py", line 38, in <module> > from code_formatter import code_formatter > File "/local_gem5/src/python/importer.py", line 80, in load_module > exec code in mod.__dict__ > File "/local_gem5/src/python/m5/util/code_formatter.py", line 28, in ><module> > import inspect > File "****/usr/lib/python2.6/inspect.py", line 41, in <module> > from operator import attrgetter >ImportError: ****/usr/lib/python2.6/lib-dynload/operator.so: undefined >symbol: _Py_TrueStruct > >After reverting this change, both the warning and the error messages >are gone. Can you help me check which part of my local configurations >might conflict to this changelist? > >Best, >Xiangyu > >-----Original Message----- >From: [email protected] [mailto:[email protected]] On >Behalf Of Andreas Hansson >Sent: Thursday, July 18, 2013 5:25 AM >To: [email protected] >Subject: [gem5-dev] changeset in gem5: scons: Use python-config instead >of distutils > >changeset 9265bcff11b7 in /z/repo/gem5 >details: http://repo.gem5.org/gem5?cmd=changeset;node=9265bcff11b7 >description: > scons: Use python-config instead of distutils > > This patch changes how we determine the Python-related compiler and > linker flags. The previous approach used the internal LINKFORSHARED > which is not intended as part of the external API > (http://bugs.python.org/issue3588) and causes failures on recent OSX > installations. > > Instead of using distutils we now rely on python-config and scons > ParseConfig. For backwards compatibility we also parse out the > includes and libs although this could safely be dropped. The >drawback > of this patch is that Python 2.5 is now required, but hopefully that > is an acceptable compromise as any system with gcc 4.4 most likely > will have Python >= 2.5. > >diffstat: > > SConstruct | 91 >+++++++++++++++++++++++++++---------------------------------- > 1 files changed, 41 insertions(+), 50 deletions(-) > >diffs (123 lines): > >diff -r 52567889c9fc -r 9265bcff11b7 SConstruct >--- a/SConstruct Thu Jul 18 08:29:08 2013 -0400 >+++ b/SConstruct Thu Jul 18 08:29:28 2013 -0400 >@@ -1,5 +1,17 @@ > # -*- mode:python -*- > >+# Copyright (c) 2013 ARM Limited >+# All rights reserved. >+# >+# The license below extends only to copyright in the software and >+shall # not be construed as granting a license to any other >+intellectual # property including but not limited to intellectual >+property relating # to a hardware implementation of the functionality >+of the software # licensed hereunder. You may use the software >+subject to the license # terms below provided that you ensure that >+this notice is replicated # unmodified and in its entirety in all >+distributions of the software, # modified or unmodified, in source >+code or in binary form. >+# > # Copyright (c) 2011 Advanced Micro Devices, Inc. > # Copyright (c) 2009 The Hewlett-Packard Development Company # >Copyright >(c) 2004-2005 The Regents of The University of Michigan @@ -81,16 >+93,15 @@ """ > raise > >-# We ensure the python version early because we have stuff that -# >requires python 2.4 >+# We ensure the python version early because because python-config # >+requires python 2.5 > try: >- EnsurePythonVersion(2, 4) >+ EnsurePythonVersion(2, 5) > except SystemExit, e: > print """ > You can use a non-default installation of the Python interpreter by >-either >(1) rearranging your PATH so that scons finds the non-default -'python' >first or (2) explicitly invoking an alternative interpreter -on the >scons script. >+rearranging your PATH so that scons finds the non-default 'python' and >+'python-config' first. > > For more details, see: > >http://gem5.org/wiki/index.php/Using_a_non-default_Python_installation >@@ -827,55 +838,35 @@ > > conf = NullConf(main) > >-# Find Python include and library directories for embedding the -# >interpreter. For consistency, we will use the same Python -# >installation used to run scons (and thus this script). If you want -# >to link in an alternate version, see above for instructions on how -# >to invoke scons with a different copy of the Python interpreter. >-from distutils import sysconfig >- >-py_getvar = sysconfig.get_config_var >- >-py_debug = getattr(sys, 'pydebug', False) -py_version = 'python' + >py_getvar('VERSION') + (py_debug and "_d" or "") >- >-py_general_include = sysconfig.get_python_inc() -py_platform_include = >sysconfig.get_python_inc(plat_specific=True) >-py_includes = [ py_general_include ] >-if py_platform_include != py_general_include: >- py_includes.append(py_platform_include) >- >-py_lib_path = [ py_getvar('LIBDIR') ] >-# add the prefix/lib/pythonX.Y/config dir, but only if there is no -# >shared library in prefix/lib/. >-if not py_getvar('Py_ENABLE_SHARED'): >- py_lib_path.append(py_getvar('LIBPL')) >- # Python requires the flags in LINKFORSHARED to be added the >- # linker flags when linking with a statically with Python. Failing >- # to do so can lead to errors from the Python's dynamic module >- # loader at start up. >- main.Append(LINKFLAGS=[py_getvar('LINKFORSHARED').split()]) >- >-py_libs = [] >-for lib in py_getvar('LIBS').split() + py_getvar('SYSLIBS').split(): >- if not lib.startswith('-l'): >- # Python requires some special flags to link (e.g. -framework >- # common on OS X systems), assume appending preserves order >- main.Append(LINKFLAGS=[lib]) >- else: >- lib = lib[2:] >- if lib not in py_libs: >- py_libs.append(lib) >-py_libs.append(py_version) >- >-main.Append(CPPPATH=py_includes) >-main.Append(LIBPATH=py_lib_path) >- > # Cache build files in the supplied directory. > if main['M5_BUILD_CACHE']: > print 'Using build cache located at', main['M5_BUILD_CACHE'] > CacheDir(main['M5_BUILD_CACHE']) > >+# Find Python include and library directories for embedding the # >+interpreter. We rely on python-config to resolve the appropriate # >+includes and linker flags. ParseConfig does not seem to understand # >+the more exotic linker flags such as -Xlinker and -export-dynamic so # >+we add them explicitly below. If you want to link in an alternate # >+version of python, see above for instructions on how to invoke # scons >+with the appropriate PATH set. >+py_includes = readCommand(['python-config', '--includes'], >+ exception='').split() # Strip the -I from >+the include folders before adding them to the # CPPPATH >+main.Append(CPPPATH=map(lambda inc: inc[2:], py_includes)) >+ >+# Read the linker flags and split them into libraries and other link # >+flags. The libraries are added later through the call the CheckLib. >+py_ld_flags = readCommand(['python-config', '--ldflags'], >+exception='').split() py_libs = [] for lib in py_ld_flags: >+ if not lib.startswith('-l'): >+ main.Append(LINKFLAGS=[lib]) >+ else: >+ lib = lib[2:] >+ if lib not in py_libs: >+ py_libs.append(lib) > > # verify that this stuff works > if not conf.CheckHeader('Python.h', '<>'): >_______________________________________________ >gem5-dev mailing list >[email protected] >http://m5sim.org/mailman/listinfo/gem5-dev > >_______________________________________________ >gem5-dev mailing list >[email protected] >http://m5sim.org/mailman/listinfo/gem5-dev > -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. _______________________________________________ gem5-dev mailing list [email protected] http://m5sim.org/mailman/listinfo/gem5-dev _______________________________________________ gem5-dev mailing list [email protected] http://m5sim.org/mailman/listinfo/gem5-dev
