Repository navigation
Enable -Wall and -Wextra warnings on the _cl module #930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4e19dd7
4f57468
b64e989
91d787d
fe43e6d
0a7a364
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,13 +150,17 @@ execute_process( | |
| "${PYTHON_EXECUTABLE}" -c "import nanobind; print(nanobind.cmake_dir())" | ||
| OUTPUT_VARIABLE NANOBIND_DIR | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT) | ||
| list(APPEND CMAKE_PREFIX_PATH "${NANOBIND_DIR}") | ||
| list(APPEND CMAKE_PREFIX_PATH "${NANOBIND_DIR}") | ||
|
|
||
| execute_process( | ||
| COMMAND | ||
| "${PYTHON_EXECUTABLE}" -c "import nanobind; print(nanobind.include_dir())" | ||
| OUTPUT_VARIABLE NANOBIND_INCLUDE_DIR | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT) | ||
|
|
||
| # }}} | ||
|
|
||
| link_directories(${CL_LIB_DIR}) | ||
| include_directories(${CL_INC_DIR} ${Python_NumPy_INCLUDE_DIRS}) | ||
|
|
||
| find_package(nanobind CONFIG REQUIRED) | ||
|
|
||
| set(OpenCL_ROOT ${CL_LIB_DIR}) | ||
|
|
@@ -167,6 +171,7 @@ find_package(OpenCL REQUIRED) | |
| nanobind_add_module( | ||
| _cl | ||
| NB_STATIC # Build static libnanobind (the extension module itself remains a shared library) | ||
| NB_SUPPRESS_WARNINGS | ||
| LTO | ||
| NOMINSIZE | ||
| src/wrap_constants.cpp | ||
|
|
@@ -176,15 +181,41 @@ nanobind_add_module( | |
| src/wrap_mempool.cpp | ||
| src/bitlog.cpp | ||
| ) | ||
| target_compile_features(_cl PRIVATE cxx_std_17) | ||
|
|
||
| target_link_libraries(_cl PRIVATE ${OpenCL_LIBRARY}) | ||
| target_include_directories(_cl SYSTEM PRIVATE | ||
| ${CL_INC_DIR} | ||
| ${NANOBIND_INCLUDE_DIR} | ||
| ${Python_NumPy_INCLUDE_DIRS}) | ||
|
|
||
| target_compile_definitions(_cl | ||
| PRIVATE | ||
| PYGPU_PACKAGE=pyopencl | ||
| PYGPU_PYOPENCL | ||
| ) | ||
|
|
||
| if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") | ||
| target_compile_options(_cl PRIVATE | ||
| -Wall | ||
| -Wextra | ||
| # NOTE: VLAs are used by PYOPENCL_STACK_CONTAINER for dubious reasons | ||
| -Wpedantic -Wno-vla | ||
|
Comment on lines
+202
to
+203
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That VLA in there is pretty old. Still useful? Even the Linux kernel removed VLAs 😁 |
||
| -Wshadow | ||
| -Wold-style-cast | ||
| -Wcast-align | ||
| -Wconversion -Wsign-conversion | ||
| -Wnon-virtual-dtor | ||
| -Woverloaded-virtual | ||
| -Wformat=2 | ||
| -Wimplicit-fallthrough | ||
| -Wdouble-promotion | ||
| -Wnull-dereference | ||
| # NOTE: mostly calls to deprecated CL functions that we support | ||
| -Wno-deprecated-declarations | ||
| ) | ||
| endif() | ||
|
Comment on lines
+198
to
+217
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Loads of random warnings here. The |
||
|
|
||
| if (PYOPENCL_PRETEND_CL_VERSION) | ||
| target_compile_definitions( | ||
| _cl PRIVATE PYOPENCL_PRETEND_CL_VERSION=${PYOPENCL_PRETEND_CL_VERSION}) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mainly needed so that gcc/clang don't complain about warnings in these headers. I think
NB_SUPRESS_WARNINGSalready does most of this, but added it with CL and NumPy just in case.