Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'modified': 0.07; 'subject:Question': 0.07; 'append': 0.09; 'line:': 0.09; 'linker': 0.09; 'setup.py': 0.09; 'subject:How': 0.10; 'python': 0.11; 'objects.': 0.16; 'skip:[ 30': 0.16; 'subject:Add': 0.16; 'variable.': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'basically': 0.19; 'seems': 0.21; 'command': 0.22; 'to:name:python- list@python.org': 0.22; 'this?': 0.23; 'copied': 0.24; 'instance,': 0.24; 'skip:e 30': 0.24; 'mon,': 0.24; 'environment': 0.24; 'script': 0.25; 'pass': 0.26; 'values': 0.27; 'header:In- Reply-To:1': 0.27; 'unix': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'gcc': 0.31; 'libraries': 0.31; 'option': 0.32; 'run': 0.32; 'another': 0.32; 'sources': 0.33; 'device': 0.34; 'problem': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'building': 0.35; 'subject:?': 0.36; 'should': 0.36; 'skip:- 20': 0.37; 'area': 0.37; 'being': 0.38; 'depends': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'most': 0.60; 'back': 0.62; 'linked': 0.65; 'subject:Build': 0.68; 'default': 0.69; 'article': 0.77; 'ldflags': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=RuWVJM5eVSMviaJz6ALt1KSbJWVZu0VwDlZqtdpn4rU=; b=rxy9NAHYaaaCi61veutYdkRDoBkswzkr/HC3gKCcB1GK1PPB+7i1CoUmm/6RYjDqPa PShFePHEIso64cUVLB783pGHkLR0J4Rj8Ta92iDx9WwQTjlsa06x5MaFgz5N6ouMCTMZ M9vK31dty4d4t0nUlMd17VZ3z6ISvHS5dC8ntBrLZs8SIvWsXLSu2qhrINi4UtEQ4eJs BteVpyV02j9jttRpcASkpWpOi91zbP342bGsRa+7mN8o5og4VytfRIciT6I90NkHP6Jz dxKCD6fDdti/ICWM6hMzH2HvhJKu8IgbxfSek6IZMyp35Etrk046sTTtLjxHrBUNEmAS uXRw== MIME-Version: 1.0 X-Received: by 10.60.47.40 with SMTP id a8mr23296274oen.18.1414452036858; Mon, 27 Oct 2014 16:20:36 -0700 (PDT) In-Reply-To: References: Date: Mon, 27 Oct 2014 18:20:36 -0500 Subject: Re: Build Question: How to Add -Wl, --option Before Objects In Setup.py? From: Cyd Haselton To: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414452046 news.xs4all.nl 2845 [2001:888:2000:d::a6]:56969 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 5388 X-Received-Body-CRC: 2502354809 Xref: csiph.com comp.lang.python:79809 On Mon, Oct 27, 2014 at 3:39 PM, Ned Deily wrote: > In article > , > Cyd Haselton wrote: >> I need to add a linker option to the command(s) run by setup.py when >> building various objects. I'm not familiar with Python at all, so I >> basically copied and modified a line from one area of the script to >> another >> >> >> ext_modules=[Extension('_struct', ['_struct.c'], extra_link_args = >> ['Wl,--allow-shlib-undefined'])], >> *snip* >> >> Unfortunately this seems to append the option to the end of the >> command line. What's the best (fastest) way to add it before the >> object being built (objectname.o)? > > It depends on what system and build tools that you are using and that > the Python you are using was built with but, in general on most > POSIX-like systems, one way to do it should be to supply it via an > LDFLAGS environment variable. The safest approach would be to get the > default value of LDFLAGS for this Python instance, append your > additional values to it, and pass it back into the setup.py build. You > can do that all in one line: > > LDFLAGS="$(python -c 'import > sysconfig;print(sysconfig.get_config_var("LDFLAGS"))') > -Wl,--allow-shlib-undefined" python setup.py build > > -- > Ned Deily, > nad@acm.org > I'm building python on an Android device in the KBOX environment...which simulates a Unix type filesystem. Python isn't installed; I'm building from sources (2.7.8) with GCC 4.8.0 and make. The problem with the LDFLAGS approach is that some of the libraries that must be linked (-lc -ldl) do not need the --allow-shlib-undefined option...it's only the lpython2.7 that does. Any way to do this? Cyd Haselton