distutil and debugging

Discussion in 'Python' started by Jesper Olsen, Jul 3, 2004.

  1. Jesper Olsen

    Jesper Olsen Guest

    Hi,

    I have a C-extention build with distutils that I would like to debug.

    How can I specify to distuils to pass option "-g" and not "-O2" along to
    the compiler (gcc)?

    Jesper
     
    Jesper Olsen, Jul 3, 2004
    #1
    1. Advertising

  2. Jesper Olsen wrote:
    > Hi,
    >
    > I have a C-extention build with distutils that I would like to debug.
    >
    > How can I specify to distuils to pass option "-g" and not "-O2" along to
    > the compiler (gcc)?


    python setup.py build --debug

    -- Gerhard
     
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Jul 3, 2004
    #2
    1. Advertising

  3. Jesper Olsen

    Jesper Olsen Guest

    Gerhard Häring <> wrote in message news:<>...
    > Jesper Olsen wrote:
    > > Hi,
    > >
    > > I have a C-extention build with distutils that I would like to debug.
    > >
    > > How can I specify to distuils to pass option "-g" and not "-O2" along to
    > > the compiler (gcc)?

    >
    > python setup.py build --debug
    >
    > -- Gerhard


    No - that does not change the options. I think it only links against a version
    of the python lib, which has been compiled for debugging.

    However, I want to debug my own extention - not the python interpretor.

    I'm not the first to have this problem:

    http://tinyurl.com/35ddd

    but that solution only works for the windows environment.
    I'm on OpenBSD, and would prefer to stay there also while debugging...

    Thanks
    Jesper
     
    Jesper Olsen, Jul 4, 2004
    #3
  4. Jesper Olsen wrote:
    > [...] No - that does not change the options. I think it only links against a version
    > of the python lib, which has been compiled for debugging.
    >
    > However, I want to debug my own extention - not the python interpretor.
    >
    > I'm not the first to have this problem:
    >
    > http://tinyurl.com/35ddd
    >
    > but that solution only works for the windows environment.
    > I'm on OpenBSD, and would prefer to stay there also while debugging...


    I don't think that's relevant here. To be honest, I didn't need to add
    any flags on Linux to debug my extensions. -g always gets added there
    automatically.

    Perhaps this comment from distutils/unixcompiler.py will help you fixing
    your build environment:

    # * optimization/debug/warning flags; we just use whatever's in Python's
    # Makefile and live with it. Is this adequate? If not, we might
    # have to have a bunch of subclasses GNUCCompiler, SGICCompiler,
    # SunCCompiler, and I suspect down that road lies madness.

    Maybe your OpenBSD Python was compiled without -g and thus your
    extensions are compiled without -g as well.

    -- Gerhard
     
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Jul 4, 2004
    #4
  5. Jesper Olsen

    Jesper Olsen Guest

    Gerhard Häring <> wrote in message news:<>...
    > Jesper Olsen wrote:
    > > [...] No - that does not change the options. I think it only links against a version
    > > of the python lib, which has been compiled for debugging.
    > >
    > > However, I want to debug my own extention - not the python interpretor.
    > >
    > > I'm not the first to have this problem:
    > >
    > > http://tinyurl.com/35ddd
    > >
    > > but that solution only works for the windows environment.
    > > I'm on OpenBSD, and would prefer to stay there also while debugging...

    >
    > I don't think that's relevant here. To be honest, I didn't need to add
    > any flags on Linux to debug my extensions. -g always gets added there
    > automatically.
    >
    > Perhaps this comment from distutils/unixcompiler.py will help you fixing
    > your build environment:
    >
    > # * optimization/debug/warning flags; we just use whatever's in Python's
    > # Makefile and live with it. Is this adequate? If not, we might
    > # have to have a bunch of subclasses GNUCCompiler, SGICCompiler,
    > # SunCCompiler, and I suspect down that road lies madness.
    >
    > Maybe your OpenBSD Python was compiled without -g and thus your
    > extensions are compiled without -g as well.
    >
    > -- Gerhard


    Thanks Gerhard.

    I think you are right - it simply grabs the options that were used for
    compiling the interpreter. So recompiling the interpreter would
    probably solve the problem.

    I thought I remembered that it was possible to specify your own
    options in the setup.py script - but I can't find it in the online
    manual, so maybe it is just
    Alzheimer.

    The easiest in this situation is probably to not use distutils, and
    simply write a normal makefile for creating that .so library.
    It is not hard to do, but I wish distutils could autogenerate it, and
    let
    me edit it.
    Most of the time distutils does a good job, and this would only be a
    small
    addition given what it does now.

    /Jesper
     
    Jesper Olsen, Jul 4, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christian Seberino
    Replies:
    0
    Views:
    304
    Christian Seberino
    Oct 21, 2003
  2. Christian Seberino
    Replies:
    0
    Views:
    493
    Christian Seberino
    Oct 21, 2003
  3. Derek Croxton

    Distutil install problem

    Derek Croxton, Feb 21, 2004, in forum: Python
    Replies:
    0
    Views:
    379
    Derek Croxton
    Feb 21, 2004
  4. Kevin Dahlhausen
    Replies:
    3
    Views:
    685
    Kevin Dahlhausen
    Sep 14, 2004
  5. Giampaolo Rodola'

    setuptools/distutil and pywin32

    Giampaolo Rodola', Feb 8, 2010, in forum: Python
    Replies:
    0
    Views:
    400
    Giampaolo Rodola'
    Feb 8, 2010
Loading...

Share This Page