Skip to content

Commit 022768d

Browse files
ENH: Add command line option for debug builds (#2572)
* add argument for debug builds * clarify about behavior on windows
1 parent d56958e commit 022768d

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

INSTALL.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,21 @@ python setup.py build --abs-rpath
214214

215215
**Note:** when building `scikit-learn-intelex` from source with this option, it will use the oneDAL library with which it was compiled. oneDAL has dependencies on other libraries such as TBB, which is also distributed as a python package through `pip` and as a `conda` package. By default, a conda environment will first try to load TBB from its own packages if it is installed in the environment, which might cause issues if oneDAL was compiled with a system TBB instead of a conda one. In such cases, it is advised to either uninstall TBB from pip/conda (it will be loaded from the oneDAL library which links to it), or modify the order of search paths in environment variables like `${LD_LIBRARY_PATH}`.
216216

217+
### Debug Builds
218+
219+
To build modules with debugging symbols and assertions enabled, pass argument `--debug` to the setup command - e.g.:
220+
221+
```shell
222+
python setup.py build_ext --inplace --force --abs-rpath --debug
223+
python setup.py build --abs-rpath --debug
224+
```
225+
226+
_**Note:** on Windows, this will only add debugging symbols for the `onedal` extension modules, but not for the `daal4py` extension module._
227+
217228
### Building with ASAN
218229

219230
In order to use AddressSanitizer (ASan) together with `scikit-learn-intelex`, it's necessary to:
220-
* Build both oneDAL and scikit-learn-intelex with ASan (otherwise error traces will not be very informative).
231+
* Build both oneDAL and scikit-learn-intelex with ASan and with debug symbols (otherwise error traces will not be very informative).
221232
* Preload the ASan runtime when executing the Python process that imports `scikit-learn-intelex`.
222233
* Optionally, configure Python to use `malloc` as default allocator to reduce the number of false-positive leak reports.
223234

scripts/build_backend.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def custom_build_cmake_clib(
4949
use_abs_rpath=False,
5050
use_gcov=False,
5151
n_threads=1,
52+
debug_build=False,
5253
):
5354
import pybind11
5455

@@ -128,6 +129,9 @@ def custom_build_cmake_clib(
128129
"-DoneDAL_USE_PARAMETERS_LIB=" + use_parameters_arg,
129130
]
130131

132+
if debug_build:
133+
cmake_args += ["-DCMAKE_BUILD_TYPE=Debug"]
134+
131135
if build_distribute:
132136
cmake_args += [
133137
"-DMPI_INCLUDE_DIRS=" + MPI_INCDIRS,

setup.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
if ARG_ABS_RPATH in sys.argv:
4646
USE_ABS_RPATH = True
4747
sys.argv = [arg for arg in sys.argv if arg != ARG_ABS_RPATH]
48+
DEBUG_BUILD = False
49+
ARG_DEBUG_BUILD = "--debug"
50+
if ARG_DEBUG_BUILD in sys.argv:
51+
DEBUG_BUILD = True
52+
sys.argv = [arg for arg in sys.argv if arg != ARG_DEBUG_BUILD]
4853

4954
IS_WIN = False
5055
IS_MAC = False
@@ -302,6 +307,9 @@ def get_build_options():
302307
eca += get_sdl_cflags()
303308
ela += get_sdl_ldflags()
304309

310+
if DEBUG_BUILD and not IS_WIN:
311+
eca += ["-g"]
312+
305313
if IS_MAC:
306314
eca.append("-stdlib=libc++")
307315
ela.append("-stdlib=libc++")
@@ -320,6 +328,7 @@ def get_build_options():
320328
for x in ["CPPFLAGS", "CFLAGS", "CXXFLAGS", "CC", "CXX", "LDFLAGS"]
321329
)
322330
and not USE_ABS_RPATH
331+
and not DEBUG_BUILD
323332
):
324333
ela.append("-s")
325334
return eca, ela, include_dir_plat
@@ -461,6 +470,7 @@ def onedal_run(self):
461470
use_abs_rpath=USE_ABS_RPATH,
462471
use_gcov=use_gcov,
463472
n_threads=n_threads,
473+
debug_build=DEBUG_BUILD,
464474
)
465475
if is_onedal_iface:
466476
build_onedal("host")

0 commit comments

Comments
 (0)