numpy

Форк
0
/
meson.build 
92 строки · 3.4 Кб
1
project(
2
  'NumPy',
3
  'c', 'cpp', 'cython',
4
  version: run_command(
5
    # This should become `numpy/_version.py` in NumPy 2.0
6
    ['numpy/_build_utils/gitversion.py'],
7
    check: true).stdout().strip(),
8
  license: 'BSD-3',
9
  meson_version: '>=1.2.99',  # version in vendored-meson is 1.2.99
10
  default_options: [
11
    'buildtype=debugoptimized',
12
    'b_ndebug=if-release',
13
    'c_std=c11',
14
    'cpp_std=c++17',
15
    'pkgconfig.relocatable=true',
16
  ],
17
)
18

19
fs = import('fs')
20

21
cc = meson.get_compiler('c')
22
cpp = meson.get_compiler('cpp')
23
cy = meson.get_compiler('cython')
24

25
# Check compiler is recent enough (see the SciPy Toolchain Roadmap for details)
26
if cc.get_id() == 'gcc'
27
  if not cc.version().version_compare('>=8.4')
28
    error('NumPy requires GCC >= 8.4')
29
  endif
30
elif cc.get_id() == 'msvc'
31
  if not cc.version().version_compare('>=19.20')
32
    error('NumPy requires at least vc142 (default with Visual Studio 2019) ' + \
33
          'when building with MSVC')
34
  endif
35
endif
36
if not cy.version().version_compare('>=3.0.6')
37
  error('NumPy requires Cython >= 3.0.6')
38
endif
39

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

43
if not cc.has_header('Python.h', dependencies: py_dep)
44
  error('Cannot compile `Python.h`. Perhaps you need to install python-dev|python-devel')
45
endif
46

47
# Add default compile flags for any compiler that supports them.
48
# Note that MSVC does not support strict aliasing at all, and neither do the
49
# Intel compilers on Windows, so the `-fno` flavor of the flag should be fine.
50
add_project_arguments(
51
  cc.get_supported_arguments( '-fno-strict-aliasing'), language : 'c'
52
)
53
#
54
# Clang defaults to a non-strict floating error point model, but we need strict
55
# behavior. `-ftrapping-math` is equivalent to `-ffp-exception-behavior=strict`.
56
# This flag is also required to prevent the activation of SIMD partial load workarounds.
57
# For further clarification, refer to gh-24461.
58
cc_id = cc.get_id()
59
if cc_id.startswith('clang')
60
  # Determine the compiler flags for trapping math exceptions.
61
  trapping_math = {
62
    'clang-cl': '/clang:-ftrapping-math',
63
  }.get(cc_id, '-ftrapping-math')
64
  # Check if the compiler supports the trapping math flag.
65
  if cc.has_argument(trapping_math)
66
    # TODO: Consider upgrading the vendored Meson to 1.3.0 to support the parameter `werror`
67
    # Detect whether the compiler actually supports strict handling of floating-point exceptions
68
    # by treating warnings as errors.
69
    if cc.compiles('int main() { return 0; }', args: [trapping_math, '-Werror'])
70
      trapping_math = [trapping_math, '-DNPY_HAVE_CLANG_FPSTRICT']
71
    else
72
      # Suppress warnings about unsupported floating-point optimization.
73
      trapping_math = [trapping_math, '-Wno-unsupported-floating-point-opt']
74
      # Inform the user about the workaround.
75
      message(
76
        'NumPy is being built against a version of Clang that does not strictly enforce ' +
77
        'floating-point exception handling. Workarounds will be used, which may impact performance.\n' +
78
        'Consider upgrading Clang to the latest version.'
79
      )
80
    endif
81
    add_project_arguments(trapping_math, language: ['c', 'cpp'])
82
  endif
83
endif
84

85
if host_machine.system() == 'darwin' and cc.has_link_argument('-Wl,-ld_classic')
86
  # New linker introduced in macOS 14 not working yet with at least OpenBLAS in Spack,
87
  # see gh-24964 (and linked scipy issue from there).
88
  add_project_link_arguments('-Wl,-ld_classic', language : ['c', 'cpp'])
89
endif
90

91
subdir('meson_cpu')
92
subdir('numpy')
93

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.