468,107 Members | 1,433 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,107 developers. It's quick & easy.

distutil and debugging

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
Jul 18 '05 #1
4 2090
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

Jul 18 '05 #2
Gerhard Häring <gh@ghaering.de> wrote in message news:<ma**************************************@pyt hon.org>...
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
Jul 18 '05 #3
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

Jul 18 '05 #4
Gerhard Häring <gh@ghaering.de> wrote in message news:<ma**************************************@pyt hon.org>...
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
Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Holger Joukl | last post: by
16 posts views Thread by Serdar Kalaycý | last post: by
2 posts views Thread by Andy Fish | last post: by
5 posts views Thread by Velvet | last post: by
reply views Thread by =?GB2312?B?zPC5zw==?= | last post: by
1 post views Thread by =?GB2312?B?zPC5zw==?= | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.