Skip to content

Commit c758ca0

Browse files
committed
Only ship debug information with PYFASTPFOR_DEBUG_INFO=1
1 parent 6bf16ad commit c758ca0

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@ python -m build
5656
pip install dist/*.whl
5757
```
5858

59-
The bindings build with GCC or Clang, on both x86-64 (SSE/AVX) and ARM/aarch64 (NEON, including Apple Silicon). You may also need to install Python dev-files. On Ubuntu, for Python 3 you can do it as follows:
59+
Debug information is disabled by default. To include it in a local build, set
60+
`PYFASTPFOR_DEBUG_INFO=1` when building:
61+
62+
```
63+
PYFASTPFOR_DEBUG_INFO=1 python -m build
64+
```
65+
66+
The bindings build with GCC, Clang, or MSVC, on both x86-64 (SSE/AVX) and ARM/aarch64 (NEON, including Apple Silicon). You may also need to install Python dev-files. On Ubuntu, for Python 3 you can do it as follows:
6067

6168
```
6269
sudo apt-get install python3-dev

python_bindings/setup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,29 @@ class BuildExt(build_ext):
122122
def build_extensions(self):
123123
ct = self.compiler.compiler_type
124124
opts = list(self.c_opts.get(ct, []))
125+
debug_info = os.environ.get('PYFASTPFOR_DEBUG_INFO') == '1'
125126
if ct == 'unix':
127+
opts.append('-g' if debug_info else '-g0')
126128
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
127129
opts.extend(simd_flags(self.compiler))
128130
if has_flag(self.compiler, '-fvisibility=hidden'):
129131
opts.append('-fvisibility=hidden')
130132
elif ct == 'msvc':
133+
if debug_info:
134+
opts.append('/Zi')
131135
opts.append('/DVERSION_INFO="%s"' % self.distribution.get_version())
132136

137+
link_opts = list(self.link_opts.get(ct, []))
138+
if ct == 'msvc' and debug_info:
139+
link_opts.append('/DEBUG')
140+
133141
# extend include dirs here (don't assume numpy/pybind11 are installed when first run, since
134142
# pip could have installed them as part of executing this script
135143
import pybind11
136144
import numpy as np
137145
for ext in self.extensions:
138146
ext.extra_compile_args.extend(opts)
139-
ext.extra_link_args.extend(self.link_opts.get(ct, []))
147+
ext.extra_link_args.extend(link_opts)
140148
ext.include_dirs.extend([
141149
# Path to pybind11 headers
142150
pybind11.get_include(),

0 commit comments

Comments
 (0)