10000 BLD: Check Intel compiler when checking complex types in build by lysnikolaou · Pull Request #25044 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BLD: Check Intel compiler when checking complex types in build #25044

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,29 @@ if not cy.version().version_compare('>=3.0.6')
error('NumPy requires Cython >= 3.0.6')
endif

# Intel compilers default to fast-math, so disable it if we detect Intel
# compilers. A word of warning: this may not work with the conda-forge
# compilers, because those have the annoying habit of including lots of flags
# that are gcc-specific in CFLAGS/CXXFLAGS/FFLAGS, which throws off the
# detection logic below. You have to remove the wrong flags (only `-isystem`
# is actually needed, everything else shouldn't be there).
_intel_cflags = []
if cc.get_id() == 'intel'
_intel_cflags += cc.get_supported_arguments('-fp-model=strict')
elif cc.get_id() == 'intel-cl'
_intel_cflags += cc.get_supported_arguments('/fp:strict')
elif cc.get_id() == 'intel-llvm-cl'
_intel_cflags += cc.get_supported_arguments('/fp:strict')
_intel_cflags += cc.get_supported_arguments('/source-charset:utf-8')
endif
add_project_arguments(_intel_cflags, language: ['c', 'cpp'])
if cc.get_id() == 'intel-llvm-cl'
_intel_c99_flag = cc.get_supported_arguments('/Qstd=c99')
add_project_arguments(_intel_c99_flag, language: 'c')
_intel_c17 = cpp.get_supported_arguments('/Qstd=c++17')
add_project_arguments(_intel_c17, language: 'cpp')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole if block looks incorrect, because it hardcodes flags that should be set already by the default options higher up. And that may be a problem soon because I already have a PR open to upgrade from C99 to C11. Did you add this to work around a problem with the default flags Meson is adding? If so, let's add a comment and link the upstream issue for it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was to solve the same problem as in #25072: hundreds of warnings about needed language standards. I am happy to wait for that PR to land first.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, you added the /Qstd=c99 warning higher up. That should already be added, because we have c_std=c99' in default_options at the top of meson.build. If it's indeed not added, can you open a Meson issue for it?

To check if it's added:

cd build
python ../vendored-meson/meson/meson.py introspect --targets -i | grep c99

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On main of course the build fails when checking for complex, which what started this whole exercise in the first place. But if I run the command on the broken build, I do not see any c99. Maybe I need to create a minimal reproducer for a proper meson issue.

endif

py = import('python').find_installation(pure: false)
py_dep = py.dependency()

Expand Down
4 changes: 2 additions & 2 deletions numpy/_core/include/numpy/npy_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,11 @@ typedef struct

#include <complex.h>

#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__INTEL_LLVM_COMPILER)
typedef _Dcomplex npy_cdouble;
typedef _Fcomplex npy_cfloat;
typedef _Lcomplex npy_clongdouble;
#else /* !defined(_MSC_VER) || defined(__INTEL_COMPILER) */
#else /* !defined(_MSC_VER) || defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER) */
typedef double _Complex npy_cdouble;
typedef float _Complex npy_cfloat;
typedef longdouble_t _Complex npy_clongdouble;
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ if not cc.has_header('complex.h')
error('"complex.h" header not found')
endif

if cc.get_argument_syntax() == 'msvc'
if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
complex_types_to_check = [
['NPY_SIZEOF_COMPLEX_FLOAT', '_Fcomplex'],
['NPY_SIZEOF_COMPLEX_DOUBLE', '_Dcomplex'],
Expand Down
0