Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
2aadadd0
Commit
2aadadd0
authored
Nov 08, 2010
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disable C/C++ compiler optimization when compiling with the "debug" flag
parent
65afcf50
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
4 deletions
+59
-4
Cython/Debugger/libcython.py
Cython/Debugger/libcython.py
+12
-3
Cython/Distutils/build_ext.py
Cython/Distutils/build_ext.py
+47
-1
No files found.
Cython/Debugger/libcython.py
View file @
2aadadd0
...
@@ -244,8 +244,14 @@ class CythonBase(object):
...
@@ -244,8 +244,14 @@ class CythonBase(object):
if
not
pyframeobject
:
if
not
pyframeobject
:
raise
gdb
.
GdbError
(
'Unable to read information on python frame'
)
raise
gdb
.
GdbError
(
'Unable to read information on python frame'
)
filename
=
pyframeobject
.
filename
()
try
:
lineno
=
pyframeobject
.
current_line_num
()
filename
=
pyframeobject
.
filename
()
except
RuntimeError
:
filename
=
None
lineno
=
None
else
:
lineno
=
pyframeobject
.
current_line_num
()
if
pygments
:
if
pygments
:
lexer
=
pygments
.
lexers
.
PythonLexer
(
stripall
=
False
)
lexer
=
pygments
.
lexers
.
PythonLexer
(
stripall
=
False
)
else
:
else
:
...
@@ -307,7 +313,10 @@ class CythonBase(object):
...
@@ -307,7 +313,10 @@ class CythonBase(object):
# print this python function as a C function
# print this python function as a C function
return
self
.
print_stackframe
(
frame
,
index
,
is_c
=
True
)
return
self
.
print_stackframe
(
frame
,
index
,
is_c
=
True
)
func_name
=
pyframe
.
co_name
try
:
func_name
=
str
(
pyframe
.
co_name
)
except
RuntimeError
:
func_name
=
'Unknown Function Name'
func_cname
=
'PyEval_EvalFrameEx'
func_cname
=
'PyEval_EvalFrameEx'
func_args
=
[]
func_args
=
[]
elif
self
.
is_cython_function
(
frame
):
elif
self
.
is_cython_function
(
frame
):
...
...
Cython/Distutils/build_ext.py
View file @
2aadadd0
...
@@ -17,11 +17,45 @@ from distutils.dep_util import newer, newer_group
...
@@ -17,11 +17,45 @@ from distutils.dep_util import newer, newer_group
from
distutils
import
log
from
distutils
import
log
from
distutils.dir_util
import
mkpath
from
distutils.dir_util
import
mkpath
from
distutils.command
import
build_ext
as
_build_ext
from
distutils.command
import
build_ext
as
_build_ext
from
distutils
import
sysconfig
extension_name_re
=
_build_ext
.
extension_name_re
extension_name_re
=
_build_ext
.
extension_name_re
show_compilers
=
_build_ext
.
show_compilers
show_compilers
=
_build_ext
.
show_compilers
class
Optimization
(
object
):
def
__init__
(
self
):
self
.
flags
=
(
'OPT'
,
'CFLAGS'
,
'CPPFLAGS'
,
'EXTRA_CFLAGS'
,
'BASECFLAGS'
,
'PY_CFLAGS'
,
)
self
.
state
=
sysconfig
.
get_config_vars
(
*
self
.
flags
)
self
.
config_vars
=
sysconfig
.
get_config_vars
()
def
disable_optimization
(
self
):
"disable optimization for the C or C++ compiler"
badoptions
=
(
'-O1'
,
'-O2'
,
'-O3'
)
for
flag
,
option
in
zip
(
self
.
flags
,
self
.
state
):
if
option
is
not
None
:
g
=
(
opt
for
opt
in
option
.
split
()
if
opt
not
in
badoptions
)
self
.
config_vars
[
flag
]
=
' '
.
join
(
g
)
def
restore_state
(
self
):
"restore the original state"
for
flag
,
option
in
zip
(
self
.
flags
,
self
.
state
):
if
option
is
not
None
:
self
.
config_vars
[
flag
]
=
option
optimization
=
Optimization
()
class
build_ext
(
_build_ext
.
build_ext
):
class
build_ext
(
_build_ext
.
build_ext
):
description
=
"build C/C++ and Cython extensions (compile/link to build directory)"
description
=
"build C/C++ and Cython extensions (compile/link to build directory)"
...
@@ -77,10 +111,22 @@ class build_ext(_build_ext.build_ext):
...
@@ -77,10 +111,22 @@ class build_ext(_build_ext.build_ext):
if
self
.
pyrex_directives
is
None
:
if
self
.
pyrex_directives
is
None
:
self
.
pyrex_directives
=
{}
self
.
pyrex_directives
=
{}
# finalize_options ()
# finalize_options ()
def
run
(
self
):
# We have one shot at this before build_ext initializes the compiler.
# If --pyrex-debug is in effect as a command line option or as option
# of any Extension module, disable optimization for the C or C++
# compiler.
if
(
self
.
pyrex_debug
or
any
(
getattr
(
ext
,
'pyrex_debug'
,
False
)
for
ext
in
self
.
extensions
)):
optimization
.
disable_optimization
()
_build_ext
.
build_ext
.
run
(
self
)
def
build_extensions
(
self
):
def
build_extensions
(
self
):
# First, sanity-check the 'extensions' list
# First, sanity-check the 'extensions' list
self
.
check_extensions_list
(
self
.
extensions
)
self
.
check_extensions_list
(
self
.
extensions
)
for
ext
in
self
.
extensions
:
for
ext
in
self
.
extensions
:
ext
.
sources
=
self
.
cython_sources
(
ext
.
sources
,
ext
)
ext
.
sources
=
self
.
cython_sources
(
ext
.
sources
,
ext
)
self
.
build_extension
(
ext
)
self
.
build_extension
(
ext
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment