1# Copyright © 2017-2020 Intel Corporation 2# SPDX-License-Identifier: MIT 3 4project( 5 'mesa', 6 ['c', 'cpp'], 7 version : files('VERSION'), 8 license : 'MIT', 9 meson_version : '>= 1.1.0', 10 default_options : [ 11 'buildtype=debugoptimized', 12 'b_ndebug=if-release', 13 'c_std=c11', 14 'cpp_std=c++17', 15 'rust_std=2021', 16 'build.rust_std=2021', 17 ], 18) 19 20if host_machine.system() == 'darwin' 21 add_languages('objc', native : false) 22 add_global_arguments('-fobjc-arc', language : 'objc') 23endif 24 25cc = meson.get_compiler('c') 26cpp = meson.get_compiler('cpp') 27 28sizeof_pointer = cc.sizeof('void*').to_string() 29 30null_dep = dependency('', required : false) 31 32if get_option('layout') != 'mirror' 33 error('`mirror` is the only build directory layout supported') 34endif 35 36with_mesa_debug = get_option('buildtype') == 'debug' 37 38# This means the final value of b_ndebug==true 39with_mesa_ndebug = get_option('b_ndebug') == 'true' or (get_option('buildtype') == 'release' and get_option('b_ndebug') == 'if-release') 40 41# Arguments for the preprocessor, put these in a separate array from the C and 42# C++ (cpp in meson terminology) arguments since they need to be added to the 43# default arguments for both C and C++. 44pre_args = [ 45 '-D__STDC_CONSTANT_MACROS', 46 '-D__STDC_FORMAT_MACROS', 47 '-D__STDC_LIMIT_MACROS', 48 '-DPACKAGE_VERSION="@0@"'.format(meson.project_version()), 49 '-DPACKAGE_BUGREPORT="https://gitlab.freedesktop.org/mesa/mesa/-/issues"', 50] 51# Arguments for c or cpp compiler, can be compiler options 52c_cpp_args = [] 53 54c_args = [] 55cpp_args = [] 56 57with_moltenvk_dir = get_option('moltenvk-dir') 58with_vulkan_icd_dir = get_option('vulkan-icd-dir') 59with_tests = get_option('build-tests') 60with_glcpp_tests = get_option('enable-glcpp-tests') 61with_aco_tests = get_option('build-aco-tests') 62with_glx_read_only_text = get_option('glx-read-only-text') 63with_glx_direct = get_option('glx-direct') 64with_osmesa = get_option('osmesa') 65with_vulkan_overlay_layer = get_option('vulkan-layers').contains('overlay') 66with_vulkan_device_select_layer = get_option('vulkan-layers').contains('device-select') 67with_vulkan_screenshot_layer = get_option('vulkan-layers').contains('screenshot') 68with_tools = get_option('tools') 69if with_tools.contains('all') 70 with_tools = [ 71 'drm-shim', 72 'dlclose-skip', 73 'etnaviv', 74 'freedreno', 75 'glsl', 76 'intel', 77 'intel-ui', 78 'lima', 79 'nir', 80 'nouveau', 81 'asahi', 82 'imagination', 83 ] 84endif 85 86with_any_vulkan_layers = get_option('vulkan-layers').length() != 0 87with_intel_tools = with_tools.contains('intel') or with_tools.contains('intel-ui') 88with_imgui = with_intel_tools or with_vulkan_overlay_layer 89 90dri_drivers_path = get_option('dri-drivers-path') 91if dri_drivers_path == '' 92 dri_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'dri') 93endif 94 95gbm_backends_path = get_option('gbm-backends-path') 96if gbm_backends_path == '' 97 gbm_backends_path = join_paths(get_option('prefix'), get_option('libdir'), 'gbm') 98endif 99 100# Default shared glapi disabled for windows, enabled elsewhere. 101with_shared_glapi = get_option('shared-glapi') \ 102 .disable_auto_if(host_machine.system() == 'windows') \ 103 .allowed() 104 105with_opengl = get_option('opengl') 106 107with_gles1 = get_option('gles1') \ 108 .require(with_shared_glapi, error_message : 'OpengGL ES 1.x requires shared-glapi') \ 109 .allowed() 110 111with_gles2 = get_option('gles2') \ 112 .require(with_shared_glapi, error_message : 'OpengGL ES 2.x requires shared-glapi') \ 113 .allowed() 114 115pre_args += '-DHAVE_OPENGL=@0@'.format(with_opengl.to_int()) 116pre_args += '-DHAVE_OPENGL_ES_1=@0@'.format(with_gles1.to_int()) 117pre_args += '-DHAVE_OPENGL_ES_2=@0@'.format(with_gles2.to_int()) 118 119with_any_opengl = with_opengl or with_gles1 or with_gles2 120# Only build shared_glapi if at least one OpenGL API is enabled 121with_shared_glapi = with_shared_glapi and with_any_opengl 122 123system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux', 'sunos', 'android', 'managarm'].contains(host_machine.system()) 124 125gallium_drivers = get_option('gallium-drivers') 126if gallium_drivers.contains('auto') 127 if system_has_kms_drm 128 # TODO: Sparc 129 if ['x86', 'x86_64'].contains(host_machine.cpu_family()) 130 gallium_drivers = [ 131 'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'svga', 'llvmpipe', 'softpipe', 132 'iris', 'crocus', 'i915', 'zink' 133 ] 134 elif ['arm', 'aarch64'].contains(host_machine.cpu_family()) 135 gallium_drivers = [ 136 'v3d', 'vc4', 'freedreno', 'etnaviv', 'nouveau', 'svga', 137 'tegra', 'virgl', 'lima', 'panfrost', 'llvmpipe', 'softpipe', 'iris', 138 'zink' 139 ] 140 elif ['mips', 'mips64', 'ppc', 'ppc64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family()) 141 gallium_drivers = [ 142 'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'llvmpipe', 'softpipe', 'zink' 143 ] 144 elif ['loongarch64'].contains(host_machine.cpu_family()) 145 gallium_drivers = [ 146 'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'etnaviv', 'llvmpipe', 'softpipe', 'zink' 147 ] 148 else 149 error('Unknown architecture @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format( 150 host_machine.cpu_family())) 151 endif 152 elif ['windows'].contains(host_machine.system()) 153 gallium_drivers = ['llvmpipe', 'softpipe', 'zink', 'd3d12'] 154 elif ['darwin', 'cygwin', 'haiku'].contains(host_machine.system()) 155 gallium_drivers = ['llvmpipe', 'softpipe'] 156 else 157 error('Unknown OS @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format( 158 host_machine.system())) 159 endif 160elif gallium_drivers.contains('all') 161 # Build-test everything except for i915, which depends on libdrm-intel which 162 # is not available on non-Intel distros. 163 gallium_drivers = [ 164 'r300', 'r600', 'radeonsi', 'crocus', 'v3d', 'vc4', 'freedreno', 'etnaviv', 165 'nouveau', 'svga', 'tegra', 'virgl', 'lima', 'panfrost', 'llvmpipe', 'softpipe', 'iris', 166 'zink', 'd3d12', 'asahi' 167 ] 168endif 169 170# compatibility for meson configurations asking for 'swrast' 171with_swrast = gallium_drivers.contains('swrast') 172if with_swrast 173 warning('`gallium-drivers=swrast` is a deprecated alias for `gallium-drivers=softpipe,llvmpipe` and will be removed in version 25.0') 174endif 175 176with_gallium_radeonsi = gallium_drivers.contains('radeonsi') 177with_gallium_r300 = gallium_drivers.contains('r300') 178with_gallium_r600 = gallium_drivers.contains('r600') 179with_gallium_nouveau = gallium_drivers.contains('nouveau') 180with_gallium_freedreno = gallium_drivers.contains('freedreno') 181with_gallium_softpipe = with_swrast or gallium_drivers.contains('softpipe') 182with_gallium_llvmpipe = with_swrast or gallium_drivers.contains('llvmpipe') 183with_gallium_vc4 = gallium_drivers.contains('vc4') 184with_gallium_v3d = gallium_drivers.contains('v3d') 185with_gallium_panfrost = gallium_drivers.contains('panfrost') 186with_gallium_etnaviv = gallium_drivers.contains('etnaviv') 187with_gallium_tegra = gallium_drivers.contains('tegra') 188with_gallium_crocus = gallium_drivers.contains('crocus') 189with_gallium_iris = gallium_drivers.contains('iris') 190with_gallium_i915 = gallium_drivers.contains('i915') 191with_gallium_svga = gallium_drivers.contains('svga') 192with_gallium_virgl = gallium_drivers.contains('virgl') 193with_gallium_lima = gallium_drivers.contains('lima') 194with_gallium_zink = gallium_drivers.contains('zink') 195with_gallium_d3d12 = gallium_drivers.contains('d3d12') 196with_gallium_asahi = gallium_drivers.contains('asahi') 197foreach gallium_driver : gallium_drivers 198 pre_args += '-DHAVE_@0@'.format(gallium_driver.to_upper()) 199endforeach 200 201# compatibility for "swrast" as an internal-ish driver name 202with_gallium_swrast = with_gallium_softpipe or with_gallium_llvmpipe 203if with_gallium_swrast 204 pre_args += '-DHAVE_SWRAST' 205endif 206 207with_gallium = gallium_drivers.length() != 0 208with_gallium_kmsro = system_has_kms_drm and [ 209 with_gallium_asahi, 210 with_gallium_etnaviv, 211 with_gallium_freedreno, 212 with_gallium_lima, 213 with_gallium_panfrost, 214 with_gallium_v3d, 215 with_gallium_vc4, 216].contains(true) 217 218_vulkan_drivers = get_option('vulkan-drivers') 219if _vulkan_drivers.contains('auto') 220 if system_has_kms_drm 221 if host_machine.cpu_family().startswith('x86') 222 _vulkan_drivers = ['amd', 'intel', 'intel_hasvk', 'nouveau', 'swrast'] 223 elif ['arm', 'aarch64'].contains(host_machine.cpu_family()) 224 _vulkan_drivers = ['swrast', 'intel'] 225 elif ['mips', 'mips64', 'ppc', 'ppc64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family()) 226 _vulkan_drivers = ['amd', 'swrast'] 227 elif ['loongarch64'].contains(host_machine.cpu_family()) 228 _vulkan_drivers = ['amd', 'swrast'] 229 else 230 error('Unknown architecture @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format( 231 host_machine.cpu_family())) 232 endif 233 elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system()) 234 # No vulkan driver supports windows or macOS currently 235 _vulkan_drivers = [] 236 else 237 error('Unknown OS @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format( 238 host_machine.system())) 239 endif 240elif _vulkan_drivers.contains('all') 241 # Build every vulkan driver regardless of architecture. 242 _vulkan_drivers = ['amd', 'intel', 'intel_hasvk', 'swrast', 243 'freedreno', 'panfrost', 'virtio', 'broadcom', 244 'imagination-experimental', 'microsoft-experimental', 245 'nouveau', 'asahi', 'gfxstream'] 246endif 247 248with_intel_vk = _vulkan_drivers.contains('intel') 249with_intel_hasvk = _vulkan_drivers.contains('intel_hasvk') 250with_amd_vk = _vulkan_drivers.contains('amd') 251with_freedreno_vk = _vulkan_drivers.contains('freedreno') 252with_panfrost_vk = _vulkan_drivers.contains('panfrost') 253with_swrast_vk = _vulkan_drivers.contains('swrast') 254with_virtio_vk = _vulkan_drivers.contains('virtio') 255with_broadcom_vk = _vulkan_drivers.contains('broadcom') 256with_imagination_vk = _vulkan_drivers.contains('imagination-experimental') 257with_imagination_srv = get_option('imagination-srv') 258with_microsoft_vk = _vulkan_drivers.contains('microsoft-experimental') 259with_nouveau_vk = _vulkan_drivers.contains('nouveau') 260with_asahi_vk = _vulkan_drivers.contains('asahi') 261with_gfxstream_vk = _vulkan_drivers.contains('gfxstream') 262with_any_vk = _vulkan_drivers.length() != 0 263 264if with_any_vk and host_machine.system() == 'windows' and meson.version().version_compare('< 1.3') 265 error('Vulkan drivers on Windows require meson 1.3 or newer') 266endif 267 268with_any_llvmpipe = with_gallium_llvmpipe or with_swrast_vk 269with_gallium_or_lvp = with_gallium or with_swrast_vk 270 271freedreno_kmds = get_option('freedreno-kmds') 272if freedreno_kmds.length() != 0 and freedreno_kmds != [ 'msm' ] and with_freedreno_vk 273 if freedreno_kmds.contains('msm') 274 warning('Turnip with the DRM KMD will require libdrm to always be present at runtime which may not always be the case on platforms such as Android.') 275 elif with_gallium_kmsro 276 warning('As a side-effect, Turnip is forced to link with libdrm when built alongside Gallium DRM drivers which platforms such as Android may not have available at runtime.') 277 elif _vulkan_drivers != [ 'freedreno' ] 278 warning('Turnip is forced to link with libdrm when built alongside other Vulkan drivers which platforms such as Android may not have available at runtime.') 279 else 280 # If DRM support isn't needed, we can get rid of it since linking 281 # to libdrm can be a potential compatibility hazard. 282 system_has_kms_drm = false 283 endif 284endif 285 286with_dri = false 287if with_gallium and system_has_kms_drm 288 _glx = get_option('glx') 289 _egl = get_option('egl') 290 if _glx == 'dri' or _egl.enabled() or (_glx == 'disabled' and _egl.allowed()) 291 with_dri = true 292 endif 293endif 294 295with_any_broadcom = [ 296 with_gallium_vc4, 297 with_gallium_v3d, 298 with_broadcom_vk, 299].contains(true) 300 301if get_option('intel-clc') != 'system' 302 # Require intel-clc with Anv & Iris (for internal shaders) 303 with_intel_clc = get_option('intel-clc') == 'enabled' or \ 304 with_intel_vk or with_gallium_iris 305else 306 with_intel_clc = false 307endif 308 309with_intel_vk_rt = get_option('intel-rt') \ 310 .disable_auto_if(not with_intel_vk) \ 311 .disable_if(host_machine.cpu_family() != 'x86_64', error_message : 'Intel Ray Tracing is only supported on x86_64') \ 312 .allowed() 313 314with_any_intel = [ 315 with_gallium_crocus, 316 with_gallium_i915, 317 with_gallium_iris, 318 with_intel_clc, 319 with_intel_hasvk, 320 with_intel_tools, 321 with_intel_vk, 322].contains(true) 323with_any_nouveau = with_gallium_nouveau or with_nouveau_vk 324 325# needed in the loader 326if with_nouveau_vk 327 pre_args += '-DHAVE_NVK' 328endif 329 330if with_gallium_tegra and not with_gallium_nouveau 331 error('tegra driver requires nouveau driver') 332endif 333if with_aco_tests and not with_amd_vk 334 error('ACO tests require Radv') 335endif 336 337with_microsoft_clc = get_option('microsoft-clc').enabled() 338with_spirv_to_dxil = get_option('spirv-to-dxil') 339 340if host_machine.system() == 'darwin' 341 with_dri_platform = 'apple' 342 pre_args += '-DBUILDING_MESA' 343elif ['windows', 'cygwin'].contains(host_machine.system()) 344 with_dri_platform = 'windows' 345elif system_has_kms_drm 346 with_dri_platform = 'drm' 347else 348 # FIXME: haiku doesn't use dri, and xlib doesn't use dri, probably should 349 # assert here that one of those cases has been met. 350 # FIXME: illumos ends up here as well 351 with_dri_platform = 'none' 352endif 353 354with_vulkan_beta = get_option('vulkan-beta') 355if host_machine.system() == 'darwin' 356 #macOS seems to need beta extensions to build for now: 357 with_vulkan_beta = true 358endif 359if with_vulkan_beta 360 pre_args += '-DVK_ENABLE_BETA_EXTENSIONS' 361endif 362 363_codecs = get_option('video-codecs') 364patent_codecs = ['vc1dec', 'h264dec', 'h264enc', 'h265dec', 'h265enc'] 365free_codecs = ['av1dec', 'av1enc', 'vp9dec'] 366all_codecs = patent_codecs + free_codecs 367 368if _codecs.contains('all') 369 _codecs = all_codecs 370elif _codecs.contains('all_free') 371 selected_codecs = _codecs 372 _codecs = free_codecs 373 foreach c : patent_codecs 374 if selected_codecs.contains(c) 375 _codecs += c 376 endif 377 endforeach 378endif 379foreach c : all_codecs 380 pre_args += '-DVIDEO_CODEC_@0@=@1@'.format(c.to_upper(), _codecs.contains(c).to_int()) 381endforeach 382 383_platforms = get_option('platforms') 384if _platforms.contains('auto') 385 if system_has_kms_drm 386 _platforms = ['x11', 'wayland'] 387 elif host_machine.system() == 'cygwin' 388 _platforms = ['x11'] 389 elif host_machine.system() == 'haiku' 390 _platforms = ['haiku'] 391 elif host_machine.system() == 'windows' 392 _platforms = ['windows'] 393 elif host_machine.system() == 'darwin' 394 _platforms = ['x11', 'macos'] 395 else 396 error('Unknown OS @0@. Please pass -Dplatforms to set platforms. Patches gladly accepted to fix this.'.format( 397 host_machine.system())) 398 endif 399endif 400 401with_platform_android = _platforms.contains('android') 402with_platform_x11 = _platforms.contains('x11') 403with_platform_xcb = _platforms.contains('xcb') 404with_platform_wayland = _platforms.contains('wayland') 405with_platform_haiku = _platforms.contains('haiku') 406with_platform_windows = _platforms.contains('windows') 407with_platform_macos = _platforms.contains('macos') 408 409with_glx = get_option('glx') 410if with_glx == 'auto' 411 if not with_opengl 412 with_glx = 'disabled' 413 elif with_platform_android 414 with_glx = 'disabled' 415 elif with_dri 416 with_glx = 'dri' 417 elif with_platform_haiku 418 with_glx = 'disabled' 419 elif host_machine.system() == 'windows' 420 with_glx = 'disabled' 421 elif with_gallium 422 # Even when building just gallium drivers the user probably wants dri 423 with_glx = 'dri' 424 elif with_platform_x11 and with_any_opengl and not with_any_vk 425 # The automatic behavior should not be to turn on xlib based glx when 426 # building only vulkan drivers 427 with_glx = 'xlib' 428 else 429 with_glx = 'disabled' 430 endif 431endif 432if with_glx == 'dri' 433 if with_gallium 434 with_dri = true 435 endif 436endif 437 438if not with_opengl and with_glx != 'disabled' 439 error('Building GLX without OpenGL is not supported.') 440endif 441 442if not (with_dri or with_gallium or with_glx != 'disabled') 443 with_gles1 = false 444 with_gles2 = false 445 with_opengl = false 446 with_any_opengl = false 447 with_shared_glapi = false 448endif 449 450with_gbm = get_option('gbm') \ 451 .require(system_has_kms_drm, error_message : 'GBM only supports DRM/KMS platforms') \ 452 .disable_auto_if(not with_dri) \ 453 .allowed() 454 455with_xlib_lease = get_option('xlib-lease') \ 456 .require(with_platform_x11 and (system_has_kms_drm or with_dri_platform == 'apple'), error_message : 'xlib-lease requires X11 and KMS/DRM support') \ 457 .allowed() 458 459with_egl = get_option('egl') \ 460 .require(with_platform_windows or with_platform_haiku or with_dri or with_platform_android, error_message : 'EGL requires DRI, Haiku, Windows or Android') \ 461 .require(with_shared_glapi, error_message : 'EGL requires shared-glapi') \ 462 .require(with_glx != 'xlib', error_message :'EGL requires DRI, but GLX is being built with xlib support') \ 463 .disable_auto_if(with_platform_haiku) \ 464 .allowed() 465 466if with_egl 467 _platforms += 'surfaceless' 468 if with_gbm and not with_platform_android 469 _platforms += 'drm' 470 endif 471 472 egl_native_platform = get_option('egl-native-platform') 473 if egl_native_platform.contains('auto') 474 egl_native_platform = _platforms[0] 475 endif 476endif 477 478if with_egl and not _platforms.contains(egl_native_platform) 479 error('-Degl-native-platform does not specify an enabled platform') 480endif 481 482if 'x11' in _platforms 483 _platforms += 'xcb' 484endif 485 486foreach platform : _platforms 487 pre_args += '-DHAVE_@0@_PLATFORM'.format(platform.to_upper()) 488endforeach 489 490if with_platform_android and get_option('platform-sdk-version') >= 29 491 # By default the NDK compiler, at least, emits emutls references instead of 492 # ELF TLS, even when building targeting newer API levels. Make it actually do 493 # ELF TLS instead. 494 c_cpp_args += '-fno-emulated-tls' 495endif 496 497# -mtls-dialect=gnu2 speeds up non-initial-exec TLS significantly but requires 498# full toolchain (including libc) support. 499have_mtls_dialect = false 500foreach c_arg : get_option('c_args') 501 if c_arg.startswith('-mtls-dialect=') 502 have_mtls_dialect = true 503 break 504 endif 505endforeach 506if not have_mtls_dialect 507 # need .run to check libc support. meson aborts when calling .run when 508 # cross-compiling, but because this is just an optimization we can skip it 509 if meson.is_cross_build() and not meson.can_run_host_binaries() 510 warning('cannot auto-detect -mtls-dialect when cross-compiling, using compiler default') 511 else 512 # The way to specify the TLSDESC dialect is architecture-specific. 513 # We probe both because there is not a fallback guaranteed to work for all 514 # future architectures. 515 foreach tlsdesc_arg : ['-mtls-dialect=gnu2', '-mtls-dialect=desc'] 516 # -fpic to force dynamic tls, otherwise TLS relaxation defeats check 517 tlsdesc_test = cc.run('int __thread x; int main() { return x; }', 518 args: [tlsdesc_arg, '-fpic'], 519 name: tlsdesc_arg) 520 if tlsdesc_test.returncode() == 0 and ( 521 # check for lld 13 bug: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5665 522 host_machine.cpu_family() != 'x86_64' or 523 # get_linker_id misses LDFLAGS=-fuse-ld=lld: https://github.com/mesonbuild/meson/issues/6377 524 #cc.get_linker_id() != 'ld.lld' or 525 cc.links('''int __thread x; int y; int main() { __asm__( 526 "leaq x@TLSDESC(%rip), %rax\n" 527 "movq y@GOTPCREL(%rip), %rdx\n" 528 "call *x@TLSCALL(%rax)\n"); }''', name: 'split TLSDESC') 529 ) 530 c_cpp_args += tlsdesc_arg 531 break 532 endif 533 endforeach 534 endif 535endif 536 537if with_glx != 'disabled' 538 if not (with_platform_x11 and with_any_opengl) 539 error('Cannot build GLX support without X11 platform support and at least one OpenGL API') 540 elif with_glx == 'xlib' 541 if not with_gallium 542 error('xlib based GLX requires at least one gallium driver') 543 elif not with_gallium_swrast 544 error('xlib based GLX requires softpipe or llvmpipe.') 545 elif with_dri 546 error('xlib conflicts with any dri driver') 547 endif 548 elif with_glx == 'dri' 549 if not with_shared_glapi 550 error('dri based GLX requires shared-glapi') 551 endif 552 endif 553endif 554 555_glvnd = get_option('glvnd') \ 556 .require(not with_platform_windows, 557 error_message: 'glvnd cannot be used on Windows') \ 558 .require(with_glx != 'xlib', 559 error_message: 'Cannot build glvnd support for GLX that is not DRI based.') \ 560 .require(with_glx != 'disabled' or with_egl, 561 error_message: 'glvnd requires DRI based GLX and/or EGL') \ 562 .require(get_option('egl-lib-suffix') == '', 563 error_message: '''EGL lib suffix can't be used with libglvnd''') 564dep_glvnd = dependency('libglvnd', version : '>= 1.3.2', required : _glvnd) 565with_glvnd = dep_glvnd.found() 566pre_args += '-DUSE_LIBGLVND=@0@'.format(with_glvnd.to_int()) 567glvnd_vendor_name = get_option('glvnd-vendor-name') 568 569if with_vulkan_icd_dir == '' 570 with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d') 571endif 572 573with_dri2 = (with_dri or with_any_vk) and (with_dri_platform == 'drm' or with_dri_platform == 'apple') 574 575with_x11_dri2 = with_dri2 and get_option('legacy-x11').contains('dri2') 576 577if with_dri 578 if with_glx == 'disabled' and not with_egl and not with_gbm 579 error('building dri drivers require at least one windowing system') 580 endif 581endif 582 583dep_dxheaders = null_dep 584if with_gallium_d3d12 or with_microsoft_clc or with_microsoft_vk 585 dep_dxheaders = dependency('directx-headers', required : false) 586 if not dep_dxheaders.found() 587 dep_dxheaders = dependency('DirectX-Headers', 588 version : '>= 1.614.1', 589 fallback : ['DirectX-Headers', 'dep_dxheaders'], 590 required : with_gallium_d3d12 or with_microsoft_vk 591 ) 592 endif 593endif 594 595_with_gallium_d3d12_video = get_option('gallium-d3d12-video') 596with_gallium_d3d12_video = false 597if with_gallium_d3d12 and not _with_gallium_d3d12_video.disabled() 598 with_gallium_d3d12_video = true 599 pre_args += '-DHAVE_GALLIUM_D3D12_VIDEO' 600endif 601 602_vdpau_drivers = [ 603 with_gallium_d3d12_video, 604 with_gallium_nouveau, 605 with_gallium_r600, 606 with_gallium_radeonsi, 607 with_gallium_virgl, 608] 609 610vdpau = get_option('gallium-vdpau') \ 611 .require(system_has_kms_drm, error_message : 'VDPAU state tracker can only be build on unix-like OSes.') \ 612 .require(with_platform_x11, error_message : 'VDPAU state tracker requires X11 support.') \ 613 .require(_vdpau_drivers.contains(true), error_message : 'VDPAU state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau, d3d12 (with option gallium-d3d12-video, virgl).') 614 615dep_vdpau = dependency('vdpau', version : '>= 1.5', required : vdpau) 616if dep_vdpau.found() 617 dep_vdpau = dep_vdpau.partial_dependency(compile_args : true) 618 pre_args += '-DHAVE_ST_VDPAU' 619endif 620with_gallium_vdpau = dep_vdpau.found() 621 622vdpau_drivers_path = get_option('vdpau-libs-path') 623if vdpau_drivers_path == '' 624 vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau') 625endif 626 627# GLSL has interesting version output and Meson doesn't parse it correctly as of 628# Meson 1.4.0 629prog_glslang = find_program('glslangValidator', native : true, 630 required : with_vulkan_overlay_layer or with_aco_tests or with_amd_vk or with_intel_vk) 631if prog_glslang.found() 632 # Check if glslang has depfile support. Support was added in 11.3.0, but 633 # Windows path support was broken until 11.9.0. 634 # 635 # It is intentional to check the build machine, since we need to ensure that 636 # glslang will output valid paths on the build platform 637 _glslang_check = build_machine.system() == 'windows' ? '>= 11.9.0' : '>= 11.3.0' 638 if run_command(prog_glslang, ['--version'], check : false).stdout().split(':')[2].version_compare(_glslang_check) 639 glslang_depfile = ['--depfile', '@DEPFILE@'] 640 else 641 glslang_depfile = [] 642 endif 643 if run_command(prog_glslang, [ '--quiet', '--version' ], check : false).returncode() == 0 644 glslang_quiet = ['--quiet'] 645 else 646 glslang_quiet = [] 647 endif 648endif 649 650_va_drivers = [ 651 with_gallium_d3d12_video, 652 with_gallium_nouveau, 653 with_gallium_r600, 654 with_gallium_radeonsi, 655 with_gallium_virgl, 656] 657 658_va = get_option('gallium-va') \ 659 .require(_va_drivers.contains(true), 660 error_message : 'VA state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau, d3d12 (with option gallium-d3d12-video), virgl.') 661_dep_va_name = host_machine.system() == 'windows' ? 'libva-win32' : 'libva' 662dep_va = dependency(_dep_va_name, version : '>= 1.8.0', required : _va) 663if dep_va.found() 664 dep_va_headers = dep_va.partial_dependency(compile_args : true) 665 if cc.has_header_symbol('va/va.h', 'VASurfaceAttribDRMFormatModifiers', 666 dependencies: dep_va_headers) 667 pre_args += '-DHAVE_VA_SURFACE_ATTRIB_DRM_FORMAT_MODIFIERS' 668 endif 669endif 670with_gallium_va = dep_va.found() 671 672va_drivers_path = get_option('va-libs-path') 673if va_drivers_path == '' 674 va_drivers_path = join_paths(get_option('libdir'), 'dri') 675endif 676 677with_gallium_xa = get_option('gallium-xa') \ 678 .require(system_has_kms_drm, error_message : 'XA state tracker can only be built on unix-like OSes.') \ 679 .require(with_gallium_nouveau or with_gallium_freedreno or with_gallium_i915 or with_gallium_svga, 680 error_message : 'XA state tracker requires at least one of the following gallium drivers: nouveau, freedreno, i915, svga.') \ 681 .allowed() 682 683d3d_drivers_path = get_option('d3d-drivers-path') 684if d3d_drivers_path == '' 685 d3d_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'd3d') 686endif 687 688with_gallium_st_nine = get_option('gallium-nine') 689if with_gallium_st_nine 690 if not with_gallium_swrast 691 error('The nine state tracker requires gallium softpipe/llvmpipe.') 692 elif not [ 693 with_gallium_crocus, 694 with_gallium_freedreno, 695 with_gallium_i915, 696 with_gallium_iris, 697 with_gallium_nouveau, 698 with_gallium_panfrost, 699 with_gallium_r300, 700 with_gallium_r600, 701 with_gallium_radeonsi, 702 with_gallium_svga, 703 with_gallium_zink, 704 ].contains(true) 705 error('The nine state tracker requires at least one non-swrast gallium driver.') 706 endif 707endif 708with_gallium_st_d3d10umd = get_option('gallium-d3d10umd') 709if with_gallium_st_d3d10umd 710 if not with_gallium_swrast 711 error('The d3d10umd state tracker requires gallium softpipe/llvmpipe.') 712 endif 713endif 714_power8 = get_option('power8') 715if _power8.allowed() 716 if host_machine.cpu_family() == 'ppc64' and host_machine.endian() == 'little' 717 if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.8') 718 error('Altivec is not supported with gcc version < 4.8.') 719 endif 720 if cc.compiles(''' 721 #include <altivec.h> 722 int main() { 723 vector unsigned char r; 724 vector unsigned int v = vec_splat_u32 (1); 725 r = __builtin_vec_vgbbd ((vector unsigned char) v); 726 return 0; 727 }''', 728 args : '-mpower8-vector', 729 name : 'POWER8 intrinsics') 730 pre_args += ['-D_ARCH_PWR8'] 731 c_cpp_args += '-mpower8-vector' 732 elif _power8.enabled() 733 error('POWER8 intrinsic support required but not found.') 734 endif 735 endif 736endif 737 738if get_option('vmware-mks-stats') 739 if not with_gallium_svga 740 error('vmware-mks-stats requires gallium VMware/svga driver.') 741 endif 742 pre_args += '-DVMX86_STATS=1' 743endif 744 745_opencl = get_option('gallium-opencl') 746_rtti = get_option('cpp_rtti') 747if _opencl != 'disabled' 748 if not with_gallium 749 error('OpenCL Clover implementation requires at least one gallium driver.') 750 endif 751 if not _rtti 752 error('The Clover OpenCL state tracker requires rtti') 753 endif 754 755 with_gallium_clover = true 756 with_opencl_icd = _opencl == 'icd' 757else 758 with_gallium_clover = false 759 with_opencl_icd = false 760endif 761 762with_gallium_rusticl = get_option('gallium-rusticl') 763if with_gallium_rusticl 764 if not with_gallium 765 error('rusticl requires at least one gallium driver.') 766 endif 767endif 768 769if with_gallium_rusticl or with_nouveau_vk or with_tools.contains('etnaviv') 770 if with_gallium_rusticl 771 # uses rust.bindgen.output_inline_wrapper needing 1.4.0 772 if meson.version().version_compare('< 1.4.0') 773 error('Rusticl requires meson 1.4.0 or newer') 774 endif 775 else 776 # see https://github.com/mesonbuild/meson/issues/12758 (backported to 1.3.2) 777 if meson.version().version_compare('< 1.3.2') 778 error('Mesa Rust support requires meson 1.3.2 or newer') 779 endif 780 endif 781 782 add_languages('rust', required: true) 783 rustc = meson.get_compiler('rust') 784 rust = import('rust') 785 786 if rustc.version().version_compare('< 1.76') 787 error('Mesa requires Rust 1.76.0 or newer') 788 endif 789 790 bindgen_version = find_program('bindgen').version() 791 if bindgen_version == 'unknown' 792 error('Failed to detect bindgen version. If you are using bindgen 0.69.0, ' + 793 'please either update to 0.69.1 or downgrade to 0.68.1. ' + 794 'You can install the latest version for your user with `cargo install bindgen-cli`.') 795 endif 796 797 if bindgen_version.version_compare('< 0.65') 798 error('Mesa requires bindgen 0.65 or newer. ' + 799 'If your distribution does not ship a recent enough version, ' + 800 'you can install the latest version for your user with `cargo install bindgen-cli`.') 801 endif 802endif 803 804with_clover_spirv = with_gallium_clover and get_option('opencl-spirv') 805with_clc = with_microsoft_clc or with_intel_clc or with_gallium_asahi or with_asahi_vk or with_gallium_rusticl or with_clover_spirv 806 807dep_clc = null_dep 808if with_gallium_clover or with_clc 809 dep_clc = dependency('libclc') 810endif 811 812gl_pkgconfig_c_flags = [] 813with_glx_indirect_rendering = false 814if with_platform_x11 815 if with_glx == 'xlib' 816 pre_args += '-DUSE_XSHM' 817 else 818 with_glx_indirect_rendering = true 819 pre_args += '-DGLX_INDIRECT_RENDERING' 820 if with_glx_direct 821 pre_args += '-DGLX_DIRECT_RENDERING' 822 endif 823 if with_dri_platform == 'drm' 824 pre_args += '-DGLX_USE_DRM' 825 elif with_dri_platform == 'apple' 826 pre_args += '-DGLX_USE_APPLEGL' 827 # Check to see if more than just the default 'swrast' is required 828 if (not with_gallium_softpipe) or 1 < gallium_drivers.length() 829 # Switch the MacOS code from "forwarding to the OpenGL.framework" mode 830 # and into actual Gallium Driver mode 831 pre_args += '-DGLX_USE_APPLE' 832 endif 833 elif with_dri_platform == 'windows' 834 pre_args += '-DGLX_USE_WINDOWSGL' 835 endif 836 endif 837endif 838 839with_glapi_export_proto_entry_points = false 840if with_shared_glapi and not with_glx_indirect_rendering 841 # Imply !defined(GLX_INDIRECT_RENDERING) 842 with_glapi_export_proto_entry_points = true 843endif 844pre_args += '-DGLAPI_EXPORT_PROTO_ENTRY_POINTS=@0@'.format(with_glapi_export_proto_entry_points.to_int()) 845 846with_android_stub = get_option('android-stub') 847if with_android_stub and not with_platform_android 848 error('`-D android-stub=true` makes no sense without `-D platforms=android`') 849endif 850 851with_libbacktrace = get_option('android-libbacktrace') \ 852 .require(with_platform_android, error_message : '`-D android-libbacktrace=enabled` makes no sense without `-D platforms=android`') \ 853 .disable_auto_if(not with_platform_android) \ 854 .allowed() 855 856if with_libbacktrace 857 cpp_args += '-DWITH_LIBBACKTRACE' 858endif 859 860if with_platform_android 861 dep_android_mapper4 = null_dep 862 if not with_android_stub 863 dep_android = [ 864 dependency('cutils'), 865 dependency('hardware'), 866 dependency('log'), 867 dependency('sync'), 868 ] 869 if with_libbacktrace 870 dep_android += dependency('backtrace') 871 endif 872 if get_option('platform-sdk-version') >= 26 873 dep_android += dependency('nativewindow') 874 endif 875 if get_option('platform-sdk-version') >= 30 876 dep_android_mapper4 = dependency('android.hardware.graphics.mapper', version : '>= 4.0', required : false) 877 endif 878 endif 879 pre_args += '-DANDROID_API_LEVEL=' + get_option('platform-sdk-version').to_string() 880 if get_option('android-strict') 881 pre_args += '-DANDROID_STRICT' 882 endif 883endif 884 885# On Android, seccomp kills the process on kernels without 886# CONFIG_KCMP/CONFIG_CHECKPOINT_RESTORE if it attemps to use KCMP. 887# Since we can't detect that, err on the side of caution and disable 888# KCMP by default on Android. 889if get_option('allow-kcmp') \ 890 .disable_auto_if(with_platform_android) \ 891 .allowed() 892 pre_args += '-DALLOW_KCMP' 893endif 894 895prog_python = import('python').find_installation('python3') 896has_mako = run_command( 897 prog_python, '-c', 898 ''' 899try: 900 from packaging.version import Version 901except: 902 from distutils.version import StrictVersion as Version 903import mako 904assert Version(mako.__version__) >= Version("0.8.0") 905 ''', check: false) 906if has_mako.returncode() != 0 907 error('Python (3.x) mako module >= 0.8.0 required to build mesa.') 908endif 909 910has_yaml = run_command( 911 prog_python, '-c', 912 ''' 913import yaml 914 ''', check: false) 915if has_yaml.returncode() != 0 916 error('Python (3.x) yaml module (PyYAML) required to build mesa.') 917endif 918 919if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6') 920 error('When using GCC, version 4.4.6 or later is required.') 921endif 922 923# Support systems without ETIME (e.g. FreeBSD) 924if cc.get_define('ETIME', prefix : '#include <errno.h>') == '' 925 pre_args += '-DETIME=ETIMEDOUT' 926endif 927 928# Define MESA_DEBUG to 1 for debug builds only (debugoptimized is not included on this one); 929# otherwise define MESA_DEBUG to 0 930pre_args += '-DMESA_DEBUG=@0@'.format(with_mesa_debug.to_int()) 931 932with_split_debug = get_option('split-debug') \ 933 .disable_if(not cc.has_argument('-gsplit-dwarf'), 934 error_message : 'split-debug requires compiler -gsplit-dwarf support') \ 935 .disable_if(not cc.has_link_argument('-Wl,--gdb-index'), 936 error_message : 'split-debug requires the linker argument -Wl,--gdb-index') 937 938if with_split_debug.allowed() and get_option('debug') 939 add_project_arguments('-gsplit-dwarf', language : ['c', 'cpp']) 940 add_project_link_arguments('-Wl,--gdb-index', language : ['c', 'cpp']) 941endif 942 943with_shader_cache = get_option('shader-cache') \ 944 .require(host_machine.system() != 'windows', error_message : 'Shader Cache does not currently work on Windows') \ 945 .allowed() 946 947if with_shader_cache 948 pre_args += '-DENABLE_SHADER_CACHE' 949 if not get_option('shader-cache-default') 950 pre_args += '-DSHADER_CACHE_DISABLE_BY_DEFAULT' 951 endif 952 953 shader_cache_max_size = get_option('shader-cache-max-size') 954 if shader_cache_max_size != '' 955 pre_args += '-DMESA_SHADER_CACHE_MAX_SIZE="@0@"'.format(shader_cache_max_size) 956 endif 957endif 958 959# Check for GCC style builtins 960foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs', 961 'ffsll', 'popcount', 'popcountll', 'unreachable', 'types_compatible_p'] 962 if cc.has_function(b) 963 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper()) 964 endif 965endforeach 966 967# check for GCC __attribute__ 968_attributes = [ 969 'const', 'flatten', 'malloc', 'pure', 'unused', 'warn_unused_result', 970 'weak', 'format', 'packed', 'returns_nonnull', 'alias', 'noreturn', 971 'optimize', 972] 973foreach a : cc.get_supported_function_attributes(_attributes) 974 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper()) 975endforeach 976if cc.has_function_attribute('visibility:hidden') 977 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISIBILITY' 978endif 979if cc.compiles('__uint128_t foo(void) { return 0; }', 980 name : '__uint128_t') 981 pre_args += '-DHAVE_UINT128' 982endif 983 984if cc.has_function('reallocarray') 985 pre_args += '-DHAVE_REALLOCARRAY' 986endif 987if cc.has_function('fmemopen') 988 pre_args += '-DHAVE_FMEMOPEN' 989endif 990 991# TODO: this is very incomplete 992if ['linux', 'cygwin', 'gnu', 'freebsd', 'gnu/kfreebsd', 'haiku', 'android', 'managarm'].contains(host_machine.system()) 993 pre_args += '-D_GNU_SOURCE' 994elif host_machine.system() == 'sunos' 995 pre_args += '-D__EXTENSIONS__' 996elif host_machine.system() == 'windows' 997 pre_args += [ 998 '-D_WINDOWS', '-D_WIN32_WINNT=0x0A00', '-DWINVER=0x0A00', 999 '-DPIPE_SUBSYSTEM_WINDOWS_USER', 1000 '-D_USE_MATH_DEFINES', # XXX: scons didn't use this for mingw 1001 ] 1002 if cc.get_argument_syntax() == 'msvc' 1003 pre_args += [ 1004 '-DVC_EXTRALEAN', 1005 '-D_CRT_SECURE_NO_WARNINGS', 1006 '-D_CRT_SECURE_NO_DEPRECATE', 1007 '-D_SCL_SECURE_NO_WARNINGS', 1008 '-D_SCL_SECURE_NO_DEPRECATE', 1009 '-D_ALLOW_KEYWORD_MACROS', 1010 '-D_HAS_EXCEPTIONS=0', # Tell C++ STL to not use exceptions 1011 '-DNOMINMAX', 1012 ] 1013 else 1014 # When the target is not mingw/ucrt 1015 # NOTE: clang's stddef.h are conflict with mingw/ucrt's stddef.h 1016 # So do not include headers that defined in clang for detecting 1017 # _UCRT 1018 if cc.compiles(''' 1019 #include <string.h> 1020 #if defined(__MINGW32__) && defined(_UCRT) 1021 #error 1022 #endif 1023 int main(void) { return 0; }''') 1024 pre_args += ['-D__MSVCRT_VERSION__=0x0700'] 1025 endif 1026 endif 1027elif host_machine.system() == 'openbsd' 1028 pre_args += '-D_ISOC11_SOURCE' 1029endif 1030 1031# Check for generic C arguments 1032c_msvc_compat_args = [] 1033no_override_init_args = [] 1034cpp_msvc_compat_args = [] 1035ld_args_gc_sections = [] 1036if cc.get_argument_syntax() == 'msvc' 1037 _trial = [ 1038 '/wd4018', # signed/unsigned mismatch 1039 '/wd4056', # overflow in floating-point constant arithmetic 1040 '/wd4244', # conversion from 'type1' to 'type2', possible loss of data 1041 '/wd4267', # 'var' : conversion from 'size_t' to 'type', possible loss of data 1042 '/wd4305', # truncation from 'type1' to 'type2' 1043 '/wd4351', # new behavior: elements of array 'array' will be default initialized 1044 '/wd4756', # overflow in constant arithmetic 1045 '/wd4800', # forcing value to bool 'true' or 'false' (performance warning) 1046 '/wd4996', # disabled deprecated POSIX name warnings 1047 '/wd4291', # no matching operator delete found 1048 '/wd4146', # unary minus operator applied to unsigned type, result still unsigned 1049 '/wd4200', # nonstandard extension used: zero-sized array in struct/union 1050 '/wd4624', # destructor was implicitly defined as deleted [from LLVM] 1051 '/wd4309', # 'initializing': truncation of constant value 1052 '/wd4838', # conversion from 'int' to 'const char' requires a narrowing conversion 1053 '/wd5105', # macro expansion producing 'defined' has undefined behavior (winbase.h, need Windows SDK upgrade) 1054 '/we4020', # Error when passing the wrong number of parameters 1055 '/we4024', # Error when passing different type of parameter 1056 '/we4189', # 'identifier' : local variable is initialized but not referenced 1057 '/Zc:__cplusplus', #Set __cplusplus macro to match the /std:c++<version> on the command line 1058 ] 1059 c_args += cc.get_supported_arguments(_trial) 1060 cpp_args += cpp.get_supported_arguments(_trial) 1061else 1062 _trial_c = [ 1063 '-Werror=implicit-function-declaration', 1064 '-Werror=missing-prototypes', 1065 '-Werror=return-type', 1066 '-Werror=empty-body', 1067 '-Werror=incompatible-pointer-types', 1068 '-Werror=int-conversion', 1069 '-Wimplicit-fallthrough', 1070 '-Wmisleading-indentation', 1071 '-Wno-missing-field-initializers', 1072 '-Wno-format-truncation', 1073 '-Wno-nonnull-compare', 1074 '-fno-math-errno', 1075 '-fno-trapping-math', 1076 '-Qunused-arguments', 1077 '-fno-common', 1078 '-Wno-unknown-pragmas', 1079 # Clang 1080 '-Wno-microsoft-enum-value', 1081 '-Wno-unused-function', 1082 ] 1083 _trial_cpp = [ 1084 '-Werror=return-type', 1085 '-Werror=empty-body', 1086 '-Wmisleading-indentation', 1087 '-Wno-non-virtual-dtor', 1088 '-Wno-missing-field-initializers', 1089 '-Wno-format-truncation', 1090 '-fno-math-errno', 1091 '-fno-trapping-math', 1092 '-Qunused-arguments', 1093 # Some classes use custom new operator which zeroes memory, however 1094 # gcc does aggressive dead-store elimination which threats all writes 1095 # to the memory before the constructor as "dead stores". 1096 # For now we disable this optimization. 1097 '-flifetime-dse=1', 1098 '-Wno-unknown-pragmas', 1099 # Clang 1100 '-Wno-microsoft-enum-value', 1101 ] 1102 1103 # MinGW chokes on format specifiers and I can't get it all working 1104 if not (cc.get_argument_syntax() == 'gcc' and host_machine.system() == 'windows') 1105 _trial_c += ['-Werror=format', '-Wformat-security'] 1106 _trial_cpp += ['-Werror=format', '-Wformat-security'] 1107 endif 1108 1109 # FreeBSD annotated <pthread.h> but Mesa isn't ready 1110 if not (cc.get_id() == 'clang' and host_machine.system() == 'freebsd') 1111 _trial_c += ['-Werror=thread-safety'] 1112 endif 1113 1114 # If the compiler supports it, put function and data symbols in their 1115 # own sections and GC the sections after linking. This lets drivers 1116 # drop shared code unused by that specific driver (particularly 1117 # relevant for Vulkan drivers). 1118 if cc.links('static char unused() { return 5; } int main() { return 0; }', 1119 args : '-Wl,--gc-sections', name : 'gc-sections') 1120 ld_args_gc_sections += '-Wl,--gc-sections' 1121 _trial_c += ['-ffunction-sections', '-fdata-sections'] 1122 _trial_cpp += ['-ffunction-sections', '-fdata-sections'] 1123 endif 1124 1125 # Variables that are only used for assertions are considered unused when assertions 1126 # are disabled. Don't treat this as an error, since we build with -Werror even if 1127 # assertions are disabled. 1128 if with_mesa_ndebug 1129 _trial_c += ['-Wno-unused-variable', '-Wno-unused-but-set-variable', '/wd4189'] 1130 _trial_cpp += ['-Wno-unused-variable', '-Wno-unused-but-set-variable', '/wd4189'] 1131 endif 1132 1133 c_args += cc.get_supported_arguments(_trial_c) 1134 cpp_args += cpp.get_supported_arguments(_trial_cpp) 1135 1136 no_override_init_args += cc.get_supported_arguments( 1137 ['-Wno-override-init', '-Wno-initializer-overrides'] 1138 ) 1139 1140 # Check for C and C++ arguments for MSVC compatibility. These are only used 1141 # in parts of the mesa code base that need to compile with MSVC, mainly 1142 # common code 1143 _trial_msvc = ['-Werror=pointer-arith', '-Werror=vla', '-Werror=gnu-empty-initializer'] 1144 c_msvc_compat_args += cc.get_supported_arguments(_trial_msvc) 1145 cpp_msvc_compat_args += cpp.get_supported_arguments(_trial_msvc) 1146endif 1147 1148# set linker arguments 1149if host_machine.system() == 'windows' 1150 if cc.get_argument_syntax() == 'msvc' 1151 add_project_link_arguments( 1152 '/fixed:no', 1153 '/dynamicbase', 1154 '/nxcompat', 1155 language : ['c', 'cpp'], 1156 ) 1157 if get_option('buildtype') != 'debug' 1158 add_project_link_arguments( 1159 '/incremental:no', 1160 language : ['c', 'cpp'], 1161 ) 1162 endif 1163 else 1164 add_project_link_arguments( 1165 cc.get_supported_link_arguments( 1166 '-Wl,--nxcompat', 1167 '-Wl,--dynamicbase', 1168 '-static-libgcc', 1169 '-static-libstdc++', 1170 ), 1171 language : ['c'], 1172 ) 1173 add_project_link_arguments( 1174 cpp.get_supported_link_arguments( 1175 '-Wl,--nxcompat', 1176 '-Wl,--dynamicbase', 1177 '-static-libgcc', 1178 '-static-libstdc++', 1179 ), 1180 language : ['cpp'], 1181 ) 1182 endif 1183endif 1184 1185sse2_arg = [] 1186sse2_args = [] 1187sse41_args = [] 1188with_sse41 = false 1189if host_machine.cpu_family().startswith('x86') 1190 pre_args += '-DUSE_SSE41' 1191 with_sse41 = true 1192 1193 if cc.get_id() != 'msvc' 1194 sse41_args = ['-msse4.1'] 1195 1196 if host_machine.cpu_family() == 'x86' 1197 # x86_64 have sse2 by default, so sse2 args only for x86 1198 sse2_arg = ['-msse2', '-mfpmath=sse'] 1199 sse2_args = [sse2_arg, '-mstackrealign'] 1200 if get_option('sse2') 1201 # These settings make generated GCC code match MSVC and follow 1202 # GCC advice on https://gcc.gnu.org/wiki/FloatingPointMath#x86note 1203 # 1204 # NOTE: We need to ensure stack is realigned given that we 1205 # produce shared objects, and have no control over the stack 1206 # alignment policy of the application. Therefore we need 1207 # -mstackrealign or -mincoming-stack-boundary=2. 1208 # 1209 # XXX: We could have SSE without -mstackrealign if we always used 1210 # __attribute__((force_align_arg_pointer)), but that's not 1211 # always the case. 1212 c_cpp_args += sse2_args 1213 # sse2_args are adopted into c_cpp_args to avoid duplicated sse2 command line args 1214 sse2_arg = [] 1215 sse2_args = [] 1216 else 1217 # GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but 1218 # that's not guaranteed 1219 sse41_args += '-mstackrealign' 1220 endif 1221 endif 1222 endif 1223endif 1224 1225# Detect __builtin_ia32_clflushopt support 1226if cc.has_function('__builtin_ia32_clflushopt', args : '-mclflushopt') 1227 pre_args += '-DHAVE___BUILTIN_IA32_CLFLUSHOPT' 1228 clflushopt_args = ['-mclflushopt'] 1229 with_clflushopt = true 1230else 1231 clflushopt_args = [] 1232 with_clflushopt = false 1233endif 1234 1235# Check for GCC style atomics 1236dep_atomic = null_dep 1237 1238if cc.compiles('''#include <stdint.h> 1239 int main() { 1240 struct { 1241 uint64_t *v; 1242 } x; 1243 return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) & 1244 (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL); 1245 1246 }''', 1247 name : 'GCC atomic builtins') 1248 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS' 1249 1250 # Not all atomic calls can be turned into lock-free instructions, in which 1251 # GCC will make calls into the libatomic library. Check whether we need to 1252 # link with -latomic. 1253 # 1254 # This can happen for 64-bit atomic operations on 32-bit architectures such 1255 # as ARM. 1256 if not cc.links('''#include <stdint.h> 1257 int main() { 1258 struct { 1259 uint64_t *v; 1260 } x; 1261 return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) & 1262 (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL); 1263 }''', 1264 name : 'GCC atomic builtins required -latomic') 1265 dep_atomic = cc.find_library('atomic') 1266 endif 1267endif 1268if not cc.links('''#include <stdint.h> 1269 uint64_t v; 1270 int main() { 1271 return __sync_add_and_fetch(&v, (uint64_t)1); 1272 }''', 1273 dependencies : dep_atomic, 1274 name : 'GCC 64bit atomics') 1275 pre_args += '-DMISSING_64BIT_ATOMICS' 1276endif 1277 1278dep_ws2_32 = cc.find_library('ws2_32', required : with_platform_windows) 1279 1280# TODO: shared/static? Is this even worth doing? 1281 1282with_asm_arch = '' 1283if host_machine.cpu_family() == 'x86' 1284 if system_has_kms_drm or host_machine.system() == 'gnu' 1285 with_asm_arch = 'x86' 1286 pre_args += ['-DUSE_X86_ASM'] 1287 1288 if with_glx_read_only_text 1289 pre_args += ['-DGLX_X86_READONLY_TEXT'] 1290 endif 1291 endif 1292elif host_machine.cpu_family() == 'x86_64' 1293 if system_has_kms_drm 1294 with_asm_arch = 'x86_64' 1295 pre_args += ['-DUSE_X86_64_ASM'] 1296 endif 1297elif host_machine.cpu_family() == 'arm' 1298 if system_has_kms_drm 1299 with_asm_arch = 'arm' 1300 pre_args += ['-DUSE_ARM_ASM'] 1301 endif 1302elif host_machine.cpu_family() == 'aarch64' 1303 if system_has_kms_drm 1304 with_asm_arch = 'aarch64' 1305 pre_args += ['-DUSE_AARCH64_ASM'] 1306 endif 1307elif host_machine.cpu_family() == 'sparc64' 1308 if system_has_kms_drm 1309 with_asm_arch = 'sparc' 1310 pre_args += ['-DUSE_SPARC_ASM'] 1311 endif 1312elif host_machine.cpu_family() == 'ppc64' and host_machine.endian() == 'little' 1313 if system_has_kms_drm 1314 with_asm_arch = 'ppc64le' 1315 pre_args += ['-DUSE_PPC64LE_ASM'] 1316 endif 1317elif host_machine.cpu_family() == 'mips64' and host_machine.endian() == 'little' 1318 if system_has_kms_drm 1319 with_asm_arch = 'mips64el' 1320 pre_args += ['-DUSE_MIPS64EL_ASM'] 1321 endif 1322elif host_machine.cpu_family() == 'loongarch64' 1323 if system_has_kms_drm 1324 with_asm_arch = 'loongarch64' 1325 pre_args += ['-DUSE_LOONGARCH64_ASM'] 1326 endif 1327endif 1328 1329# Check for standard headers and functions 1330if (cc.has_header_symbol('sys/sysmacros.h', 'major') and 1331 cc.has_header_symbol('sys/sysmacros.h', 'minor') and 1332 cc.has_header_symbol('sys/sysmacros.h', 'makedev')) 1333 pre_args += '-DMAJOR_IN_SYSMACROS' 1334endif 1335if (cc.has_header_symbol('sys/mkdev.h', 'major') and 1336 cc.has_header_symbol('sys/mkdev.h', 'minor') and 1337 cc.has_header_symbol('sys/mkdev.h', 'makedev')) 1338 pre_args += '-DMAJOR_IN_MKDEV' 1339endif 1340 1341if cc.check_header('sched.h') 1342 pre_args += '-DHAS_SCHED_H' 1343 if cc.has_function('sched_getaffinity') 1344 pre_args += '-DHAS_SCHED_GETAFFINITY' 1345 endif 1346endif 1347 1348if not ['linux'].contains(host_machine.system()) 1349 # Deprecated on Linux and requires <sys/types.h> on FreeBSD and OpenBSD 1350 if cc.check_header('sys/sysctl.h', prefix : '#include <sys/types.h>') 1351 pre_args += '-DHAVE_SYS_SYSCTL_H' 1352 endif 1353endif 1354 1355foreach h : ['xlocale.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'sys/shm.h', 1356 'cet.h', 'pthread_np.h', 'sys/inotify.h', 'linux/udmabuf.h'] 1357 if cc.check_header(h) 1358 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify()) 1359 endif 1360endforeach 1361 1362functions_to_detect = { 1363 'strtof': '', 1364 'mkostemp': '', 1365 'memfd_create': '', 1366 'random_r': '', 1367 'flock': '', 1368 'strtok_r': '', 1369 'getrandom': '', 1370 'qsort_s': '', 1371 'posix_fallocate': '', 1372 'secure_getenv': '', 1373} 1374 1375foreach f, prefix: functions_to_detect 1376 if cc.has_function(f, prefix: prefix) 1377 pre_args += '-DHAVE_@0@'.format(f.to_upper()) 1378 endif 1379endforeach 1380 1381if cpp.links(''' 1382 #define _GNU_SOURCE 1383 #include <stdlib.h> 1384 1385 static int dcomp(const void *l, const void *r, void *t) { return 0; } 1386 1387 int main(int ac, char **av) { 1388 int arr[] = { 1 }; 1389 void *t = NULL; 1390 qsort_r((void*)&arr[0], 1, 1, dcomp, t); 1391 return (0); 1392 }''', 1393 args : pre_args, 1394 name : 'GNU qsort_r') 1395 pre_args += '-DHAVE_GNU_QSORT_R' 1396elif cpp.links(''' 1397 #include <stdlib.h> 1398 1399 static int dcomp(void *t, const void *l, const void *r) { return 0; } 1400 1401 int main(int ac, char **av) { 1402 int arr[] = { 1 }; 1403 void *t = NULL; 1404 qsort_r((void*)&arr[0], 1, 1, t, dcomp); 1405 return (0); 1406 }''', 1407 args : pre_args, 1408 name : 'BSD qsort_r') 1409 pre_args += '-DHAVE_BSD_QSORT_R' 1410endif 1411 1412if cc.has_header_symbol('time.h', 'struct timespec') 1413 pre_args += '-DHAVE_STRUCT_TIMESPEC' 1414endif 1415 1416with_c11_threads = false 1417if cc.has_function('thrd_create', prefix: '#include <threads.h>') 1418 if with_platform_android 1419 # Current only Android's c11 <threads.h> are verified 1420 pre_args += '-DHAVE_THRD_CREATE' 1421 with_c11_threads = true 1422 endif 1423endif 1424 1425if cc.has_header_symbol('errno.h', 'program_invocation_name', 1426 args : '-D_GNU_SOURCE') 1427 pre_args += '-DHAVE_PROGRAM_INVOCATION_NAME' 1428elif with_tools.contains('intel') 1429 error('Intel tools require the program_invocation_name variable') 1430endif 1431 1432if cc.has_header_symbol('math.h', 'issignaling', 1433 args : '-D_GNU_SOURCE') 1434 pre_args += '-DHAVE_ISSIGNALING' 1435endif 1436 1437# MinGW provides a __builtin_posix_memalign function, but not a posix_memalign. 1438# This means that this check will succeed, but then compilation will later 1439# fail. MSVC doesn't have this function at all, so only check for it on 1440# non-windows platforms. 1441if host_machine.system() != 'windows' 1442 if cc.has_function('posix_memalign') 1443 pre_args += '-DHAVE_POSIX_MEMALIGN' 1444 endif 1445endif 1446 1447if cc.has_member('struct dirent', 'd_type', prefix: '''#include <sys/types.h> 1448 #include <dirent.h>''') 1449 pre_args += '-DHAVE_DIRENT_D_TYPE' 1450endif 1451 1452# strtod locale support 1453if cc.links(''' 1454 #define _GNU_SOURCE 1455 #include <stdlib.h> 1456 #include <locale.h> 1457 #ifdef HAVE_XLOCALE_H 1458 #include <xlocale.h> 1459 #endif 1460 int main() { 1461 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL); 1462 const char *s = "1.0"; 1463 char *end; 1464 double d = strtod_l(s, &end, loc); 1465 float f = strtof_l(s, &end, loc); 1466 freelocale(loc); 1467 return 0; 1468 }''', 1469 args : pre_args, 1470 name : 'strtod has locale support') 1471 pre_args += '-DHAVE_STRTOD_L' 1472endif 1473 1474# Check for some linker flags 1475ld_args_bsymbolic = [] 1476if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic') 1477 ld_args_bsymbolic += '-Wl,-Bsymbolic' 1478endif 1479with_ld_version_script = false 1480if cc.links('int main() { return 0; }', 1481 args : '-Wl,--version-script=@0@'.format( 1482 join_paths(meson.current_source_dir(), 'build-support/conftest.map')), 1483 name : 'version-script') 1484 with_ld_version_script = true 1485endif 1486with_ld_dynamic_list = false 1487if cc.links('int main() { return 0; }', 1488 args : '-Wl,--dynamic-list=@0@'.format( 1489 join_paths(meson.current_source_dir(), 'build-support/conftest.dyn')), 1490 name : 'dynamic-list') 1491 with_ld_dynamic_list = true 1492endif 1493 1494ld_args_build_id = cc.get_supported_link_arguments('-Wl,--build-id=sha1') 1495 1496# check for dl support 1497dep_dl = null_dep 1498if host_machine.system() != 'windows' 1499 if not cc.has_function('dlopen') 1500 dep_dl = cc.find_library('dl', required : true) 1501 endif 1502 if cc.has_function('dladdr', dependencies : dep_dl) 1503 # This is really only required for util/disk_cache.h 1504 pre_args += '-DHAVE_DLADDR' 1505 endif 1506endif 1507 1508if cc.has_function('dl_iterate_phdr') 1509 pre_args += '-DHAVE_DL_ITERATE_PHDR' 1510elif with_intel_vk or with_intel_hasvk 1511 error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr function') 1512endif 1513 1514if with_any_intel and ['x86', 'x86_64'].contains(host_machine.cpu_family()) 1515 pre_args += '-DSUPPORT_INTEL_INTEGRATED_GPUS' 1516endif 1517 1518if with_gallium_i915 and host_machine.cpu_family().startswith('x86') == false 1519 error('Intel "i915" Gallium driver requires x86 or x86_64 CPU family') 1520endif 1521 1522# Determine whether or not the rt library is needed for time functions 1523if host_machine.system() == 'windows' or cc.has_function('clock_gettime') 1524 dep_clock = null_dep 1525else 1526 dep_clock = cc.find_library('rt') 1527endif 1528 1529# IMPORTANT: We can't upgrade Zlib beyond 1.2.5 because it would break Viewperf. 1530dep_zlib = dependency('zlib', version : '>= 1.2.3', 1531 allow_fallback: true, 1532 required : get_option('zlib')) 1533if dep_zlib.found() 1534 pre_args += '-DHAVE_ZLIB' 1535endif 1536 1537dep_zstd = dependency('libzstd', required : get_option('zstd')) 1538if dep_zstd.found() 1539 pre_args += '-DHAVE_ZSTD' 1540endif 1541 1542with_compression = dep_zlib.found() or dep_zstd.found() 1543if with_compression 1544 pre_args += '-DHAVE_COMPRESSION' 1545elif with_shader_cache 1546 error('Shader Cache requires compression') 1547endif 1548 1549if host_machine.system() == 'windows' 1550 # For MSVC and MinGW we aren't using pthreads, and dependency('threads') will add linkage 1551 # to pthread for MinGW, so leave the dependency null_dep for Windows. For Windows linking to 1552 # kernel32 is enough for c11/threads.h and it's already linked by meson by default 1553 dep_thread = null_dep 1554else 1555 dep_thread = dependency('threads') 1556endif 1557if dep_thread.found() 1558 pre_args += '-DHAVE_PTHREAD' 1559 if host_machine.system() != 'netbsd' and cc.has_function( 1560 'pthread_setaffinity_np', 1561 dependencies : dep_thread, 1562 prefix : '#include <pthread.h>', 1563 args : '-D_GNU_SOURCE') 1564 pre_args += '-DHAVE_PTHREAD_SETAFFINITY' 1565 endif 1566endif 1567 1568with_expat = get_option('expat') \ 1569 .disable_auto_if(with_platform_android or with_platform_windows) 1570 1571if host_machine.system() == 'darwin' 1572 dep_expat = meson.get_compiler('c').find_library('expat', required : with_expat) 1573else 1574 dep_expat = dependency('expat', allow_fallback: true, 1575 required : with_expat) 1576endif 1577 1578# TODO: with Meson 1.1.0 this can be replaced with with_expat.enable_if(with_intel_tools) 1579if with_intel_tools and not dep_expat.found() 1580 error('Intel tools require expat') 1581endif 1582 1583# We don't require expat on Android or Windows 1584use_xmlconfig = get_option('xmlconfig') \ 1585 .require(not (with_platform_android or with_platform_windows), 1586 error_message : 'xmlconfig not available on Android or Windows') \ 1587 .require(dep_expat.found(), 1588 error_message : 'requires expat') \ 1589 .allowed() 1590 1591# Predefined macros for windows 1592if host_machine.system() == 'windows' 1593 pre_args += '-DWIN32_LEAN_AND_MEAN' # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx 1594endif 1595# this only exists on linux so either this is linux and it will be found, or 1596# it's not linux and wont 1597dep_m = cc.find_library('m', required : false) 1598 1599if host_machine.system() == 'windows' 1600 dep_regex = meson.get_compiler('c').find_library('regex', required : false) 1601 if not dep_regex.found() 1602 dep_regex = declare_dependency(compile_args : ['-DNO_REGEX']) 1603 endif 1604else 1605 dep_regex = null_dep 1606endif 1607 1608if with_platform_haiku 1609 dep_network = cc.find_library('network') 1610endif 1611 1612dep_futex = null_dep 1613if host_machine.system() == 'windows' 1614 if (get_option('min-windows-version') < 8) 1615 pre_args += '-DWINDOWS_NO_FUTEX' 1616 else 1617 dep_futex = cc.find_library('synchronization', required : true) 1618 endif 1619endif 1620 1621# Check for libdrm. Various drivers have different libdrm version requirements, 1622# but we always want to use the same version for all libdrm modules. That means 1623# even if driver foo requires 2.4.0 and driver bar requires 2.4.3, if foo and 1624# bar are both on use 2.4.3 for both of them 1625dep_libdrm_amdgpu = null_dep 1626dep_libdrm_radeon = null_dep 1627dep_libdrm_intel = null_dep 1628 1629_drm_amdgpu_ver = '2.4.121' 1630_drm_radeon_ver = '2.4.71' 1631_drm_intel_ver = '2.4.75' 1632_drm_ver = '2.4.109' 1633 1634_libdrm_checks = [ 1635 ['intel', with_gallium_i915], 1636 ['amdgpu', (with_amd_vk and not with_platform_windows) or with_gallium_radeonsi], 1637 ['radeon', (with_gallium_radeonsi or with_gallium_r300 or with_gallium_r600)], 1638] 1639 1640# Loop over the enables versions and get the highest libdrm requirement for all 1641# active drivers. 1642_drm_blame = '' 1643foreach d : _libdrm_checks 1644 ver = get_variable('_drm_@0@_ver'.format(d[0])) 1645 if d[1] and ver.version_compare('>' + _drm_ver) 1646 _drm_ver = ver 1647 _drm_blame = d[0] 1648 endif 1649endforeach 1650if _drm_blame != '' 1651 message('libdrm @0@ needed because @1@ has the highest requirement'.format(_drm_ver, _drm_blame)) 1652endif 1653 1654# Then get each libdrm module 1655foreach d : _libdrm_checks 1656 if d[1] 1657 set_variable( 1658 'dep_libdrm_' + d[0], 1659 dependency('libdrm_' + d[0], version : '>=' + _drm_ver) 1660 ) 1661 endif 1662endforeach 1663 1664with_gallium_drisw_kms = false 1665if system_has_kms_drm 1666 dep_libdrm = dependency( 1667 'libdrm', version : '>=' + _drm_ver, 1668 required : with_dri2 or with_dri or with_gbm 1669 ) 1670else 1671 # We should prevent libdrm from being available when the target doesn't have it to avoid transitive 1672 # dependencies (such as vk-runtime) linking to it 1673 dep_libdrm = null_dep 1674endif 1675if dep_libdrm.found() 1676 pre_args += '-DHAVE_LIBDRM' 1677 if with_dri_platform == 'drm' and with_dri 1678 with_gallium_drisw_kms = true 1679 endif 1680endif 1681 1682dep_libudev = dependency('libudev', required : false) 1683if dep_libudev.found() 1684 pre_args += '-DHAVE_LIBUDEV' 1685endif 1686 1687llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit', 'core', 'executionengine', 'scalaropts', 'transformutils', 'instcombine'] 1688llvm_optional_modules = ['coroutines'] 1689if with_amd_vk or with_gallium_radeonsi or with_gallium_r600 1690 llvm_modules += ['amdgpu', 'bitreader', 'ipo'] 1691 if with_gallium_r600 1692 llvm_modules += 'asmparser' 1693 endif 1694endif 1695if with_gallium_clover 1696 llvm_modules += [ 1697 'linker', 'coverage', 'instrumentation', 'ipo', 'irreader', 1698 'lto', 'option', 'objcarcopts', 'profiledata' 1699 ] 1700 # all-targets is needed to support static linking LLVM build with multiple targets 1701 # windowsdriver is needded with LLVM>=15, but we don't know what LLVM verrsion we are using yet 1702 llvm_optional_modules += ['all-targets', 'frontendopenmp', 'windowsdriver'] 1703endif 1704if with_clc 1705 llvm_modules += ['coverage', 'target', 'linker', 'irreader', 'option', 'libdriver', 'lto'] 1706 # all-targets is needed to support static linking LLVM build with multiple targets. 1707 # windowsdriver is needded with LLVM>=15 and frontendhlsl is needed with LLVM>=16, 1708 # but we don't know what LLVM version we are using yet 1709 llvm_optional_modules += ['all-targets', 'windowsdriver', 'frontendhlsl', 'frontenddriver'] 1710endif 1711draw_with_llvm = get_option('draw-use-llvm') 1712if draw_with_llvm 1713 llvm_modules += 'native' 1714 # lto is needded with LLVM>=15, but we don't know what LLVM verrsion we are using yet 1715 llvm_optional_modules += ['lto'] 1716endif 1717amd_with_llvm = get_option('amd-use-llvm') 1718 1719# MCJIT is deprecated in LLVM and will not accept new architecture ports, 1720# so any architecture not in the exhaustive list will have to rely on LLVM 1721# ORCJIT for llvmpipe functionality. 1722llvm_has_mcjit = host_machine.cpu_family() in ['aarch64', 'arm', 'ppc', 'ppc64', 's390x', 'x86', 'x86_64'] 1723llvm_with_orcjit = get_option('llvm-orcjit') or not llvm_has_mcjit 1724 1725if with_amd_vk or with_gallium_radeonsi or with_clc or llvm_with_orcjit 1726 _llvm_version = '>= 15.0.0' 1727elif with_gallium_clover 1728 _llvm_version = '>= 11.0.0' 1729else 1730 _llvm_version = '>= 5.0.0' 1731endif 1732 1733_shared_llvm = get_option('shared-llvm') \ 1734 .disable_auto_if(host_machine.system() == 'windows') \ 1735 .allowed() 1736 1737_llvm = get_option('llvm') 1738dep_llvm = null_dep 1739with_llvm = false 1740if _llvm.allowed() 1741 dep_llvm = dependency( 1742 'llvm', 1743 method : host_machine.system() == 'windows' ? 'auto' : 'config-tool', 1744 version : _llvm_version, 1745 modules : llvm_modules, 1746 optional_modules : llvm_optional_modules, 1747 required : ( 1748 with_amd_vk or with_gallium_radeonsi or with_gallium_clover or with_clc 1749 or _llvm.enabled() 1750 ), 1751 static : not _shared_llvm, 1752 fallback : ['llvm', 'dep_llvm'], 1753 include_type : 'system', 1754 ) 1755 with_llvm = dep_llvm.found() 1756endif 1757if with_llvm 1758 pre_args += '-DMESA_LLVM_VERSION_STRING="@0@"'.format(dep_llvm.version()) 1759 pre_args += '-DLLVM_IS_SHARED=@0@'.format(_shared_llvm.to_int()) 1760 1761 if (with_swrast_vk or with_gallium_llvmpipe) and not draw_with_llvm 1762 error('Lavapipe and llvmpipe require LLVM draw support.') 1763 endif 1764 1765 if with_gallium_r600 and not amd_with_llvm 1766 error('R600 requires LLVM AMD support.') 1767 endif 1768 1769 if host_machine.system() != 'windows' 1770 # LLVM can be built without rtti, turning off rtti changes the ABI of C++ 1771 # programs, so we need to build all C++ code in mesa without rtti as well to 1772 # ensure that linking works. Note that Win32 compilers does handle mismatching RTTI 1773 # without issues, so only apply this for other compilers. 1774 if dep_llvm.type_name() == 'internal' 1775 _llvm_rtti = subproject('llvm').get_variable('has_rtti', true) 1776 else 1777 # The CMake finder will return 'ON', the llvm-config will return 'YES' 1778 _llvm_rtti = ['ON', 'YES'].contains(dep_llvm.get_variable(cmake : 'LLVM_ENABLE_RTTI', configtool: 'has-rtti')) 1779 endif 1780 if _rtti != _llvm_rtti 1781 if _llvm_rtti 1782 error('LLVM was built with RTTI, cannot build Mesa with RTTI disabled. Remove cpp_rtti disable switch or use LLVM built without LLVM_ENABLE_RTTI.') 1783 else 1784 error('LLVM was built without RTTI, so Mesa must also disable RTTI. Use an LLVM built with LLVM_ENABLE_RTTI or add cpp_rtti=false.') 1785 endif 1786 endif 1787 endif 1788 1789 if cc.get_argument_syntax() == 'msvc' 1790 # Suppress "/DELAYLOAD:ole32.dll/shell32.dll ignored" warnings that LLVM adds 1791 add_project_link_arguments( 1792 '/ignore:4199', 1793 language : ['c', 'cpp'], 1794 ) 1795 endif 1796elif with_amd_vk and with_aco_tests 1797 error('ACO tests require LLVM, but LLVM is disabled.') 1798elif with_swrast_vk 1799 error('lavapipe requires LLVM and is enabled, but LLVM is disabled.') 1800elif with_any_llvmpipe 1801 error('llvmpipe requires LLVM and is enabled, but LLVM is disabled.') 1802elif with_gallium_clover 1803 error('The OpenCL "Clover" state tracker requires LLVM, but LLVM is disabled.') 1804elif with_clc 1805 error('The CLC compiler requires LLVM, but LLVM is disabled.') 1806else 1807 draw_with_llvm = false 1808endif 1809amd_with_llvm = amd_with_llvm and with_llvm 1810pre_args += '-DLLVM_AVAILABLE=@0@'.format(with_llvm.to_int()) 1811pre_args += '-DDRAW_LLVM_AVAILABLE=@0@'.format((with_llvm and draw_with_llvm).to_int()) 1812pre_args += '-DAMD_LLVM_AVAILABLE=@0@'.format(amd_with_llvm.to_int()) 1813pre_args += '-DGALLIVM_USE_ORCJIT=@0@'.format((with_llvm and llvm_with_orcjit).to_int()) 1814 1815if with_clover_spirv or with_clc 1816 chosen_llvm_version_array = dep_llvm.version().split('.') 1817 chosen_llvm_version_major = chosen_llvm_version_array[0].to_int() 1818 chosen_llvm_version_minor = chosen_llvm_version_array[1].to_int() 1819 1820 # Require an SPIRV-LLVM-Translator version compatible with the chosen LLVM 1821 # one. 1822 1823 # This first version check is still needed as maybe LLVM 8.0 was picked but 1824 # we do not want to accept SPIRV-LLVM-Translator 8.0.0.1 as that version 1825 # does not have the required API and those are only available starting from 1826 # 8.0.1.3. 1827 _llvmspirvlib_min_version = '>= 8.0.1.3' 1828 if with_clc 1829 _llvmspirvlib_min_version = '>= 15.0.0.0' 1830 endif 1831 1832 _llvmspirvlib_version = [ 1833 _llvmspirvlib_min_version, 1834 '>= @0@.@1@'.format(chosen_llvm_version_major, chosen_llvm_version_minor), 1835 '< @0@.@1@'.format(chosen_llvm_version_major, chosen_llvm_version_minor + 1) ] 1836 1837 # LLVMSPIRVLib is available at https://github.com/KhronosGroup/SPIRV-LLVM-Translator 1838 dep_llvmspirvlib = dependency('LLVMSPIRVLib', required : true, version : _llvmspirvlib_version) 1839else 1840 dep_llvmspirvlib = null_dep 1841endif 1842 1843dep_spirv_tools = dependency( 1844 'SPIRV-Tools', 1845 required : with_clover_spirv or with_clc, 1846 version : '>= 2018.0' 1847) 1848if dep_spirv_tools.found() 1849 pre_args += '-DHAVE_SPIRV_TOOLS' 1850endif 1851 1852dep_clang = null_dep 1853if with_clc 1854 llvm_libdir = dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir') 1855 1856 dep_clang = cpp.find_library('clang-cpp', dirs : llvm_libdir, required : false) 1857 1858 if not dep_clang.found() or not _shared_llvm 1859 clang_modules = [ 1860 'clangBasic', 'clangAST', 'clangCodeGen', 'clangLex', 1861 'clangDriver', 'clangFrontend', 'clangFrontendTool', 1862 'clangHandleCXX', 'clangHandleLLVM', 'clangSerialization', 1863 'clangSema', 'clangParse', 'clangEdit', 'clangAnalysis' 1864 ] 1865 if dep_llvm.version().version_compare('>= 15.0') 1866 clang_modules += 'clangSupport' 1867 endif 1868 if dep_llvm.version().version_compare('>= 16.0') 1869 clang_modules += 'clangASTMatchers' 1870 endif 1871 if dep_llvm.version().version_compare('>= 18.0') 1872 clang_modules += 'clangAPINotes' 1873 endif 1874 1875 dep_clang = [] 1876 foreach m : clang_modules 1877 dep_clang += cpp.find_library(m, dirs : llvm_libdir, required : true) 1878 endforeach 1879 endif 1880endif 1881 1882dep_lua = dependency('lua54', 'lua5.4', 'lua-5.4', 1883 'lua53', 'lua5.3', 'lua-5.3', 1884 'lua', required: false, 1885 allow_fallback: with_tools.contains('freedreno'), 1886 version: '>=5.3') 1887 1888# Be explicit about only using this lib on Windows, to avoid picking 1889# up random libs with the generic name 'libversion' 1890dep_version = null_dep 1891if host_machine.system() == 'windows' 1892 dep_version = cpp.find_library('version') 1893endif 1894 1895dep_elf = dependency('libelf', required : false) 1896if not with_platform_windows and not dep_elf.found() 1897 dep_elf = cc.find_library('elf', required : false) 1898endif 1899if dep_elf.found() 1900 pre_args += '-DUSE_LIBELF' 1901elif with_gallium_radeonsi 1902 error('Gallium driver radeonsi requires libelf') 1903endif 1904 1905dep_valgrind = dependency('valgrind', required : get_option('valgrind')) 1906if dep_valgrind.found() 1907 pre_args += '-DHAVE_VALGRIND' 1908endif 1909 1910# AddressSanitizer's leak reports need all the symbols to be present at exit to 1911# decode well, which runs afoul of our dlopen()/dlclose()ing of the DRI drivers. 1912# Set a flag so we can skip the dlclose for asan builds. 1913if ['address', 'address,undefined'].contains(get_option('b_sanitize')) 1914 asan_c_args = ['-DBUILT_WITH_ASAN=1'] 1915else 1916 asan_c_args = ['-DBUILT_WITH_ASAN=0'] 1917endif 1918 1919# ThreadSanitizer can't deal with futexes, and reports races for cases we don't care about 1920# so add a define to work silence these issues. 1921if get_option('b_sanitize') == 'thread' 1922 pre_args += '-DTHREAD_SANITIZER=1' 1923 # meson versions prior to 1.4 will warn "Consider using the built-in option for sanitizers ..." 1924 # later on because it only checks whether the option starts with "-fsanitize", 1925 # but there is no built-in option for adding a blacklist 1926 tsan_blacklist = '-fsanitize-blacklist=@0@'.format(join_paths(meson.project_source_root(), 'build-support', 'tsan-blacklist.txt')) 1927 if cc.has_argument(tsan_blacklist) 1928 pre_args += tsan_blacklist 1929 else 1930 warning('Compiler does not support "-fsanitize-blacklist", expected race conditions will not be surpressed') 1931 endif 1932else 1933 pre_args += '-DTHREAD_SANITIZER=0' 1934endif 1935 1936yacc_is_bison = true 1937needs_flex_bison = with_any_opengl or with_freedreno_vk or with_intel_tools or with_gallium 1938 1939if build_machine.system() == 'windows' 1940 # Prefer the winflexbison versions, they're much easier to install and have 1941 # better windows support. 1942 1943 prog_flex = find_program('win_flex', required : false) 1944 if prog_flex.found() 1945 # windows compatibility (uses <io.h> instead of <unistd.h> and _isatty, 1946 # _fileno functions) 1947 prog_flex = [prog_flex, '--wincompat'] 1948 else 1949 prog_flex = [find_program('flex', 'lex', required : needs_flex_bison, disabler : true)] 1950 endif 1951 # Force flex to use const keyword in prototypes, as relies on __cplusplus or 1952 # __STDC__ macro to determine whether it's safe to use const keyword 1953 prog_flex += '-DYY_USE_CONST=' 1954 1955 prog_flex_cpp = prog_flex 1956 # Convince win_flex to use <inttypes.h> for C++ files 1957 # Note that we are using a C99 version here rather than C11, 1958 # because using a C11 version can cause the MSVC CRT headers to define 1959 # static_assert to _Static_assert, which breaks other parts of the CRT 1960 prog_flex_cpp += '-D__STDC_VERSION__=199901' 1961 1962 prog_bison = find_program('win_bison', required : false) 1963 if not prog_bison.found() 1964 prog_bison = find_program('bison', 'yacc', required : needs_flex_bison, disabler : true) 1965 endif 1966else 1967 prog_bison = find_program('bison', required : false) 1968 1969 if not prog_bison.found() 1970 prog_bison = find_program('byacc', required : needs_flex_bison, disabler : true) 1971 yacc_is_bison = false 1972 endif 1973 1974 # Disable deprecated keyword warnings, since we have to use them for 1975 # old-bison compat. See discussion in 1976 # https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2161 1977 if find_program('bison', required : false, version : '> 2.3').found() 1978 prog_bison = [prog_bison, '-Wno-deprecated'] 1979 endif 1980 1981 prog_flex = find_program('flex', required : needs_flex_bison, disabler : true) 1982 prog_flex_cpp = prog_flex 1983endif 1984 1985dep_selinux = null_dep 1986if get_option('selinux') 1987 dep_selinux = dependency('libselinux') 1988 pre_args += '-DMESA_SELINUX' 1989endif 1990 1991_libunwind = get_option('libunwind') \ 1992 .require(not with_platform_android, error_message : 'Android requires the use of the backtrace library, not libunwind') 1993if host_machine.system() == 'darwin' 1994 dep_unwind = meson.get_compiler('c').find_library('System', required : _libunwind) 1995else 1996 dep_unwind = dependency('libunwind', required : _libunwind) 1997endif 1998if dep_unwind.found() 1999 pre_args += '-DHAVE_LIBUNWIND' 2000endif 2001 2002if with_osmesa 2003 if not with_gallium_swrast 2004 error('OSMesa gallium requires gallium softpipe or llvmpipe.') 2005 endif 2006 if host_machine.system() == 'windows' 2007 osmesa_lib_name = 'osmesa' 2008 else 2009 osmesa_lib_name = 'OSMesa' 2010 endif 2011endif 2012 2013# TODO: symbol mangling 2014 2015if with_platform_wayland 2016 dep_wl_scanner = dependency('wayland-scanner', native: true) 2017 prog_wl_scanner = find_program(dep_wl_scanner.get_variable(pkgconfig : 'wayland_scanner')) 2018 if dep_wl_scanner.version().version_compare('>= 1.15') 2019 wl_scanner_arg = 'private-code' 2020 else 2021 wl_scanner_arg = 'code' 2022 endif 2023 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.34') 2024 dep_wayland_client = dependency('wayland-client', version : '>=1.18') 2025 dep_wayland_server = dependency('wayland-server', version : '>=1.18') 2026 if with_egl 2027 dep_wayland_egl = dependency('wayland-egl-backend', version : '>= 3') 2028 dep_wayland_egl_headers = dep_wayland_egl.partial_dependency(compile_args : true) 2029 endif 2030 pre_args += '-DWL_HIDE_DEPRECATED' 2031 if cc.has_function( 2032 'wl_display_dispatch_queue_timeout', 2033 prefix : '#include <wayland-client.h>', 2034 dependencies: dep_wayland_client) 2035 pre_args += ['-DHAVE_WL_DISPATCH_QUEUE_TIMEOUT'] 2036 endif 2037 if cc.has_function( 2038 'wl_display_create_queue_with_name', 2039 prefix : '#include <wayland-client.h>', 2040 dependencies: dep_wayland_client) 2041 pre_args += ['-DHAVE_WL_CREATE_QUEUE_WITH_NAME'] 2042 endif 2043endif 2044 2045dep_x11 = null_dep 2046dep_xext = null_dep 2047dep_xfixes = null_dep 2048dep_x11_xcb = null_dep 2049dep_xcb = null_dep 2050dep_xcb_keysyms = null_dep 2051dep_xcb_glx = null_dep 2052dep_xcb_dri2 = null_dep 2053dep_xcb_dri3 = null_dep 2054dep_dri2proto = null_dep 2055dep_glproto = null_dep 2056dep_xxf86vm = null_dep 2057dep_xcb_dri3 = null_dep 2058dep_xcb_present = null_dep 2059dep_xcb_sync = null_dep 2060dep_xcb_xfixes = null_dep 2061dep_xshmfence = null_dep 2062dep_xcb_xrandr = null_dep 2063dep_xcb_shm = null_dep 2064dep_xlib_xrandr = null_dep 2065dep_openmp = null_dep 2066 2067# Even if we find OpenMP, Gitlab CI fails to link with gcc/i386 and clang/anyarch. 2068if host_machine.cpu_family() == 'x86_64' and cc.get_id() == 'gcc' 2069 dep_openmp = dependency('openmp', required : false) 2070 if dep_openmp.found() 2071 pre_args += ['-DHAVE_OPENMP'] 2072 endif 2073endif 2074 2075with_dri3_explicit_sync = false 2076with_xcb_keysyms = false 2077if with_platform_x11 2078 dep_xcb = dependency('xcb') 2079 dep_xcb_xrandr = dependency('xcb-randr') 2080 if with_glx == 'xlib' 2081 dep_x11 = dependency('x11') 2082 dep_xext = dependency('xext') 2083 elif with_glx == 'dri' 2084 dep_x11 = dependency('x11') 2085 dep_xext = dependency('xext') 2086 dep_xfixes = dependency('xfixes', version : '>= 2.0') 2087 dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1') 2088 dep_xcb_shm = dependency('xcb-shm') 2089 elif with_gallium_rusticl 2090 # needed for GL sharing extension 2091 dep_x11 = dependency('x11') 2092 endif 2093 if (with_any_vk or with_glx == 'dri' or with_egl or 2094 (with_gallium_vdpau or with_gallium_va)) 2095 dep_xcb = dependency('xcb') 2096 dep_xcb_keysyms = dependency('xcb-keysyms', required : false) 2097 with_xcb_keysyms = dep_xcb_keysyms.found() 2098 if with_xcb_keysyms 2099 pre_args += '-DXCB_KEYSYMS_AVAILABLE' 2100 endif 2101 dep_x11_xcb = dependency('x11-xcb') 2102 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8', required : with_x11_dri2) 2103 if with_dri_platform == 'drm' and not dep_libdrm.found() 2104 error('libdrm required for gallium video statetrackers when using x11') 2105 endif 2106 endif 2107 if with_dri_platform == 'drm' 2108 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8', required : with_x11_dri2) 2109 2110 dep_xcb_dri3 = dependency('xcb-dri3', version : '>= 1.13') 2111 dep_xcb_present = dependency('xcb-present', version : '>= 1.13') 2112 if (dep_xcb_dri3.version().version_compare('>= 1.17') and 2113 dep_xcb_present.version().version_compare('>= 1.17')) 2114 with_dri3_explicit_sync = true 2115 endif 2116 dep_xcb_shm = dependency('xcb-shm') 2117 dep_xcb_sync = dependency('xcb-sync') 2118 dep_xshmfence = dependency('xshmfence', version : '>= 1.1') 2119 pre_args += '-DHAVE_X11_DRM' 2120 endif 2121 if with_glx == 'dri' or with_glx == 'xlib' 2122 dep_glproto = dependency('glproto', version : '>= 1.4.14') 2123 endif 2124 if with_glx == 'dri' 2125 if with_dri_platform == 'drm' 2126 dep_dri2proto = dependency('dri2proto', version : '>= 2.8') 2127 if with_glx_direct 2128 dep_xxf86vm = dependency('xxf86vm') 2129 endif 2130 endif 2131 endif 2132 if (with_egl or 2133 with_dri or 2134 with_any_vk or 2135 with_gallium_vdpau or with_gallium_xa) 2136 dep_xcb_xfixes = dependency('xcb-xfixes') 2137 endif 2138 if with_xlib_lease or with_any_vk 2139 dep_xcb_xrandr = dependency('xcb-randr') 2140 endif 2141 if with_xlib_lease 2142 dep_xlib_xrandr = dependency('xrandr', version : '>= 1.3') 2143 endif 2144endif 2145 2146if with_dri 2147 pre_args += '-DHAVE_DRI' 2148endif 2149if with_dri2 2150 pre_args += '-DHAVE_DRI2' 2151endif 2152if with_x11_dri2 2153 pre_args += '-DHAVE_X11_DRI2' 2154endif 2155if with_dri3_explicit_sync 2156 pre_args += '-DHAVE_DRI3_EXPLICIT_SYNC' 2157endif 2158if with_gallium_drisw_kms 2159 pre_args += '-DHAVE_DRISW_KMS' 2160endif 2161 2162if get_option('gallium-extra-hud') 2163 pre_args += '-DHAVE_GALLIUM_EXTRA_HUD=1' 2164endif 2165 2166dep_lmsensors = cc.find_library('sensors', required : get_option('lmsensors')) 2167if dep_lmsensors.found() 2168 pre_args += '-DHAVE_LIBSENSORS=1' 2169endif 2170 2171_shader_replacement = get_option('custom-shader-replacement') 2172if _shader_replacement == '' 2173else 2174 pre_args += '-DCUSTOM_SHADER_REPLACEMENT' 2175endif 2176 2177with_perfetto = get_option('perfetto') 2178with_datasources = get_option('datasources') 2179with_any_datasource = with_datasources.length() != 0 2180if with_perfetto 2181 dep_perfetto = dependency('perfetto', fallback: ['perfetto', 'dep_perfetto']) 2182 pre_args += '-DHAVE_PERFETTO' 2183endif 2184 2185with_teflon = get_option('teflon') 2186if with_teflon and with_tests 2187 dep_xtensor = dependency('xtensor') 2188 dep_flatbuffers = dependency('flatbuffers') 2189 prog_flatc = find_program('flatc') 2190endif 2191 2192with_gpuvis = get_option('gpuvis') 2193if with_gpuvis 2194 pre_args += '-DHAVE_GPUVIS' 2195endif 2196 2197add_project_arguments(pre_args, language : ['c', 'cpp']) 2198add_project_arguments(c_cpp_args, language : ['c', 'cpp']) 2199 2200add_project_arguments(c_args, language : ['c']) 2201add_project_arguments(cpp_args, language : ['cpp']) 2202 2203gl_priv_reqs = [] 2204 2205if with_glx == 'xlib' 2206 gl_priv_reqs += ['x11', 'xext', 'xcb'] 2207elif with_glx == 'dri' 2208 gl_priv_reqs += [ 2209 'x11', 'xext', 'xfixes', 'x11-xcb', 'xcb', 2210 'xcb-glx >= 1.8.1'] 2211 if with_dri_platform == 'drm' 2212 gl_priv_reqs += 'xcb-dri2 >= 1.8' 2213 if with_glx_direct 2214 gl_priv_reqs += 'xxf86vm' 2215 endif 2216 endif 2217endif 2218if dep_libdrm.found() 2219 gl_priv_reqs += 'libdrm >= 2.4.75' 2220endif 2221 2222gl_priv_libs = [] 2223if dep_thread.found() 2224 gl_priv_libs += ['-lpthread', '-pthread'] 2225endif 2226if dep_m.found() 2227 gl_priv_libs += '-lm' 2228endif 2229if dep_dl.found() 2230 gl_priv_libs += '-ldl' 2231endif 2232 2233# FIXME: autotools lists this as incomplete 2234gbm_priv_libs = [] 2235if dep_dl.found() 2236 gbm_priv_libs += '-ldl' 2237endif 2238 2239pkg = import('pkgconfig') 2240 2241if host_machine.system() == 'windows' 2242 prog_dumpbin = find_program('dumpbin', required : false) 2243 with_symbols_check = prog_dumpbin.found() and with_tests 2244 if with_symbols_check 2245 symbols_check_args = ['--dumpbin', prog_dumpbin.full_path()] 2246 endif 2247else 2248 prog_nm = find_program('nm') 2249 with_symbols_check = with_tests 2250 symbols_check_args = ['--nm', prog_nm.full_path()] 2251endif 2252 2253# This quirk needs to be applied to sources with functions defined in assembly 2254# as GCC LTO drops them. See: https://bugs.freedesktop.org/show_bug.cgi?id=109391 2255gcc_lto_quirk = (cc.get_id() == 'gcc') ? ['-fno-lto'] : [] 2256 2257devenv = environment() 2258 2259dir_compiler_nir = join_paths(meson.current_source_dir(), 'src/compiler/nir/') 2260dir_source_root = meson.project_source_root() 2261 2262 2263subdir('include') 2264subdir('bin') 2265subdir('src') 2266 2267meson.add_devenv(devenv) 2268 2269sphinx = find_program('sphinx-build', version : '>= 4.3', 2270 required: get_option('html-docs')) 2271if sphinx.found() 2272 subdir('docs') 2273endif 2274 2275summary( 2276 { 2277 'prefix': get_option('prefix'), 2278 'libdir': get_option('libdir'), 2279 'includedir': get_option('includedir'), 2280 }, 2281 section: 'Directories' 2282) 2283 2284summary( 2285 { 2286 'c_cpp_args': c_cpp_args, 2287 }, 2288 section: 'Common C and C++ arguments' 2289) 2290 2291summary( 2292 { 2293 'OpenGL': with_opengl, 2294 'ES1': with_gles1, 2295 'ES2': with_gles2, 2296 'Shared glapi': with_shared_glapi, 2297 'GLVND': with_glvnd, 2298 }, 2299 section: 'OpenGL', bool_yn: true 2300) 2301 2302summary( 2303 { 2304 'Platform': with_dri_platform, 2305 'Driver dir': dri_drivers_path, 2306 }, 2307 section: 'DRI', bool_yn: true, list_sep: ' ' 2308) 2309 2310summary( 2311 { 2312 'Enabled': with_glx != 'disabled', 2313 'Provider': with_glx == 'disabled' ? 'None' : with_glx 2314 }, 2315 section: 'GLX', bool_yn: true, list_sep: ' ' 2316) 2317 2318egl_summary = {'Enabled': with_egl} 2319if with_egl 2320 egl_drivers = [] 2321 if with_dri 2322 egl_drivers += 'builtin:egl_dri2' 2323 endif 2324 if with_dri_platform == 'drm' 2325 egl_drivers += 'builtin:egl_dri3' 2326 endif 2327 if with_platform_windows 2328 egl_drivers += 'builtin:wgl' 2329 endif 2330 egl_summary += {'Drivers': egl_drivers} 2331 egl_summary += {'Platforms': _platforms} 2332endif 2333summary(egl_summary, section: 'EGL', bool_yn: true, list_sep: ' ') 2334 2335gbm_summary = {'Enabled': with_gbm} 2336if with_gbm 2337 gbm_summary += {'Backends path': gbm_backends_path} 2338endif 2339summary(gbm_summary, section: 'GBM', bool_yn: true, list_sep: ' ') 2340 2341vulkan_summary = {'Drivers': _vulkan_drivers.length() != 0 ? _vulkan_drivers : false } 2342if with_any_vk 2343 vulkan_summary += {'Platforms': _platforms} 2344 vulkan_summary += {'ICD dir': with_vulkan_icd_dir} 2345 if with_any_vulkan_layers 2346 vulkan_summary += {'Layers': get_option('vulkan-layers')} 2347 endif 2348 vulkan_summary += {'Intel Ray tracing': with_intel_vk_rt} 2349endif 2350summary(vulkan_summary, section: 'Vulkan', bool_yn: true, list_sep: ' ') 2351 2352video_summary = {'Codecs': _codecs.length() != 0 ? _codecs : false} 2353video_apis = [] 2354if with_gallium_vdpau 2355 video_apis += 'vdpau' 2356endif 2357if with_gallium_va 2358 video_apis += 'va' 2359endif 2360if with_any_vk 2361 video_apis += 'vulkan' 2362endif 2363if with_gallium_xa 2364 video_apis += 'xa' 2365endif 2366video_summary += {'APIs': video_apis.length() != 0 ? video_apis : false} 2367summary(video_summary, section: 'Video', bool_yn: true, list_sep: ' ') 2368 2369llvm_summary = {'Enabled': with_llvm} 2370if with_llvm 2371 llvm_summary += {'Version': dep_llvm.version()} 2372endif 2373summary(llvm_summary, section: 'LLVM', bool_yn: true, list_sep: ' ') 2374 2375gallium_summary = {'Enabled': with_gallium} 2376if with_gallium 2377 gallium_summary += {'Drivers': gallium_drivers} 2378 gallium_summary += {'Platforms': _platforms} 2379 2380 gallium_frontends = ['mesa'] 2381 if with_gallium_xa 2382 gallium_frontends += 'xa' 2383 endif 2384 if with_gallium_vdpau 2385 gallium_frontends += 'vdpau' 2386 endif 2387 if with_gallium_va 2388 gallium_frontends += 'va' 2389 endif 2390 if with_gallium_st_nine 2391 gallium_frontends += 'nine' 2392 endif 2393 if with_gallium_clover 2394 gallium_frontends += 'clover' 2395 endif 2396 if with_gallium_rusticl 2397 gallium_frontends += 'rusticl' 2398 endif 2399 gallium_summary += {'Frontends': gallium_frontends} 2400 gallium_summary += {'Off-screen rendering (OSMesa)': with_osmesa ? 'lib' + osmesa_lib_name : false} 2401 gallium_summary += {'HUD lm-sensors': dep_lmsensors.found()} 2402endif 2403summary(gallium_summary, section: 'Gallium', bool_yn: true, list_sep: ' ') 2404 2405perfetto_summary = {'Enabled': with_perfetto} 2406if with_perfetto and with_any_datasource 2407 perfetto_summary += {'Data source': with_datasources} 2408endif 2409summary(perfetto_summary, section: 'Perfetto', bool_yn: true, list_sep: ' ') 2410 2411teflon_summary = {'Enabled': with_teflon} 2412summary(teflon_summary, section: 'Teflon (TensorFlow Lite delegate)', bool_yn: true, list_sep: ' ') 2413