From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3104 invoked by alias); 8 Nov 2013 02:45:48 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 3095 invoked by uid 89); 8 Nov 2013 02:45:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.9 required=5.0 tests=AWL,BAYES_50,RDNS_NONE,SPAM_SUBJECT,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: rock.gnat.com Received: from Unknown (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 08 Nov 2013 02:45:45 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id A0A84116670; Thu, 7 Nov 2013 21:46:07 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 2nig4GaoNzn1; Thu, 7 Nov 2013 21:46:07 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 38AAB1165EF; Thu, 7 Nov 2013 21:46:07 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 03BD6E11FA; Fri, 8 Nov 2013 06:45:29 +0400 (RET) Date: Fri, 08 Nov 2013 02:45:00 -0000 From: Joel Brobecker To: Steve Ellcey Cc: gdb@sourceware.org Subject: Re: GDB/Python configuration question Message-ID: <20131108024528.GN7563@adacore.com> References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="envbJBWh7q8WU6mo" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2013-11/txt/msg00014.txt.bz2 --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 860 > The reason is that "python-config.py --ldflags" is returning: > > -L/local/home/sellcey/gcc/mt/src/install-python/lib/python2.7/config -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic > > and if I link with this I get undefined references because libpython2.7 is > listed *after* libutil, libm, and libdl and is an archive library. If I > move it before (by hand) the link works. > > Has anyone else run into this? I don't remember which issues we ran into when building GDB against a static version of libpython, but we've had to make a number of changes to python-config.py. I do see in your output the one I remember making for GNU/Linux, though (-export-dynamic). The only difference in outupt with the script we use is an extra -static-libgcc at the end. JIC, here is our python-config.py, in case it helps in your case. -- Joel --envbJBWh7q8WU6mo Content-Type: text/x-python; charset=us-ascii Content-Disposition: attachment; filename="python-config.py" Content-length: 5214 # Program to fetch python compilation parameters. # Copied from python-config of the 2.7 release. import sys import os import getopt from distutils import sysconfig import platform valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags', 'ldflags', 'help'] def exit_with_usage(code=1): sys.stderr.write ("Usage: %s [%s]\n" % (sys.argv[0], '|'.join('--'+opt for opt in valid_opts))) sys.exit(code) try: opts, args = getopt.getopt(sys.argv[1:], '', valid_opts) except getopt.error: exit_with_usage() if not opts: exit_with_usage() pyver = sysconfig.get_config_var('VERSION') getvar = sysconfig.get_config_var abiflags = getattr (sys, "abiflags", "") opt_flags = [flag for (flag, val) in opts] if '--help' in opt_flags: exit_with_usage(code=0) def to_unix_path(path): """On Windows, returns the given path with all backslashes converted into forward slashes. This is to help prevent problems when using the paths returned by this script with cygwin tools. In particular, cygwin bash treats backslashes as a special character. On Unix systems, returns the path unchanged. """ if os.name == 'nt': path = path.replace('\\', '/') # At AdaCore, the prefix we provide to the configure script # does not contain drive letters. If this path starts with # a drive letter, then we need to remove it. Otherwise, # the crude path-matching algorithm used in the configure # script to determine whether the path ought to be relocatable # or not will trip, purely because it does not know about # drive letters. import re if re.match("[a-zA-Z]:/", path): path = path[2:] return path for opt in opt_flags: if opt == '--prefix': print (to_unix_path(sysconfig.PREFIX)) elif opt == '--exec-prefix': print (to_unix_path(sysconfig.EXEC_PREFIX)) elif opt in ('--includes', '--cflags'): flags = ['-I' + sysconfig.get_python_inc(), '-I' + sysconfig.get_python_inc(plat_specific=True)] if opt == '--cflags': flags.extend(getvar('CFLAGS').split()) print (to_unix_path(' '.join(flags))) elif opt in ('--libs', '--ldflags'): libs = [] if getvar('LIBS') is not None: libs.extend(getvar('LIBS').split()) if getvar('SYSLIBS') is not None: libs.extend(getvar('SYSLIBS').split()) libs.append('-lpython'+pyver + abiflags) # add the prefix/lib/pythonX.Y/config dir, but only if there is no # shared library in prefix/lib/. if opt == '--ldflags': if not getvar('Py_ENABLE_SHARED'): # Do not rely on the LIBPL variable as the offical version # of this script does, as this variable is not relocated # (which means that if Python is installed at at different # location than the configure prefix, LIBPL is wrong). # # FIXME: The following code assumes that Python was # configured without --with-libdir, and thus is not # strictly correct either. if os.name == 'nt': from platform import architecture if architecture()[0].startswith('64'): # For 64bit Windows /libpython[...].dll # is actually an import library. libdir = sysconfig.PREFIX else: # On 32bit Windows, however, the import library # is inside /libs. libdir = sysconfig.PREFIX + '/libs' else: libdir = sysconfig.get_python_lib(standard_lib=True) \ + '/config' libs.insert(0, '-L' + libdir) if platform.system() == 'Linux': # Make sure that the loader can resolve symbols from # the libpython archive when loading modules implemented # as DSOs (Eg: "import time"). This is to work around # a side-effect of linking against the static version # of libpython. libs.insert(0, '-Xlinker -export-dynamic') linkforshared = getvar('LINKFORSHARED') if linkforshared is not None: if platform.system() == 'AIX': # On this platform, one of the options is # missing the full path to the .exp file # (an Export file), causing the link to fail. # Fix that path... linkforshared = linkforshared.replace( '-bE:Modules/python.exp', '-bE:%s/python.exp' % libdir) # The python library also depends on libm, which # needs to be added after -lpython... linkforshared += ' -lm' libs.extend(linkforshared.split()) print (to_unix_path(' '.join(libs))) --envbJBWh7q8WU6mo--