Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79809

Re: Build Question: How to Add -Wl, --option Before Objects In Setup.py?

References <CAHu5PrbHSob2r-zOTCtrYiqdudU_q+4mDXOXzp=_ReJp7khTDg@mail.gmail.com> <nad-150419.13393227102014@news.gmane.org>
Date 2014-10-27 18:20 -0500
Subject Re: Build Question: How to Add -Wl, --option Before Objects In Setup.py?
From Cyd Haselton <chaselton@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.15245.1414452046.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Oct 27, 2014 at 3:39 PM, Ned Deily <nad@acm.org> wrote:
> In article
> <CAHu5PrbHSob2r-zOTCtrYiqdudU_q+4mDXOXzp=_ReJp7khTDg@mail.gmail.com>,
>  Cyd Haselton <chaselton@gmail.com> 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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Build Question: How to Add -Wl, --option Before Objects In Setup.py? Cyd Haselton <chaselton@gmail.com> - 2014-10-27 18:20 -0500

csiph-web