Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/meson.build
4538 views
1
# Copyright © 2017-2020 Intel Corporation
2
3
# Permission is hereby granted, free of charge, to any person obtaining a copy
4
# of this software and associated documentation files (the "Software"), to deal
5
# in the Software without restriction, including without limitation the rights
6
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
# copies of the Software, and to permit persons to whom the Software is
8
# furnished to do so, subject to the following conditions:
9
10
# The above copyright notice and this permission notice shall be included in
11
# all copies or substantial portions of the Software.
12
13
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
# SOFTWARE.
20
21
project(
22
'mesa',
23
['c', 'cpp'],
24
version : run_command(
25
[find_program('python', 'python3'), 'bin/meson_get_version.py']
26
).stdout(),
27
license : 'MIT',
28
meson_version : '>= 0.52',
29
default_options : ['buildtype=debugoptimized', 'b_ndebug=if-release', 'c_std=c11', 'cpp_std=c++14']
30
)
31
32
cc = meson.get_compiler('c')
33
cpp = meson.get_compiler('cpp')
34
35
null_dep = dependency('', required : false)
36
37
if get_option('layout') != 'mirror'
38
error('`mirror` is the only build directory layout supported')
39
endif
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++.
44
pre_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
c_args = []
52
cpp_args = []
53
54
with_moltenvk_dir = get_option('moltenvk-dir')
55
with_vulkan_icd_dir = get_option('vulkan-icd-dir')
56
with_tests = get_option('build-tests')
57
with_aco_tests = get_option('build-aco-tests')
58
with_glx_read_only_text = get_option('glx-read-only-text')
59
with_glx_direct = get_option('glx-direct')
60
with_osmesa = get_option('osmesa')
61
with_swr_arches = get_option('swr-arches')
62
with_vulkan_overlay_layer = get_option('vulkan-layers').contains('overlay')
63
with_vulkan_device_select_layer = get_option('vulkan-layers').contains('device-select')
64
with_tools = get_option('tools')
65
if with_tools.contains('all')
66
with_tools = [
67
'drm-shim',
68
'etnaviv',
69
'freedreno',
70
'glsl',
71
'intel',
72
'intel-ui',
73
'lima',
74
'nir',
75
'nouveau',
76
'xvmc',
77
'asahi',
78
]
79
endif
80
with_clc = false
81
82
with_any_vulkan_layers = get_option('vulkan-layers').length() != 0
83
with_intel_tools = with_tools.contains('intel') or with_tools.contains('intel-ui')
84
with_imgui = with_intel_tools or with_vulkan_overlay_layer
85
86
dri_drivers_path = get_option('dri-drivers-path')
87
if dri_drivers_path == ''
88
dri_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'dri')
89
endif
90
dri_search_path = get_option('dri-search-path')
91
if dri_search_path == ''
92
dri_search_path = dri_drivers_path
93
endif
94
95
gbm_backends_path = get_option('gbm-backends-path')
96
if gbm_backends_path == ''
97
gbm_backends_path = join_paths(get_option('prefix'), get_option('libdir'), 'gbm')
98
endif
99
100
with_gles1 = get_option('gles1')
101
if with_gles1 == 'true'
102
with_gles1 = 'enabled'
103
warning('gles1 option "true" deprecated, please use "enabled" instead.')
104
elif with_gles1 == 'false'
105
with_gles1 = 'disabled'
106
warning('gles1 option "false" deprecated, please use "disabled" instead.')
107
endif
108
with_gles2 = get_option('gles2')
109
if with_gles2 == 'true'
110
with_gles2 = 'enabled'
111
warning('gles2 option "true" deprecated, please use "enabled" instead.')
112
elif with_gles2 == 'false'
113
with_gles2 = 'disabled'
114
warning('gles2 option "false" deprecated, please use "disabled" instead.')
115
endif
116
if host_machine.system() == 'windows'
117
if with_gles1 == 'auto'
118
with_gles1 = 'disabled'
119
endif
120
if with_gles2 == 'auto'
121
with_gles2 = 'disabled'
122
endif
123
endif
124
with_opengl = get_option('opengl')
125
126
# Default shared glapi off for windows, on elsewhere.
127
_sg = get_option('shared-glapi')
128
if _sg == 'true'
129
_sg = 'enabled'
130
warning('shared-glapi option "true" deprecated, please use "enabled" instead.')
131
elif _sg == 'false'
132
_sg = 'disabled'
133
warning('shared-glapi option "false" deprecated, please use "disabled" instead.')
134
endif
135
if _sg == 'auto'
136
with_shared_glapi = host_machine.system() != 'windows'
137
else
138
with_shared_glapi = _sg == 'enabled'
139
endif
140
141
# shared-glapi is required if at least two OpenGL APIs are being built
142
if not with_shared_glapi
143
if ((with_gles1 == 'enabled' and with_gles2 == 'enabled') or
144
(with_gles1 == 'enabled' and with_opengl) or
145
(with_gles2 == 'enabled' and with_opengl))
146
error('shared-glapi required for building two or more of OpenGL, OpenGL ES 1.x, OpenGL ES 2.x')
147
endif
148
with_gles1 = 'disabled'
149
with_gles2 = 'disabled'
150
endif
151
152
# We require OpenGL for OpenGL ES
153
if not with_opengl
154
if (with_gles1 == 'enabled' or with_gles2 == 'enabled') and not with_opengl
155
error('building OpenGL ES without OpenGL is not supported.')
156
endif
157
with_gles1 = 'disabled'
158
with_gles2 = 'disabled'
159
endif
160
161
with_gles1 = with_gles1 != 'disabled'
162
with_gles2 = with_gles2 != 'disabled'
163
with_any_opengl = with_opengl or with_gles1 or with_gles2
164
# Only build shared_glapi if at least one OpenGL API is enabled
165
with_shared_glapi = with_shared_glapi and with_any_opengl
166
167
system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux', 'sunos'].contains(host_machine.system())
168
169
dri_drivers = get_option('dri-drivers')
170
if dri_drivers.contains('auto')
171
if system_has_kms_drm
172
# TODO: PPC, Sparc
173
if ['x86', 'x86_64'].contains(host_machine.cpu_family())
174
dri_drivers = ['i915', 'i965', 'r100', 'r200', 'nouveau']
175
elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
176
dri_drivers = []
177
elif ['mips', 'mips64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family())
178
dri_drivers = ['r100', 'r200', 'nouveau']
179
else
180
error('Unknown architecture @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format(
181
host_machine.cpu_family()))
182
endif
183
elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
184
# only swrast would make sense here, but gallium swrast is a much better default
185
dri_drivers = []
186
else
187
error('Unknown OS @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format(
188
host_machine.system()))
189
endif
190
endif
191
192
with_dri_i915 = dri_drivers.contains('i915')
193
with_dri_i965 = dri_drivers.contains('i965')
194
with_dri_r100 = dri_drivers.contains('r100')
195
with_dri_r200 = dri_drivers.contains('r200')
196
with_dri_nouveau = dri_drivers.contains('nouveau')
197
198
with_dri = dri_drivers.length() != 0
199
200
gallium_drivers = get_option('gallium-drivers')
201
if gallium_drivers.contains('auto')
202
if system_has_kms_drm
203
# TODO: PPC, Sparc
204
if ['x86', 'x86_64'].contains(host_machine.cpu_family())
205
gallium_drivers = [
206
'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'svga', 'swrast',
207
'iris'
208
]
209
elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
210
gallium_drivers = [
211
'v3d', 'vc4', 'freedreno', 'etnaviv', 'nouveau',
212
'tegra', 'virgl', 'lima', 'panfrost', 'swrast'
213
]
214
elif ['mips', 'mips64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family())
215
gallium_drivers = [
216
'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'swrast'
217
]
218
else
219
error('Unknown architecture @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format(
220
host_machine.cpu_family()))
221
endif
222
elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
223
gallium_drivers = ['swrast']
224
else
225
error('Unknown OS @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format(
226
host_machine.system()))
227
endif
228
endif
229
with_gallium_radeonsi = gallium_drivers.contains('radeonsi')
230
with_gallium_r300 = gallium_drivers.contains('r300')
231
with_gallium_r600 = gallium_drivers.contains('r600')
232
with_gallium_nouveau = gallium_drivers.contains('nouveau')
233
with_gallium_freedreno = gallium_drivers.contains('freedreno')
234
with_gallium_softpipe = gallium_drivers.contains('swrast')
235
with_gallium_vc4 = gallium_drivers.contains('vc4')
236
with_gallium_v3d = gallium_drivers.contains('v3d')
237
with_gallium_panfrost = gallium_drivers.contains('panfrost')
238
with_gallium_etnaviv = gallium_drivers.contains('etnaviv')
239
with_gallium_tegra = gallium_drivers.contains('tegra')
240
with_gallium_crocus = gallium_drivers.contains('crocus')
241
with_gallium_iris = gallium_drivers.contains('iris')
242
with_gallium_i915 = gallium_drivers.contains('i915')
243
with_gallium_svga = gallium_drivers.contains('svga')
244
with_gallium_virgl = gallium_drivers.contains('virgl')
245
with_gallium_swr = gallium_drivers.contains('swr')
246
with_gallium_lima = gallium_drivers.contains('lima')
247
with_gallium_zink = gallium_drivers.contains('zink')
248
with_gallium_d3d12 = gallium_drivers.contains('d3d12')
249
with_gallium_asahi = gallium_drivers.contains('asahi')
250
251
with_gallium = gallium_drivers.length() != 0
252
with_gallium_kmsro = with_gallium_v3d or with_gallium_vc4 or with_gallium_etnaviv or with_gallium_panfrost or with_gallium_lima or with_gallium_freedreno
253
254
if with_gallium and system_has_kms_drm
255
_glx = get_option('glx')
256
_egl = get_option('egl')
257
if _glx == 'dri' or _egl == 'enabled' or (_glx == 'disabled' and _egl != 'disabled')
258
with_dri = true
259
endif
260
endif
261
262
_vulkan_drivers = get_option('vulkan-drivers')
263
if _vulkan_drivers.contains('auto')
264
if system_has_kms_drm
265
if host_machine.cpu_family().startswith('x86')
266
_vulkan_drivers = ['amd', 'intel', 'swrast']
267
elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
268
_vulkan_drivers = ['swrast']
269
elif ['mips', 'mips64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family())
270
_vulkan_drivers = ['amd', 'swrast']
271
else
272
error('Unknown architecture @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format(
273
host_machine.cpu_family()))
274
endif
275
elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
276
# No vulkan driver supports windows or macOS currently
277
_vulkan_drivers = []
278
else
279
error('Unknown OS @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format(
280
host_machine.system()))
281
endif
282
endif
283
284
with_intel_vk = _vulkan_drivers.contains('intel')
285
with_amd_vk = _vulkan_drivers.contains('amd')
286
with_freedreno_vk = _vulkan_drivers.contains('freedreno')
287
with_panfrost_vk = _vulkan_drivers.contains('panfrost')
288
with_swrast_vk = _vulkan_drivers.contains('swrast')
289
with_virtio_vk = _vulkan_drivers.contains('virtio-experimental')
290
with_freedreno_kgsl = get_option('freedreno-kgsl')
291
with_broadcom_vk = _vulkan_drivers.contains('broadcom')
292
with_any_vk = _vulkan_drivers.length() != 0
293
294
with_any_broadcom = with_gallium_vc4 or with_gallium_v3d or with_broadcom_vk
295
with_any_intel = with_dri_i965 or with_intel_vk or with_gallium_iris or with_gallium_crocus
296
297
if with_swrast_vk and not with_gallium_softpipe
298
error('swrast vulkan requires gallium swrast')
299
endif
300
if with_dri_i915 and with_gallium_i915
301
error('Only one i915 provider can be built')
302
endif
303
if with_gallium_tegra and not with_gallium_nouveau
304
error('tegra driver requires nouveau driver')
305
endif
306
if with_aco_tests and not with_amd_vk
307
error('ACO tests require Radv')
308
endif
309
310
dep_clang = dependency(
311
'clang',
312
method : 'cmake',
313
static : true,
314
modules : [
315
'clangBasic', 'clangCodeGen', 'clangDriver', 'clangFrontend', 'clangFrontendTool',
316
'clangHandleCXX', 'clangHandleLLVM',
317
],
318
required : get_option('microsoft-clc'),
319
)
320
with_microsoft_clc = dep_clang.found()
321
with_clc = dep_clang.found()
322
323
with_spirv_to_dxil = get_option('spirv-to-dxil')
324
325
if host_machine.system() == 'darwin'
326
# with_dri_platform = 'apple'
327
with_dri_platform = 'none'
328
pre_args += '-DBUILDING_MESA'
329
elif ['windows', 'cygwin'].contains(host_machine.system())
330
with_dri_platform = 'windows'
331
elif system_has_kms_drm
332
with_dri_platform = 'drm'
333
else
334
# FIXME: haiku doesn't use dri, and xlib doesn't use dri, probably should
335
# assert here that one of those cases has been met.
336
# FIXME: illumos ends up here as well
337
with_dri_platform = 'none'
338
endif
339
340
_platforms = get_option('platforms')
341
if _platforms.contains('auto')
342
if system_has_kms_drm
343
_platforms = ['x11', 'wayland']
344
elif ['darwin', 'cygwin'].contains(host_machine.system())
345
_platforms = ['x11']
346
elif ['haiku'].contains(host_machine.system())
347
_platforms = ['haiku']
348
elif host_machine.system() == 'windows'
349
_platforms = ['windows']
350
else
351
error('Unknown OS @0@. Please pass -Dplatforms to set platforms. Patches gladly accepted to fix this.'.format(
352
host_machine.system()))
353
endif
354
endif
355
356
with_platform_android = _platforms.contains('android')
357
with_platform_x11 = _platforms.contains('x11')
358
with_platform_wayland = _platforms.contains('wayland')
359
with_platform_haiku = _platforms.contains('haiku')
360
with_platform_windows = _platforms.contains('windows')
361
362
with_glx = get_option('glx')
363
if with_glx == 'auto'
364
if with_platform_android
365
with_glx = 'disabled'
366
elif with_dri
367
with_glx = 'dri'
368
elif with_platform_haiku
369
with_glx = 'disabled'
370
elif host_machine.system() == 'windows'
371
with_glx = 'disabled'
372
elif with_gallium
373
# Even when building just gallium drivers the user probably wants dri
374
with_glx = 'dri'
375
elif with_platform_x11 and with_any_opengl and not with_any_vk
376
# The automatic behavior should not be to turn on xlib based glx when
377
# building only vulkan drivers
378
with_glx = 'xlib'
379
else
380
with_glx = 'disabled'
381
endif
382
endif
383
if with_glx == 'dri'
384
if with_gallium
385
with_dri = true
386
endif
387
endif
388
389
if not (with_dri or with_gallium or with_glx != 'disabled')
390
with_gles1 = false
391
with_gles2 = false
392
with_opengl = false
393
with_any_opengl = false
394
with_shared_glapi = false
395
endif
396
397
_gbm = get_option('gbm')
398
if _gbm == 'true'
399
_gbm = 'enabled'
400
warning('gbm option "true" deprecated, please use "enabled" instead.')
401
elif _gbm == 'false'
402
_gbm = 'disabled'
403
warning('gbm option "false" deprecated, please use "disabled" instead.')
404
endif
405
if _gbm == 'auto'
406
with_gbm = system_has_kms_drm and with_dri
407
else
408
with_gbm = _gbm == 'enabled'
409
endif
410
if with_gbm and not system_has_kms_drm
411
error('GBM only supports DRM/KMS platforms')
412
endif
413
414
_xlib_lease = get_option('xlib-lease')
415
if _xlib_lease == 'true'
416
_xlib_lease = 'enabled'
417
warning('xlib_lease option "true" deprecated, please use "enabled" instead.')
418
elif _xlib_lease == 'false'
419
_xlib_lease = 'disabled'
420
warning('xlib_lease option "false" deprecated, please use "disabled" instead.')
421
endif
422
if _xlib_lease == 'auto'
423
with_xlib_lease = with_platform_x11 and system_has_kms_drm
424
else
425
with_xlib_lease = _xlib_lease == 'enabled'
426
endif
427
428
_egl = get_option('egl')
429
if _egl == 'true'
430
_egl = 'enabled'
431
warning('egl option "true" deprecated, please use "enabled" instead.')
432
elif _egl == 'false'
433
_egl = 'disabled'
434
warning('egl option "false" deprecated, please use "disabled" instead.')
435
endif
436
if _egl == 'auto'
437
with_egl = (
438
not ['darwin', 'windows'].contains(host_machine.system()) and
439
with_dri and with_shared_glapi
440
)
441
elif _egl == 'enabled'
442
if not with_dri and not with_platform_haiku
443
error('EGL requires dri')
444
elif not with_shared_glapi
445
error('EGL requires shared-glapi')
446
elif not ['disabled', 'dri'].contains(with_glx)
447
error('EGL requires dri, but a GLX is being built without dri')
448
elif ['darwin', 'windows'].contains(host_machine.system())
449
error('EGL is not available on Windows or MacOS')
450
endif
451
with_egl = true
452
else
453
with_egl = false
454
endif
455
456
if with_egl
457
_platforms += 'surfaceless'
458
if with_gbm and not with_platform_android
459
_platforms += 'drm'
460
endif
461
endif
462
463
egl_native_platform = get_option('egl-native-platform')
464
if egl_native_platform.contains('auto')
465
if _platforms.length() != 0
466
egl_native_platform = _platforms[0]
467
else
468
egl_native_platform = 'surfaceless'
469
endif
470
endif
471
472
if with_egl and not _platforms.contains(egl_native_platform)
473
error('-Degl-native-platform does not specify an enabled platform')
474
endif
475
476
# Android uses emutls for versions <= P/28. For USE_ELF_TLS we need ELF TLS.
477
use_elf_tls = false
478
if (not ['freebsd', 'openbsd', 'haiku'].contains(host_machine.system()) and
479
(not with_platform_android or get_option('platform-sdk-version') >= 29) and
480
(not with_platform_windows or not with_shared_glapi))
481
pre_args += '-DUSE_ELF_TLS'
482
use_elf_tls = true
483
484
if with_platform_android
485
# By default the NDK compiler, at least, emits emutls references instead of
486
# ELF TLS, even when building targeting newer API levels. Make it actually do
487
# ELF TLS instead.
488
c_args += '-fno-emulated-tls'
489
cpp_args += '-fno-emulated-tls'
490
endif
491
endif
492
493
if with_glx != 'disabled' and host_machine.system() != 'darwin'
494
if not (with_platform_x11 and with_any_opengl)
495
warning('Cannot build GLX support without X11 platform support and at least one OpenGL API')
496
elif with_glx == 'gallium-xlib'
497
if not with_gallium
498
error('Gallium-xlib based GLX requires at least one gallium driver')
499
elif not with_gallium_softpipe
500
error('Gallium-xlib based GLX requires softpipe or llvmpipe.')
501
elif with_dri
502
error('gallium-xlib conflicts with any dri driver')
503
endif
504
elif with_glx == 'xlib'
505
if with_dri
506
error('xlib conflicts with any dri driver')
507
endif
508
elif with_glx == 'dri'
509
if not with_shared_glapi
510
error('dri based GLX requires shared-glapi')
511
endif
512
endif
513
endif
514
515
with_glvnd = get_option('glvnd')
516
glvnd_vendor_name = get_option('glvnd-vendor-name')
517
if with_glvnd
518
if with_platform_windows
519
error('glvnd cannot be used on Windows')
520
elif with_glx == 'xlib' or with_glx == 'gallium-xlib'
521
error('Cannot build glvnd support for GLX that is not DRI based.')
522
elif with_glx == 'disabled' and not with_egl
523
error('glvnd requires DRI based GLX and/or EGL')
524
endif
525
if get_option('egl-lib-suffix') != ''
526
error('''EGL lib suffix can't be used with libglvnd''')
527
endif
528
endif
529
530
if with_vulkan_icd_dir == ''
531
with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
532
endif
533
534
# GNU/Hurd includes egl_dri2, without drm.
535
with_dri2 = (with_dri or with_any_vk) and (with_dri_platform == 'drm' or
536
host_machine.system() == 'gnu')
537
_dri3 = get_option('dri3')
538
if _dri3 == 'true'
539
_dri3 = 'enabled'
540
warning('dri3 option "true" deprecated, please use "enabled" instead.')
541
elif _dri3 == 'false'
542
_dri3 = 'disabled'
543
warning('dri3 option "false" deprecated, please use "disabled" instead.')
544
endif
545
if _dri3 == 'auto'
546
with_dri3 = system_has_kms_drm and with_dri2
547
else
548
with_dri3 = _dri3 == 'enabled'
549
endif
550
551
if with_any_vk and (with_platform_x11 and not with_dri3)
552
error('Vulkan drivers require dri3 for X11 support')
553
endif
554
if with_dri
555
if with_glx == 'disabled' and not with_egl and not with_gbm
556
error('building dri drivers require at least one windowing system')
557
endif
558
endif
559
560
if with_gallium_kmsro and (with_platform_x11 and not with_dri3)
561
error('kmsro requires dri3 for X11 support')
562
endif
563
564
_vdpau = get_option('gallium-vdpau')
565
if _vdpau == 'true'
566
_vdpau = 'enabled'
567
warning('gallium-vdpau option "true" deprecated, please use "enabled" instead.')
568
elif _vdpau == 'false'
569
_vdpau = 'disabled'
570
warning('gallium-vdpau option "false" deprecated, please use "disabled" instead.')
571
endif
572
if not system_has_kms_drm
573
if _vdpau == 'enabled'
574
error('VDPAU state tracker can only be build on unix-like OSes.')
575
else
576
_vdpau = 'disabled'
577
endif
578
elif not with_platform_x11
579
if _vdpau == 'enabled'
580
error('VDPAU state tracker requires X11 support.')
581
else
582
_vdpau = 'disabled'
583
endif
584
elif not (with_gallium_r300 or with_gallium_r600 or with_gallium_radeonsi or
585
with_gallium_nouveau)
586
if _vdpau == 'enabled'
587
error('VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau.')
588
else
589
_vdpau = 'disabled'
590
endif
591
endif
592
dep_vdpau = null_dep
593
with_gallium_vdpau = false
594
if _vdpau != 'disabled'
595
dep_vdpau = dependency('vdpau', version : '>= 1.1', required : _vdpau == 'enabled')
596
if dep_vdpau.found()
597
dep_vdpau = dep_vdpau.partial_dependency(compile_args : true)
598
with_gallium_vdpau = true
599
endif
600
endif
601
602
if with_gallium_vdpau
603
pre_args += '-DHAVE_ST_VDPAU'
604
endif
605
vdpau_drivers_path = get_option('vdpau-libs-path')
606
if vdpau_drivers_path == ''
607
vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau')
608
endif
609
610
if with_gallium_zink
611
dep_vulkan = dependency('vulkan')
612
endif
613
614
dep_dxheaders = null_dep
615
if with_gallium_d3d12 or with_microsoft_clc
616
dep_dxheaders = dependency('DirectX-Headers', fallback : ['DirectX-Headers', 'dep_dxheaders'],
617
required : with_gallium_d3d12
618
)
619
endif
620
621
if with_vulkan_overlay_layer or with_aco_tests
622
prog_glslang = find_program('glslangValidator')
623
endif
624
625
_xvmc = get_option('gallium-xvmc')
626
if _xvmc == 'true'
627
_xvmc = 'enabled'
628
warning('gallium-xvmc option "true" deprecated, please use "enabled" instead.')
629
elif _xvmc == 'false'
630
_xvmc = 'disabled'
631
warning('gallium-xvmc option "false" deprecated, please use "disabled" instead.')
632
endif
633
if not system_has_kms_drm
634
if _xvmc == 'enabled'
635
error('XVMC state tracker can only be build on unix-like OSes.')
636
else
637
_xvmc = 'disabled'
638
endif
639
elif not with_platform_x11
640
if _xvmc == 'enabled'
641
error('XVMC state tracker requires X11 support.')
642
else
643
_xvmc = 'disabled'
644
endif
645
elif not (with_gallium_r600 or with_gallium_nouveau)
646
if _xvmc == 'enabled'
647
error('XVMC state tracker requires at least one of the following gallium drivers: r600, nouveau.')
648
else
649
_xvmc = 'disabled'
650
endif
651
endif
652
dep_xvmc = null_dep
653
dep_xv = null_dep
654
with_gallium_xvmc = false
655
if _xvmc != 'disabled'
656
dep_xvmc = dependency('xvmc', version : '>= 1.0.6', required : _xvmc == 'enabled')
657
dep_xv = dependency('xv', required : _xvmc == 'enabled')
658
with_gallium_xvmc = dep_xvmc.found() and dep_xv.found()
659
endif
660
661
xvmc_drivers_path = get_option('xvmc-libs-path')
662
if xvmc_drivers_path == ''
663
xvmc_drivers_path = get_option('libdir')
664
endif
665
666
_omx = get_option('gallium-omx')
667
if not system_has_kms_drm
668
if ['auto', 'disabled'].contains(_omx)
669
_omx = 'disabled'
670
else
671
error('OMX state tracker can only be built on unix-like OSes.')
672
endif
673
elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
674
if ['auto', 'disabled'].contains(_omx)
675
_omx = 'disabled'
676
else
677
error('OMX state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
678
endif
679
endif
680
with_gallium_omx = _omx
681
dep_omx = null_dep
682
dep_omx_other = []
683
if ['auto', 'bellagio'].contains(_omx)
684
dep_omx = dependency(
685
'libomxil-bellagio', required : _omx == 'bellagio'
686
)
687
if dep_omx.found()
688
with_gallium_omx = 'bellagio'
689
endif
690
endif
691
if ['auto', 'tizonia'].contains(_omx)
692
if with_dri and with_egl
693
dep_omx = dependency(
694
'libtizonia', version : '>= 0.10.0',
695
required : _omx == 'tizonia',
696
)
697
dep_omx_other = [
698
dependency('libtizplatform', required : _omx == 'tizonia'),
699
dependency('tizilheaders', required : _omx == 'tizonia'),
700
]
701
if dep_omx.found() and dep_omx_other[0].found() and dep_omx_other[1].found()
702
with_gallium_omx = 'tizonia'
703
endif
704
elif _omx == 'tizonia'
705
error('OMX-Tizonia state tracker requires dri and egl')
706
endif
707
endif
708
if _omx == 'auto'
709
with_gallium_omx = 'disabled'
710
else
711
with_gallium_omx = _omx
712
endif
713
714
pre_args += [
715
'-DENABLE_ST_OMX_BELLAGIO=' + (with_gallium_omx == 'bellagio' ? '1' : '0'),
716
'-DENABLE_ST_OMX_TIZONIA=' + (with_gallium_omx == 'tizonia' ? '1' : '0'),
717
]
718
719
720
omx_drivers_path = get_option('omx-libs-path')
721
722
if with_gallium_omx != 'disabled'
723
# Figure out where to put the omx driver.
724
# FIXME: this could all be vastly simplified by adding a 'defined_variable'
725
# argument to meson's get_pkgconfig_variable method.
726
if omx_drivers_path == ''
727
_omx_libdir = dep_omx.get_pkgconfig_variable('libdir')
728
_omx_drivers_dir = dep_omx.get_pkgconfig_variable('pluginsdir')
729
if _omx_libdir == get_option('libdir')
730
omx_drivers_path = _omx_drivers_dir
731
else
732
_omx_base_dir = []
733
# This will fail on windows. Does OMX run on windows?
734
_omx_libdir = _omx_libdir.split('/')
735
_omx_drivers_dir = _omx_drivers_dir.split('/')
736
foreach o : _omx_drivers_dir
737
if not _omx_libdir.contains(o)
738
_omx_base_dir += o
739
endif
740
endforeach
741
omx_drivers_path = join_paths(get_option('libdir'), _omx_base_dir)
742
endif
743
endif
744
endif
745
746
_va = get_option('gallium-va')
747
if _va == 'true'
748
_va = 'enabled'
749
warning('gallium-va option "true" deprecated, please use "enabled" instead.')
750
elif _va == 'false'
751
_va = 'disabled'
752
warning('gallium-va option "false" deprecated, please use "disabled" instead.')
753
endif
754
if not system_has_kms_drm
755
if _va == 'enabled'
756
error('VA state tracker can only be built on unix-like OSes.')
757
else
758
_va = 'disabled'
759
endif
760
elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
761
if _va == 'enabled'
762
error('VA state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
763
else
764
_va = 'disabled'
765
endif
766
endif
767
with_gallium_va = false
768
dep_va = null_dep
769
if _va != 'disabled'
770
dep_va = dependency('libva', version : '>= 1.1.0', required : _va == 'enabled')
771
if dep_va.found()
772
dep_va_headers = dep_va.partial_dependency(compile_args : true)
773
with_gallium_va = true
774
if cc.has_header_symbol('va/va.h', 'VASurfaceAttribDRMFormatModifiers',
775
dependencies: dep_va_headers)
776
pre_args += '-DHAVE_VA_SURFACE_ATTRIB_DRM_FORMAT_MODIFIERS'
777
endif
778
endif
779
endif
780
781
va_drivers_path = get_option('va-libs-path')
782
if va_drivers_path == ''
783
va_drivers_path = join_paths(get_option('libdir'), 'dri')
784
endif
785
786
_xa = get_option('gallium-xa')
787
if _xa == 'true'
788
_xa = 'enabled'
789
warning('gallium-xa option "true" deprecated, please use "enabled" instead.')
790
elif _xa == 'false'
791
_xa = 'disabled'
792
warning('gallium-xa option "false" deprecated, please use "disabled" instead.')
793
endif
794
if not system_has_kms_drm
795
if _xa == 'enabled'
796
error('XA state tracker can only be built on unix-like OSes.')
797
else
798
_xa = 'disabled'
799
endif
800
elif not (with_gallium_nouveau or with_gallium_freedreno or with_gallium_i915
801
or with_gallium_svga)
802
if _xa == 'enabled'
803
error('XA state tracker requires at least one of the following gallium drivers: nouveau, freedreno, i915, svga.')
804
else
805
_xa = 'disabled'
806
endif
807
endif
808
with_gallium_xa = _xa != 'disabled'
809
810
d3d_drivers_path = get_option('d3d-drivers-path')
811
if d3d_drivers_path == ''
812
d3d_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'd3d')
813
endif
814
815
with_gallium_st_nine = get_option('gallium-nine')
816
if with_gallium_st_nine
817
if not with_gallium_softpipe
818
error('The nine state tracker requires gallium softpipe/llvmpipe.')
819
elif not (with_gallium_radeonsi or with_gallium_nouveau or with_gallium_r600
820
or with_gallium_r300 or with_gallium_svga or with_gallium_i915
821
or with_gallium_iris or with_gallium_crocus)
822
error('The nine state tracker requires at least one non-swrast gallium driver.')
823
endif
824
if not with_dri3
825
error('Using nine with wine requires dri3')
826
endif
827
endif
828
with_gallium_st_d3d10umd = get_option('gallium-d3d10umd')
829
if with_gallium_st_d3d10umd
830
if not with_gallium_softpipe
831
error('The d3d10umd state tracker requires gallium softpipe/llvmpipe.')
832
endif
833
endif
834
_power8 = get_option('power8')
835
if _power8 == 'true'
836
_power8 = 'enabled'
837
warning('power8 option "true" deprecated, please use "enabled" instead.')
838
elif _power8 == 'false'
839
_power8 = 'disabled'
840
warning('power8 option "false" deprecated, please use "disabled" instead.')
841
endif
842
if _power8 != 'disabled'
843
# on old versions of meson the cpu family would return as ppc64le on little
844
# endian power8, this was changed in 0.48 such that the family would always
845
# be ppc64 regardless of endianness, and then the machine.endian() value
846
# should be checked. Since we support versions < 0.48 we need to use
847
# startswith.
848
if host_machine.cpu_family().startswith('ppc64') and host_machine.endian() == 'little'
849
if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.8')
850
error('Altivec is not supported with gcc version < 4.8.')
851
endif
852
if cc.compiles('''
853
#include <altivec.h>
854
int main() {
855
vector unsigned char r;
856
vector unsigned int v = vec_splat_u32 (1);
857
r = __builtin_vec_vgbbd ((vector unsigned char) v);
858
return 0;
859
}''',
860
args : '-mpower8-vector',
861
name : 'POWER8 intrinsics')
862
pre_args += ['-D_ARCH_PWR8', '-mpower8-vector']
863
elif get_option('power8') == 'enabled'
864
error('POWER8 intrinsic support required but not found.')
865
endif
866
endif
867
endif
868
869
_opencl = get_option('gallium-opencl')
870
if _opencl != 'disabled'
871
if not with_gallium
872
error('OpenCL Clover implementation requires at least one gallium driver.')
873
endif
874
875
with_clc = true
876
with_gallium_opencl = true
877
with_opencl_icd = _opencl == 'icd'
878
else
879
with_gallium_opencl = false
880
with_opencl_icd = false
881
endif
882
883
dep_clc = null_dep
884
if with_clc
885
dep_clc = dependency('libclc')
886
endif
887
888
gl_pkgconfig_c_flags = []
889
if with_platform_x11
890
if with_any_vk or with_egl or (with_glx == 'dri' and with_dri_platform == 'drm')
891
pre_args += '-DHAVE_X11_PLATFORM'
892
pre_args += '-DHAVE_XCB_PLATFORM'
893
endif
894
if with_glx == 'xlib' or with_glx == 'gallium-xlib'
895
pre_args += '-DUSE_XSHM'
896
else
897
pre_args += '-DGLX_INDIRECT_RENDERING'
898
if with_glx_direct
899
pre_args += '-DGLX_DIRECT_RENDERING'
900
endif
901
if with_dri_platform == 'drm'
902
pre_args += '-DGLX_USE_DRM'
903
elif with_dri_platform == 'apple'
904
pre_args += '-DGLX_USE_APPLEGL'
905
elif with_dri_platform == 'windows'
906
pre_args += '-DGLX_USE_WINDOWSGL'
907
endif
908
endif
909
else
910
pre_args += '-DEGL_NO_X11'
911
gl_pkgconfig_c_flags += '-DEGL_NO_X11'
912
endif
913
if with_gbm and not with_platform_android
914
pre_args += '-DHAVE_DRM_PLATFORM'
915
endif
916
917
with_android_stub = get_option('android-stub')
918
if with_android_stub and not with_platform_android
919
error('`-D android-stub=true` makes no sense without `-D platforms=android`')
920
endif
921
922
if with_platform_android
923
dep_android_mapper4 = null_dep
924
if not with_android_stub
925
dep_android = [
926
dependency('cutils'),
927
dependency('hardware'),
928
dependency('sync'),
929
dependency('backtrace')
930
]
931
if get_option('platform-sdk-version') >= 26
932
dep_android += dependency('nativewindow')
933
endif
934
if get_option('platform-sdk-version') >= 30
935
dep_android_mapper4 = dependency('android.hardware.graphics.mapper', version : '>= 4.0', required : false)
936
endif
937
endif
938
pre_args += [
939
'-DHAVE_ANDROID_PLATFORM',
940
'-DANDROID',
941
'-DANDROID_API_LEVEL=' + get_option('platform-sdk-version').to_string()
942
]
943
endif
944
if with_platform_haiku
945
pre_args += '-DHAVE_HAIKU_PLATFORM'
946
endif
947
948
prog_python = import('python').find_installation('python3')
949
has_mako = run_command(
950
prog_python, '-c',
951
'''
952
from distutils.version import StrictVersion
953
import mako
954
assert StrictVersion(mako.__version__) > StrictVersion("0.8.0")
955
''')
956
if has_mako.returncode() != 0
957
error('Python (3.x) mako module >= 0.8.0 required to build mesa.')
958
endif
959
960
if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
961
error('When using GCC, version 4.4.6 or later is required.')
962
endif
963
964
# Support systems without ETIME (e.g. FreeBSD)
965
if cc.get_define('ETIME', prefix : '#include <errno.h>') == ''
966
pre_args += '-DETIME=ETIMEDOUT'
967
endif
968
969
# Define DEBUG for debug builds only (debugoptimized is not included on this one)
970
if get_option('buildtype') == 'debug'
971
pre_args += '-DDEBUG'
972
endif
973
974
with_shader_cache = false
975
_shader_cache = get_option('shader-cache')
976
if _shader_cache == 'true'
977
_shader_cache = 'enabled'
978
warning('shader_cache option "true" deprecated, please use "enabled" instead.')
979
elif _shader_cache == 'false'
980
_shader_cache = 'disabled'
981
warning('shader_cache option "false" deprecated, please use "disabled" instead.')
982
endif
983
if _shader_cache != 'disabled'
984
if host_machine.system() == 'windows'
985
if _shader_cache == 'enabled'
986
error('Shader Cache does not currently work on Windows')
987
endif
988
else
989
pre_args += '-DENABLE_SHADER_CACHE'
990
if not get_option('shader-cache-default')
991
pre_args += '-DSHADER_CACHE_DISABLE_BY_DEFAULT'
992
endif
993
with_shader_cache = true
994
endif
995
endif
996
997
if with_shader_cache
998
shader_cache_max_size = get_option('shader-cache-max-size')
999
if shader_cache_max_size != ''
1000
pre_args += '-DMESA_GLSL_CACHE_MAX_SIZE="@0@"'.format(shader_cache_max_size)
1001
endif
1002
endif
1003
1004
# Check for GCC style builtins
1005
foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
1006
'ffsll', 'popcount', 'popcountll', 'unreachable', 'types_compatible_p']
1007
if cc.has_function(b)
1008
pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
1009
endif
1010
endforeach
1011
1012
# check for GCC __attribute__
1013
_attributes = [
1014
'const', 'flatten', 'malloc', 'pure', 'unused', 'warn_unused_result',
1015
'weak', 'format', 'packed', 'returns_nonnull', 'alias', 'noreturn',
1016
]
1017
foreach a : cc.get_supported_function_attributes(_attributes)
1018
pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
1019
endforeach
1020
if cc.has_function_attribute('visibility:hidden')
1021
pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISIBILITY'
1022
endif
1023
if cc.compiles('__uint128_t foo(void) { return 0; }',
1024
name : '__uint128_t')
1025
pre_args += '-DHAVE_UINT128'
1026
endif
1027
1028
# TODO: this is very incomplete
1029
if ['linux', 'cygwin', 'gnu', 'freebsd', 'gnu/kfreebsd', 'haiku'].contains(host_machine.system())
1030
pre_args += '-D_GNU_SOURCE'
1031
elif host_machine.system() == 'sunos'
1032
pre_args += '-D__EXTENSIONS__'
1033
elif host_machine.system() == 'windows'
1034
pre_args += [
1035
'-D_WINDOWS', '-D_WIN32_WINNT=0x0A00', '-DWINVER=0x0A00',
1036
'-DPIPE_SUBSYSTEM_WINDOWS_USER',
1037
'-D_USE_MATH_DEFINES', # XXX: scons didn't use this for mingw
1038
]
1039
if cc.get_id() == 'msvc'
1040
pre_args += [
1041
'-DVC_EXTRALEAN',
1042
'-D_CRT_SECURE_NO_WARNINGS',
1043
'-D_CRT_SECURE_NO_DEPRECATE',
1044
'-D_SCL_SECURE_NO_WARNINGS',
1045
'-D_SCL_SECURE_NO_DEPRECATE',
1046
'-D_ALLOW_KEYWORD_MACROS',
1047
'-D_HAS_EXCEPTIONS=0', # Tell C++ STL to not use exceptions
1048
'-DNOMINMAX',
1049
]
1050
else
1051
pre_args += ['-D__MSVCRT_VERSION__=0x0700']
1052
endif
1053
elif host_machine.system() == 'openbsd'
1054
pre_args += '-D_ISOC11_SOURCE'
1055
endif
1056
1057
# Check for generic C arguments
1058
c_msvc_compat_args = []
1059
no_override_init_args = []
1060
cpp_msvc_compat_args = []
1061
if cc.get_id() == 'msvc'
1062
foreach a : ['/wd4018', # signed/unsigned mismatch
1063
'/wd4056', # overflow in floating-point constant arithmetic
1064
'/wd4244', # conversion from 'type1' to 'type2', possible loss of data
1065
'/wd4267', # 'var' : conversion from 'size_t' to 'type', possible loss of data
1066
'/wd4305', # trancation from 'type1' to 'type2'
1067
'/wd4351', # new behavior: elements of array 'array' will be default initialized
1068
'/wd4756', # overflow in constant arithmetic
1069
'/wd4800', # forcing value to bool 'true' or 'false' (performance warning)
1070
'/wd4996', # disabled deprecated POSIX name warnings
1071
'/wd4291', # no matching operator delete found
1072
'/wd4146', # unary minus operator applied to unsigned type, result still unsigned
1073
'/wd4200', # nonstandard extension used: zero-sized array in struct/union
1074
'/wd4624', # destructor was implicitly defined as deleted [from LLVM]
1075
'/wd4309', # 'initializing': truncation of constant value
1076
'/wd4838', # conversion from 'int' to 'const char' requires a narrowing conversion
1077
'/wd5105', # macro expansion producing 'defined' has undefined behavior (winbase.h, need Windows SDK upgrade)
1078
'/we4020', # Error when passing the wrong number of parameters
1079
'/we4024', # Error when passing different type of parameter
1080
]
1081
if cc.has_argument(a)
1082
c_args += a
1083
endif
1084
if cpp.has_argument(a)
1085
cpp_args += a
1086
endif
1087
endforeach
1088
else
1089
_trial = [
1090
'-Werror=implicit-function-declaration',
1091
'-Werror=missing-prototypes',
1092
'-Werror=return-type',
1093
'-Werror=empty-body',
1094
'-Werror=incompatible-pointer-types',
1095
'-Werror=int-conversion',
1096
'-Wimplicit-fallthrough',
1097
'-Werror=thread-safety',
1098
'-Wno-missing-field-initializers',
1099
'-Wno-format-truncation',
1100
'-fno-math-errno',
1101
'-fno-trapping-math',
1102
'-Qunused-arguments',
1103
'-fno-common',
1104
]
1105
# MinGW chokes on format specifiers and I can't get it all working
1106
if not (cc.get_id() == 'gcc' and host_machine.system() == 'windows')
1107
_trial += ['-Werror=format', '-Wformat-security']
1108
endif
1109
foreach a : _trial
1110
if cc.has_argument(a)
1111
c_args += a
1112
endif
1113
endforeach
1114
1115
_trial = [
1116
'-Werror=return-type',
1117
'-Werror=empty-body',
1118
'-Wno-non-virtual-dtor',
1119
'-Wno-missing-field-initializers',
1120
'-Wno-format-truncation',
1121
'-fno-math-errno',
1122
'-fno-trapping-math',
1123
'-Qunused-arguments',
1124
# Some classes use custom new operator which zeroes memory, however
1125
# gcc does aggressive dead-store elimination which threats all writes
1126
# to the memory before the constructor as "dead stores".
1127
# For now we disable this optimization.
1128
'-flifetime-dse=1',
1129
]
1130
# MinGW chokes on format specifiers and I can't get it all working
1131
if not (cc.get_id() == 'gcc' and host_machine.system() == 'windows')
1132
_trial += ['-Werror=format', '-Wformat-security']
1133
endif
1134
foreach a : _trial
1135
if cpp.has_argument(a)
1136
cpp_args += a
1137
endif
1138
endforeach
1139
1140
foreach a : ['-Wno-override-init', '-Wno-initializer-overrides']
1141
if cc.has_argument(a)
1142
no_override_init_args += a
1143
endif
1144
endforeach
1145
1146
# Check for C and C++ arguments for MSVC compatibility. These are only used
1147
# in parts of the mesa code base that need to compile with MSVC, mainly
1148
# common code
1149
foreach a : ['-Werror=pointer-arith', '-Werror=gnu-empty-initializer']
1150
if cc.has_argument(a)
1151
c_msvc_compat_args += a
1152
endif
1153
if cpp.has_argument(a)
1154
cpp_msvc_compat_args += a
1155
endif
1156
endforeach
1157
1158
if cc.has_argument('-Wmicrosoft-enum-value') # Clang
1159
c_args += '-Wno-microsoft-enum-value'
1160
cpp_args += '-Wno-microsoft-enum-value'
1161
endif
1162
endif
1163
1164
# set linker arguments
1165
if host_machine.system() == 'windows'
1166
if cc.get_id() == 'msvc'
1167
add_project_link_arguments(
1168
'/fixed:no',
1169
'/dynamicbase',
1170
'/nxcompat',
1171
language : ['c', 'cpp'],
1172
)
1173
if get_option('buildtype') != 'debug'
1174
add_project_link_arguments(
1175
'/incremental:no',
1176
language : ['c', 'cpp'],
1177
)
1178
endif
1179
else
1180
add_project_link_arguments(
1181
'-Wl,--nxcompat',
1182
'-Wl,--dynamicbase',
1183
'-static-libgcc',
1184
'-static-libstdc++',
1185
language : ['c', 'cpp'],
1186
)
1187
endif
1188
endif
1189
1190
if host_machine.cpu_family().startswith('x86') and cc.get_id() != 'msvc'
1191
pre_args += '-DUSE_SSE41'
1192
with_sse41 = true
1193
sse41_args = ['-msse4.1']
1194
1195
if host_machine.cpu_family() == 'x86'
1196
if get_option('sse2')
1197
# These settings make generated GCC code match MSVC and follow
1198
# GCC advice on https://gcc.gnu.org/wiki/FloatingPointMath#x86note
1199
#
1200
# NOTE: We need to ensure stack is realigned given that we
1201
# produce shared objects, and have no control over the stack
1202
# alignment policy of the application. Therefore we need
1203
# -mstackrealign or -mincoming-stack-boundary=2.
1204
#
1205
# XXX: We could have SSE without -mstackrealign if we always used
1206
# __attribute__((force_align_arg_pointer)), but that's not
1207
# always the case.
1208
c_args += ['-msse2', '-mfpmath=sse', '-mstackrealign']
1209
else
1210
# GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but
1211
# that's not guaranteed
1212
sse41_args += '-mstackrealign'
1213
endif
1214
endif
1215
else
1216
with_sse41 = false
1217
sse41_args = []
1218
endif
1219
1220
# Check for GCC style atomics
1221
dep_atomic = null_dep
1222
1223
if cc.compiles('''#include <stdint.h>
1224
int main() {
1225
struct {
1226
uint64_t *v;
1227
} x;
1228
return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
1229
(int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
1230
1231
}''',
1232
name : 'GCC atomic builtins')
1233
pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
1234
1235
# Not all atomic calls can be turned into lock-free instructions, in which
1236
# GCC will make calls into the libatomic library. Check whether we need to
1237
# link with -latomic.
1238
#
1239
# This can happen for 64-bit atomic operations on 32-bit architectures such
1240
# as ARM.
1241
if not cc.links('''#include <stdint.h>
1242
int main() {
1243
struct {
1244
uint64_t *v;
1245
} x;
1246
return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
1247
(int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
1248
}''',
1249
name : 'GCC atomic builtins required -latomic')
1250
dep_atomic = cc.find_library('atomic')
1251
endif
1252
endif
1253
if not cc.links('''#include <stdint.h>
1254
uint64_t v;
1255
int main() {
1256
return __sync_add_and_fetch(&v, (uint64_t)1);
1257
}''',
1258
dependencies : dep_atomic,
1259
name : 'GCC 64bit atomics')
1260
pre_args += '-DMISSING_64BIT_ATOMICS'
1261
endif
1262
1263
dep_ws2_32 = cc.find_library('ws2_32', required : with_platform_windows)
1264
1265
# TODO: shared/static? Is this even worth doing?
1266
1267
with_asm_arch = ''
1268
if host_machine.cpu_family() == 'x86'
1269
if system_has_kms_drm or host_machine.system() == 'gnu'
1270
with_asm_arch = 'x86'
1271
pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
1272
'-DUSE_SSE_ASM']
1273
1274
if with_glx_read_only_text
1275
pre_args += ['-DGLX_X86_READONLY_TEXT']
1276
endif
1277
endif
1278
elif host_machine.cpu_family() == 'x86_64'
1279
if system_has_kms_drm
1280
with_asm_arch = 'x86_64'
1281
pre_args += ['-DUSE_X86_64_ASM']
1282
endif
1283
elif host_machine.cpu_family() == 'arm'
1284
if system_has_kms_drm
1285
with_asm_arch = 'arm'
1286
pre_args += ['-DUSE_ARM_ASM']
1287
endif
1288
elif host_machine.cpu_family() == 'aarch64'
1289
if system_has_kms_drm
1290
with_asm_arch = 'aarch64'
1291
pre_args += ['-DUSE_AARCH64_ASM']
1292
endif
1293
elif host_machine.cpu_family() == 'sparc64'
1294
if system_has_kms_drm
1295
with_asm_arch = 'sparc'
1296
pre_args += ['-DUSE_SPARC_ASM']
1297
endif
1298
elif host_machine.cpu_family().startswith('ppc64') and host_machine.endian() == 'little'
1299
if system_has_kms_drm
1300
with_asm_arch = 'ppc64le'
1301
pre_args += ['-DUSE_PPC64LE_ASM']
1302
endif
1303
endif
1304
1305
# Check for standard headers and functions
1306
if (cc.has_header_symbol('sys/sysmacros.h', 'major') and
1307
cc.has_header_symbol('sys/sysmacros.h', 'minor') and
1308
cc.has_header_symbol('sys/sysmacros.h', 'makedev'))
1309
pre_args += '-DMAJOR_IN_SYSMACROS'
1310
endif
1311
if (cc.has_header_symbol('sys/mkdev.h', 'major') and
1312
cc.has_header_symbol('sys/mkdev.h', 'minor') and
1313
cc.has_header_symbol('sys/mkdev.h', 'makedev'))
1314
pre_args += '-DMAJOR_IN_MKDEV'
1315
endif
1316
1317
if cc.check_header('sched.h')
1318
pre_args += '-DHAS_SCHED_H'
1319
if cc.has_function('sched_getaffinity')
1320
pre_args += '-DHAS_SCHED_GETAFFINITY'
1321
endif
1322
endif
1323
1324
if not ['linux'].contains(host_machine.system())
1325
# Deprecated on Linux and requires <sys/types.h> on FreeBSD and OpenBSD
1326
if cc.check_header('sys/sysctl.h', prefix : '#include <sys/types.h>')
1327
pre_args += '-DHAVE_SYS_SYSCTL_H'
1328
endif
1329
endif
1330
1331
foreach h : ['xlocale.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'execinfo.h', 'sys/shm.h', 'cet.h', 'pthread_np.h']
1332
if cc.check_header(h)
1333
pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
1334
endif
1335
endforeach
1336
1337
foreach f : ['strtof', 'mkostemp', 'timespec_get', 'memfd_create', 'random_r',
1338
'flock', 'strtok_r', 'getrandom', 'qsort_r', 'qsort_s']
1339
if cc.has_function(f)
1340
pre_args += '-DHAVE_@0@'.format(f.to_upper())
1341
endif
1342
endforeach
1343
1344
if cc.has_header_symbol('errno.h', 'program_invocation_name',
1345
args : '-D_GNU_SOURCE')
1346
pre_args += '-DHAVE_PROGRAM_INVOCATION_NAME'
1347
elif with_tools.contains('intel')
1348
error('Intel tools require the program_invocation_name variable')
1349
endif
1350
1351
# MinGW provides a __builtin_posix_memalign function, but not a posix_memalign.
1352
# This means that this check will succeed, but then compilation will later
1353
# fail. MSVC doesn't have this function at all, so only check for it on
1354
# non-windows platforms.
1355
if host_machine.system() != 'windows'
1356
if cc.has_function('posix_memalign')
1357
pre_args += '-DHAVE_POSIX_MEMALIGN'
1358
endif
1359
endif
1360
1361
if cc.has_member('struct dirent', 'd_type', prefix: '''#include <sys/types.h>
1362
#include <dirent.h>''')
1363
pre_args += '-DHAVE_DIRENT_D_TYPE'
1364
endif
1365
1366
# strtod locale support
1367
if cc.links('''
1368
#define _GNU_SOURCE
1369
#include <stdlib.h>
1370
#include <locale.h>
1371
#ifdef HAVE_XLOCALE_H
1372
#include <xlocale.h>
1373
#endif
1374
int main() {
1375
locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
1376
const char *s = "1.0";
1377
char *end;
1378
double d = strtod_l(s, end, loc);
1379
float f = strtof_l(s, end, loc);
1380
freelocale(loc);
1381
return 0;
1382
}''',
1383
args : pre_args,
1384
name : 'strtod has locale support')
1385
pre_args += '-DHAVE_STRTOD_L'
1386
endif
1387
1388
# Check for some linker flags
1389
ld_args_bsymbolic = []
1390
if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
1391
ld_args_bsymbolic += '-Wl,-Bsymbolic'
1392
endif
1393
ld_args_gc_sections = []
1394
if cc.links('static char unused() { return 5; } int main() { return 0; }',
1395
args : '-Wl,--gc-sections', name : 'gc-sections')
1396
ld_args_gc_sections += '-Wl,--gc-sections'
1397
endif
1398
with_ld_version_script = false
1399
if cc.links('int main() { return 0; }',
1400
args : '-Wl,--version-script=@0@'.format(
1401
join_paths(meson.source_root(), 'build-support/conftest.map')),
1402
name : 'version-script')
1403
with_ld_version_script = true
1404
endif
1405
with_ld_dynamic_list = false
1406
if cc.links('int main() { return 0; }',
1407
args : '-Wl,--dynamic-list=@0@'.format(
1408
join_paths(meson.source_root(), 'build-support/conftest.dyn')),
1409
name : 'dynamic-list')
1410
with_ld_dynamic_list = true
1411
endif
1412
1413
ld_args_build_id = cc.get_supported_link_arguments('-Wl,--build-id=sha1')
1414
1415
# check for dl support
1416
dep_dl = null_dep
1417
if not cc.has_function('dlopen')
1418
dep_dl = cc.find_library('dl', required : host_machine.system() != 'windows')
1419
endif
1420
if cc.has_function('dladdr', dependencies : dep_dl)
1421
# This is really only required for megadrivers
1422
pre_args += '-DHAVE_DLADDR'
1423
endif
1424
1425
if cc.has_function('dl_iterate_phdr')
1426
pre_args += '-DHAVE_DL_ITERATE_PHDR'
1427
elif with_intel_vk
1428
error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr function')
1429
elif with_dri_i965 and with_shader_cache
1430
error('Intel i965 GL driver requires dl_iterate_phdr when built with shader caching.')
1431
endif
1432
1433
# Determine whether or not the rt library is needed for time functions
1434
if host_machine.system() == 'windows' or cc.has_function('clock_gettime')
1435
dep_clock = null_dep
1436
else
1437
dep_clock = cc.find_library('rt')
1438
endif
1439
1440
dep_zlib = dependency('zlib', version : '>= 1.2.3',
1441
fallback : ['zlib', 'zlib_dep'],
1442
required : get_option('zlib'))
1443
if dep_zlib.found()
1444
pre_args += '-DHAVE_ZLIB'
1445
endif
1446
1447
_zstd = get_option('zstd')
1448
if _zstd == 'true'
1449
_zstd = 'enabled'
1450
warning('zstd option "true" deprecated, please use "enabled" instead.')
1451
elif _zstd == 'false'
1452
_zstd = 'disabled'
1453
warning('zstd option "false" deprecated, please use "disabled" instead.')
1454
endif
1455
if _zstd != 'disabled'
1456
dep_zstd = dependency('libzstd', required : _zstd == 'enabled')
1457
if dep_zstd.found()
1458
pre_args += '-DHAVE_ZSTD'
1459
endif
1460
else
1461
dep_zstd = null_dep
1462
endif
1463
1464
with_compression = dep_zlib.found() or dep_zstd.found()
1465
if with_compression
1466
pre_args += '-DHAVE_COMPRESSION'
1467
elif with_shader_cache
1468
error('Shader Cache requires compression')
1469
endif
1470
1471
dep_thread = dependency('threads')
1472
if dep_thread.found() and host_machine.system() != 'windows'
1473
pre_args += '-DHAVE_PTHREAD'
1474
if host_machine.system() != 'netbsd' and cc.has_function(
1475
'pthread_setaffinity_np',
1476
dependencies : dep_thread,
1477
prefix : '#include <pthread.h>',
1478
args : '-D_GNU_SOURCE')
1479
pre_args += '-DHAVE_PTHREAD_SETAFFINITY'
1480
endif
1481
endif
1482
if host_machine.system() == 'darwin'
1483
dep_expat = meson.get_compiler('c').find_library('expat')
1484
elif host_machine.system() != 'windows'
1485
dep_expat = dependency('expat', fallback : ['expat', 'expat_dep'],
1486
required: not with_platform_android or with_any_intel)
1487
else
1488
dep_expat = null_dep
1489
endif
1490
# this only exists on linux so either this is linux and it will be found, or
1491
# it's not linux and wont
1492
dep_m = cc.find_library('m', required : false)
1493
1494
if host_machine.system() == 'windows'
1495
dep_regex = meson.get_compiler('c').find_library('regex', required : false)
1496
if not dep_regex.found()
1497
dep_regex = declare_dependency(compile_args : ['-DNO_REGEX'])
1498
endif
1499
else
1500
dep_regex = null_dep
1501
endif
1502
1503
if with_platform_haiku
1504
dep_network = cc.find_library('network')
1505
endif
1506
1507
# Check for libdrm. Various drivers have different libdrm version requirements,
1508
# but we always want to use the same version for all libdrm modules. That means
1509
# even if driver foo requires 2.4.0 and driver bar requires 2.4.3, if foo and
1510
# bar are both on use 2.4.3 for both of them
1511
dep_libdrm_amdgpu = null_dep
1512
dep_libdrm_radeon = null_dep
1513
dep_libdrm_nouveau = null_dep
1514
dep_libdrm_intel = null_dep
1515
1516
_drm_amdgpu_ver = '2.4.107'
1517
_drm_radeon_ver = '2.4.71'
1518
_drm_nouveau_ver = '2.4.102'
1519
_drm_intel_ver = '2.4.75'
1520
_drm_ver = '2.4.81'
1521
1522
_libdrm_checks = [
1523
['intel', with_dri_i915 or with_gallium_i915],
1524
['amdgpu', (with_amd_vk and not with_platform_windows) or with_gallium_radeonsi],
1525
['radeon', (with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or
1526
with_gallium_r300 or with_gallium_r600)],
1527
['nouveau', (with_gallium_nouveau or with_dri_nouveau)],
1528
]
1529
1530
# VC4 only needs core libdrm support of this version, not a libdrm_vc4
1531
# library.
1532
if with_gallium_vc4
1533
_drm_ver = '2.4.89'
1534
endif
1535
1536
# etnaviv only needs core libdrm
1537
if with_gallium_etnaviv
1538
_drm_ver = '2.4.89'
1539
endif
1540
1541
# Loop over the enables versions and get the highest libdrm requirement for all
1542
# active drivers.
1543
_drm_blame = ''
1544
foreach d : _libdrm_checks
1545
ver = get_variable('_drm_@0@_ver'.format(d[0]))
1546
if d[1] and ver.version_compare('>' + _drm_ver)
1547
_drm_ver = ver
1548
_drm_blame = d[0]
1549
endif
1550
endforeach
1551
if _drm_blame != ''
1552
message('libdrm @0@ needed because @1@ has the highest requirement'.format(_drm_ver, _drm_blame))
1553
endif
1554
1555
# Then get each libdrm module
1556
foreach d : _libdrm_checks
1557
if d[1]
1558
set_variable(
1559
'dep_libdrm_' + d[0],
1560
dependency('libdrm_' + d[0], version : '>=' + _drm_ver)
1561
)
1562
endif
1563
endforeach
1564
1565
with_gallium_drisw_kms = false
1566
dep_libdrm = dependency(
1567
'libdrm', version : '>=' + _drm_ver,
1568
# GNU/Hurd includes egl_dri2, without drm.
1569
required : not with_platform_android and ((with_dri2 and host_machine.system() != 'gnu') or with_dri3)
1570
)
1571
if dep_libdrm.found()
1572
pre_args += '-DHAVE_LIBDRM'
1573
if with_dri_platform == 'drm' and with_dri
1574
with_gallium_drisw_kms = true
1575
endif
1576
endif
1577
1578
llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit', 'core', 'executionengine', 'scalaropts', 'transformutils', 'instcombine']
1579
llvm_optional_modules = ['coroutines']
1580
if with_amd_vk or with_gallium_radeonsi or with_gallium_r600
1581
llvm_modules += ['amdgpu', 'native', 'bitreader', 'ipo']
1582
if with_gallium_r600
1583
llvm_modules += 'asmparser'
1584
endif
1585
endif
1586
if with_gallium_opencl
1587
llvm_modules += [
1588
'linker', 'coverage', 'instrumentation', 'ipo', 'irreader',
1589
'lto', 'option', 'objcarcopts', 'profiledata'
1590
]
1591
llvm_optional_modules += ['frontendopenmp']
1592
endif
1593
if with_microsoft_clc
1594
llvm_modules += ['target', 'linker', 'irreader', 'option', 'libdriver']
1595
endif
1596
if with_tests or with_gallium_softpipe
1597
llvm_modules += 'native'
1598
endif
1599
1600
if with_amd_vk or with_gallium_radeonsi
1601
_llvm_version = '>= 11.0.0'
1602
elif with_microsoft_clc
1603
_llvm_version = '>= 10.0.0'
1604
elif with_gallium_opencl
1605
_llvm_version = '>= 8.0.0'
1606
elif with_gallium_swr
1607
_llvm_version = '>= 6.0.0'
1608
else
1609
_llvm_version = '>= 3.9.0'
1610
endif
1611
1612
_shared_llvm = get_option('shared-llvm')
1613
if _shared_llvm == 'true'
1614
_shared_llvm = 'enabled'
1615
warning('shared_llvm option "true" deprecated, please use "enabled" instead.')
1616
elif _shared_llvm == 'false'
1617
_shared_llvm = 'disabled'
1618
warning('shared_llvm option "false" deprecated, please use "disabled" instead.')
1619
endif
1620
if _shared_llvm == 'auto'
1621
_shared_llvm = (host_machine.system() != 'windows')
1622
else
1623
_shared_llvm = (_shared_llvm == 'enabled')
1624
endif
1625
_llvm = get_option('llvm')
1626
if _llvm == 'true'
1627
_llvm = 'enabled'
1628
warning('llvm option "true" deprecated, please use "enabled" instead.')
1629
elif _llvm == 'false'
1630
_llvm = 'disabled'
1631
warning('llvm option "false" deprecated, please use "disabled" instead.')
1632
endif
1633
1634
# the cmake method can only link statically, so don't attempt to use it if we
1635
# want to link dynamically. Before 0.54.0 meson will try cmake even when shared
1636
# linking is requested, so we need to force the config-tool method to be used
1637
# in that case, but in 0.54.0 meson won't try the cmake method if shared
1638
# linking is requested.
1639
_llvm_method = 'auto'
1640
if meson.version().version_compare('< 0.54.0') and _shared_llvm
1641
_llvm_method = 'config-tool'
1642
endif
1643
1644
dep_llvm = null_dep
1645
with_llvm = false
1646
draw_with_llvm = get_option('draw-use-llvm')
1647
if _llvm != 'disabled'
1648
dep_llvm = dependency(
1649
'llvm',
1650
version : _llvm_version,
1651
modules : llvm_modules,
1652
optional_modules : llvm_optional_modules,
1653
required : (
1654
with_amd_vk or with_gallium_radeonsi or with_gallium_swr or
1655
with_gallium_opencl or with_microsoft_clc or _llvm == 'enabled'
1656
),
1657
static : not _shared_llvm,
1658
method : _llvm_method,
1659
fallback : ['llvm', 'dep_llvm'],
1660
include_type : 'system',
1661
)
1662
with_llvm = dep_llvm.found()
1663
endif
1664
if with_llvm
1665
pre_args += '-DLLVM_AVAILABLE'
1666
pre_args += '-DMESA_LLVM_VERSION_STRING="@0@"'.format(dep_llvm.version())
1667
pre_args += '-DLLVM_IS_SHARED=@0@'.format(_shared_llvm.to_int())
1668
1669
if draw_with_llvm
1670
pre_args += '-DDRAW_LLVM_AVAILABLE'
1671
elif with_swrast_vk
1672
error('Lavapipe requires LLVM draw support.')
1673
elif with_gallium_swr
1674
error('SWR requires LLVM draw support.')
1675
endif
1676
1677
# LLVM can be built without rtti, turning off rtti changes the ABI of C++
1678
# programs, so we need to build all C++ code in mesa without rtti as well to
1679
# ensure that linking works.
1680
#
1681
# In meson 0.51.0 we can use cmake to find LLVM in addittion to meson's
1682
# builtin llvm-config based finder. A new generic variable getter method
1683
# has also been added, so we'll use that if we can, to cover the cmake case.
1684
if dep_llvm.type_name() == 'internal'
1685
_rtti = subproject('llvm').get_variable('has_rtti', true)
1686
else
1687
# The CMake finder will return 'ON', the llvm-config will return 'YES'
1688
_rtti = ['ON', 'YES'].contains(dep_llvm.get_variable(cmake : 'LLVM_ENABLE_RTTI', configtool: 'has-rtti'))
1689
endif
1690
if not _rtti
1691
if with_gallium_opencl
1692
error('The Clover OpenCL state tracker requires rtti, you need to turn off clover or use an LLVM built with LLVM_ENABLE_RTTI.')
1693
endif
1694
if cc.get_id() == 'msvc'
1695
cpp_args += '/GR-'
1696
else
1697
cpp_args += '-fno-rtti'
1698
endif
1699
endif
1700
1701
if cc.get_id() == 'msvc'
1702
# Suppress "/DELAYLOAD:ole32.dll/shell32.dll ignored" warnings that LLVM adds
1703
add_project_link_arguments(
1704
'/ignore:4199',
1705
language : ['c', 'cpp'],
1706
)
1707
endif
1708
elif with_amd_vk or with_gallium_radeonsi or with_gallium_swr or with_swrast_vk
1709
error('The following drivers require LLVM: Radv, RadeonSI, SWR, Lavapipe. One of these is enabled, but LLVM is disabled.')
1710
elif with_gallium_opencl
1711
error('The OpenCL "Clover" state tracker requires LLVM, but LLVM is disabled.')
1712
elif with_microsoft_clc
1713
error('The Microsoft CLC compiler requires LLVM, but LLVM is disabled.')
1714
else
1715
draw_with_llvm = false
1716
endif
1717
1718
with_opencl_spirv = (_opencl != 'disabled' and get_option('opencl-spirv')) or with_microsoft_clc
1719
if with_opencl_spirv
1720
chosen_llvm_version_array = dep_llvm.version().split('.')
1721
chosen_llvm_version_major = chosen_llvm_version_array[0].to_int()
1722
chosen_llvm_version_minor = chosen_llvm_version_array[1].to_int()
1723
1724
# Require an SPIRV-LLVM-Translator version compatible with the chosen LLVM
1725
# one.
1726
_llvmspirvlib_version = [
1727
# This first version check is still needed as maybe LLVM 8.0 was picked but
1728
# we do not want to accept SPIRV-LLVM-Translator 8.0.0.1 as that version does
1729
# not have the required API and those are only available starting from
1730
# 8.0.1.3.
1731
'>= 8.0.1.3',
1732
'>= @0@.@1@'.format(chosen_llvm_version_major, chosen_llvm_version_minor),
1733
'< @0@.@1@'.format(chosen_llvm_version_major, chosen_llvm_version_minor + 1) ]
1734
1735
dep_spirv_tools = dependency('SPIRV-Tools', required : true, version : '>= 2018.0')
1736
# LLVMSPIRVLib is available at https://github.com/KhronosGroup/SPIRV-LLVM-Translator
1737
dep_llvmspirvlib = dependency('LLVMSPIRVLib', required : true, version : _llvmspirvlib_version)
1738
else
1739
dep_spirv_tools = null_dep
1740
dep_llvmspirvlib = null_dep
1741
endif
1742
1743
with_opencl_native = _opencl != 'disabled' and get_option('opencl-native')
1744
1745
if (with_amd_vk or with_gallium_radeonsi or
1746
(with_gallium_opencl and with_opencl_native) or
1747
(with_gallium_r600 and with_llvm))
1748
if with_platform_windows
1749
dep_elf = dependency('libelf', required : false, fallback : ['libelf', 'libelf_dep'])
1750
else
1751
dep_elf = dependency('libelf', required : false)
1752
endif
1753
if not dep_elf.found()
1754
dep_elf = cc.find_library('elf')
1755
endif
1756
else
1757
dep_elf = null_dep
1758
endif
1759
1760
dep_glvnd = null_dep
1761
if with_glvnd
1762
dep_glvnd = dependency('libglvnd', version : '>= 1.3.2')
1763
pre_args += '-DUSE_LIBGLVND=1'
1764
endif
1765
1766
_valgrind = get_option('valgrind')
1767
if _valgrind == 'true'
1768
_valgrind = 'enabled'
1769
warning('valgrind option "true" deprecated, please use "enabled" instead.')
1770
elif _valgrind == 'false'
1771
_valgrind = 'disabled'
1772
warning('valgrind option "false" deprecated, please use "disabled" instead.')
1773
endif
1774
if _valgrind != 'disabled'
1775
dep_valgrind = dependency('valgrind', required : _valgrind == 'enabled')
1776
if dep_valgrind.found()
1777
pre_args += '-DHAVE_VALGRIND'
1778
endif
1779
else
1780
dep_valgrind = null_dep
1781
endif
1782
1783
# AddressSanitizer's leak reports need all the symbols to be present at exit to
1784
# decode well, which runs afoul of our dlopen()/dlclose()ing of the DRI drivers.
1785
# Set a flag so we can skip the dlclose for asan builds.
1786
if ['address', 'address,undefined'].contains(get_option('b_sanitize'))
1787
asan_c_args = ['-DBUILT_WITH_ASAN=1']
1788
else
1789
asan_c_args = ['-DBUILT_WITH_ASAN=0']
1790
endif
1791
1792
yacc_is_bison = true
1793
1794
if build_machine.system() == 'windows'
1795
# Prefer the winflexbison versions, they're much easier to install and have
1796
# better windows support.
1797
1798
prog_flex = find_program('win_flex', required : false)
1799
if prog_flex.found()
1800
# windows compatibility (uses <io.h> instead of <unistd.h> and _isatty,
1801
# _fileno functions)
1802
prog_flex = [prog_flex, '--wincompat']
1803
if get_option('c_std') == 'c99'
1804
prog_flex += '-D__STDC_VERSION__=199901'
1805
endif
1806
else
1807
prog_flex = [find_program('flex', 'lex', required : with_any_opengl)]
1808
endif
1809
# Force flex to use const keyword in prototypes, as relies on __cplusplus or
1810
# __STDC__ macro to determine whether it's safe to use const keyword, but
1811
# MSVC only defines __STDC_VERSION__ for C11/C17.
1812
prog_flex += '-DYY_USE_CONST='
1813
1814
prog_flex_cpp = prog_flex
1815
if get_option('c_std') != 'c99'
1816
# Convince win_flex to use <inttypes.h> for C++ files
1817
prog_flex_cpp += '-D__STDC_VERSION__=199901'
1818
endif
1819
1820
prog_bison = find_program('win_bison', required : false)
1821
if not prog_bison.found()
1822
prog_bison = find_program('bison', 'yacc', required : with_any_opengl)
1823
endif
1824
else
1825
prog_bison = find_program('bison', required : false)
1826
1827
if not prog_bison.found()
1828
prog_bison = find_program('byacc', required : with_any_opengl)
1829
yacc_is_bison = false
1830
endif
1831
1832
# Disable deprecated keyword warnings, since we have to use them for
1833
# old-bison compat. See discussion in
1834
# https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2161
1835
if find_program('bison', required : false, version : '> 2.3').found()
1836
prog_bison = [prog_bison, '-Wno-deprecated']
1837
endif
1838
1839
prog_flex = find_program('flex', required : with_any_opengl)
1840
prog_flex_cpp = prog_flex
1841
endif
1842
1843
dep_selinux = null_dep
1844
if get_option('selinux')
1845
if get_option('execmem') != true
1846
warning('execmem option is disabled, selinux will not be able to use execmem.')
1847
endif
1848
dep_selinux = dependency('libselinux')
1849
pre_args += '-DMESA_SELINUX'
1850
endif
1851
1852
if get_option('execmem')
1853
pre_args += '-DMESA_EXECMEM'
1854
endif
1855
1856
_libunwind = get_option('libunwind')
1857
if _libunwind == 'true'
1858
_libunwind = 'enabled'
1859
warning('libunwind option "true" deprecated, please use "enabled" instead.')
1860
elif _libunwind == 'false'
1861
_libunwind = 'disabled'
1862
warning('libunwind option "false" deprecated, please use "disabled" instead.')
1863
endif
1864
if _libunwind != 'disabled' and not with_platform_android
1865
if host_machine.system() == 'darwin'
1866
dep_unwind = meson.get_compiler('c').find_library('System')
1867
else
1868
dep_unwind = dependency('libunwind', required : _libunwind == 'enabled')
1869
endif
1870
if dep_unwind.found()
1871
pre_args += '-DHAVE_LIBUNWIND'
1872
endif
1873
else
1874
dep_unwind = null_dep
1875
endif
1876
1877
if with_osmesa
1878
if not with_gallium_softpipe
1879
warning('OSMesa gallium requires gallium softpipe or llvmpipe.')
1880
endif
1881
if host_machine.system() == 'windows'
1882
osmesa_lib_name = 'osmesa'
1883
else
1884
osmesa_lib_name = 'OSMesa'
1885
endif
1886
osmesa_bits = get_option('osmesa-bits')
1887
if osmesa_bits != '8'
1888
if with_dri or with_glx != 'disabled'
1889
error('OSMesa bits must be 8 if building glx or dri based drivers')
1890
endif
1891
osmesa_lib_name = osmesa_lib_name + osmesa_bits
1892
pre_args += [
1893
'-DCHAN_BITS=@0@'.format(osmesa_bits), '-DDEFAULT_SOFTWARE_DEPTH_BITS=31'
1894
]
1895
endif
1896
endif
1897
1898
# TODO: symbol mangling
1899
1900
if with_platform_wayland
1901
dep_wl_scanner = dependency('wayland-scanner', native: true)
1902
prog_wl_scanner = find_program(dep_wl_scanner.get_pkgconfig_variable('wayland_scanner'))
1903
if dep_wl_scanner.version().version_compare('>= 1.15')
1904
wl_scanner_arg = 'private-code'
1905
else
1906
wl_scanner_arg = 'code'
1907
endif
1908
dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
1909
dep_wayland_client = dependency('wayland-client', version : '>=1.18')
1910
dep_wayland_server = dependency('wayland-server', version : '>=1.18')
1911
if with_egl
1912
dep_wayland_egl = dependency('wayland-egl-backend', version : '>= 3')
1913
dep_wayland_egl_headers = dep_wayland_egl.partial_dependency(compile_args : true)
1914
endif
1915
wayland_dmabuf_xml = join_paths(
1916
dep_wl_protocols.get_pkgconfig_variable('pkgdatadir'), 'unstable',
1917
'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml'
1918
)
1919
pre_args += ['-DHAVE_WAYLAND_PLATFORM', '-DWL_HIDE_DEPRECATED']
1920
endif
1921
1922
dep_x11 = null_dep
1923
dep_xext = null_dep
1924
dep_xfixes = null_dep
1925
dep_x11_xcb = null_dep
1926
dep_xcb = null_dep
1927
dep_xcb_glx = null_dep
1928
dep_xcb_dri2 = null_dep
1929
dep_xcb_dri3 = null_dep
1930
dep_dri2proto = null_dep
1931
dep_glproto = null_dep
1932
dep_xxf86vm = null_dep
1933
dep_xcb_dri3 = null_dep
1934
dep_xcb_present = null_dep
1935
dep_xcb_sync = null_dep
1936
dep_xcb_xfixes = null_dep
1937
dep_xshmfence = null_dep
1938
dep_xcb_xrandr = null_dep
1939
dep_xcb_shm = null_dep
1940
dep_xlib_xrandr = null_dep
1941
dep_openmp = null_dep
1942
1943
# Even if we find OpenMP, Gitlab CI fails to link with gcc/i386 and clang/anyarch.
1944
if host_machine.cpu_family() == 'x86_64' and cc.get_id() == 'gcc'
1945
dep_openmp = dependency('openmp', required : false)
1946
if dep_openmp.found()
1947
pre_args += ['-DHAVE_OPENMP']
1948
endif
1949
endif
1950
1951
if with_platform_x11 and host_machine.system() != 'darwin'
1952
if with_glx == 'xlib' or with_glx == 'gallium-xlib'
1953
dep_x11 = dependency('x11')
1954
dep_xext = dependency('xext')
1955
dep_xcb = dependency('xcb')
1956
elif with_glx == 'dri'
1957
dep_x11 = dependency('x11')
1958
dep_xext = dependency('xext')
1959
dep_xfixes = dependency('xfixes', version : '>= 2.0')
1960
dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
1961
dep_xcb_shm = dependency('xcb-shm')
1962
endif
1963
if (with_any_vk or with_glx == 'dri' or with_egl or
1964
(with_gallium_vdpau or with_gallium_xvmc or with_gallium_va or
1965
with_gallium_omx != 'disabled'))
1966
dep_xcb = dependency('xcb')
1967
dep_x11_xcb = dependency('x11-xcb')
1968
if with_dri_platform == 'drm' and not dep_libdrm.found()
1969
error('libdrm required for gallium video statetrackers when using x11')
1970
endif
1971
endif
1972
if with_any_vk or with_egl or (with_glx == 'dri' and with_dri_platform == 'drm')
1973
dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
1974
1975
if with_dri3
1976
pre_args += '-DHAVE_DRI3'
1977
dep_xcb_dri3 = dependency('xcb-dri3')
1978
dep_xcb_present = dependency('xcb-present')
1979
# until xcb-dri3 has been around long enough to make a hard-dependency:
1980
if (dep_xcb_dri3.version().version_compare('>= 1.13') and
1981
dep_xcb_present.version().version_compare('>= 1.13'))
1982
pre_args += '-DHAVE_DRI3_MODIFIERS'
1983
endif
1984
dep_xcb_sync = dependency('xcb-sync')
1985
dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
1986
endif
1987
endif
1988
if with_glx == 'dri' or with_glx == 'gallium-xlib'
1989
dep_glproto = dependency('glproto', version : '>= 1.4.14')
1990
endif
1991
if with_glx == 'dri'
1992
if with_dri_platform == 'drm'
1993
dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
1994
if with_glx_direct
1995
dep_xxf86vm = dependency('xxf86vm')
1996
endif
1997
endif
1998
endif
1999
if (with_egl or
2000
with_dri3 or (
2001
with_gallium_vdpau or with_gallium_xvmc or with_gallium_xa or
2002
with_gallium_omx != 'disabled'))
2003
dep_xcb_xfixes = dependency('xcb-xfixes')
2004
endif
2005
if with_xlib_lease or with_any_vk
2006
dep_xcb_xrandr = dependency('xcb-randr')
2007
endif
2008
if with_xlib_lease
2009
dep_xlib_xrandr = dependency('xrandr', version : '>= 1.3')
2010
endif
2011
endif
2012
2013
if get_option('gallium-extra-hud')
2014
pre_args += '-DHAVE_GALLIUM_EXTRA_HUD=1'
2015
endif
2016
2017
_sensors = get_option('lmsensors')
2018
if _sensors == 'true'
2019
_sensors = 'enabled'
2020
warning('lmsensors option "true" deprecated, please use "enabled" instead.')
2021
elif _sensors == 'false'
2022
_sensors = 'disabled'
2023
warning('lmsensors option "false" deprecated, please use "disabled" instead.')
2024
endif
2025
if _sensors != 'disabled'
2026
dep_lmsensors = cc.find_library('sensors', required : _sensors == 'enabled')
2027
if dep_lmsensors.found()
2028
pre_args += '-DHAVE_LIBSENSORS=1'
2029
endif
2030
else
2031
dep_lmsensors = null_dep
2032
endif
2033
2034
_shader_replacement = get_option('custom-shader-replacement')
2035
if _shader_replacement == ''
2036
else
2037
pre_args += '-DCUSTOM_SHADER_REPLACEMENT'
2038
endif
2039
2040
with_perfetto = get_option('perfetto')
2041
with_datasources = get_option('datasources')
2042
with_any_datasource = with_datasources.length() != 0
2043
if with_perfetto
2044
dep_perfetto = dependency('perfetto', fallback: ['perfetto', 'dep_perfetto'])
2045
pre_args += '-DHAVE_PERFETTO'
2046
endif
2047
2048
# If the compiler supports it, put function and data symbols in their
2049
# own sections and GC the sections after linking. This lets drivers
2050
# drop shared code unused by that specific driver (particularly
2051
# relevant for Vulkan drivers).
2052
if cc.has_link_argument('-Wl,--gc-sections')
2053
foreach a: ['-ffunction-sections', '-fdata-sections']
2054
if cc.has_argument(a)
2055
add_project_arguments(a, language : ['c', 'cpp'])
2056
endif
2057
endforeach
2058
endif
2059
2060
foreach a : pre_args
2061
add_project_arguments(a, language : ['c', 'cpp'])
2062
endforeach
2063
foreach a : c_args
2064
add_project_arguments(a, language : ['c'])
2065
endforeach
2066
foreach a : cpp_args
2067
add_project_arguments(a, language : ['cpp'])
2068
endforeach
2069
2070
gl_priv_reqs = []
2071
2072
if with_glx == 'xlib' or with_glx == 'gallium-xlib'
2073
gl_priv_reqs += ['x11', 'xext', 'xcb']
2074
elif with_glx == 'dri'
2075
gl_priv_reqs += [
2076
'x11', 'xext', 'xfixes', 'x11-xcb', 'xcb',
2077
'xcb-glx >= 1.8.1']
2078
if with_dri_platform == 'drm'
2079
gl_priv_reqs += 'xcb-dri2 >= 1.8'
2080
if with_glx_direct
2081
gl_priv_reqs += 'xxf86vm'
2082
endif
2083
endif
2084
endif
2085
if dep_libdrm.found()
2086
gl_priv_reqs += 'libdrm >= 2.4.75'
2087
endif
2088
2089
gl_priv_libs = []
2090
if dep_thread.found()
2091
gl_priv_libs += ['-lpthread', '-pthread']
2092
endif
2093
if dep_m.found()
2094
gl_priv_libs += '-lm'
2095
endif
2096
if dep_dl.found()
2097
gl_priv_libs += '-ldl'
2098
endif
2099
2100
# FIXME: autotools lists this as incomplete
2101
gbm_priv_libs = []
2102
if dep_dl.found()
2103
gbm_priv_libs += '-ldl'
2104
endif
2105
2106
pkg = import('pkgconfig')
2107
2108
if host_machine.system() == 'windows'
2109
prog_dumpbin = find_program('dumpbin', required : false)
2110
with_symbols_check = prog_dumpbin.found() and with_tests
2111
if with_symbols_check
2112
symbols_check_args = ['--dumpbin', prog_dumpbin.path()]
2113
endif
2114
else
2115
prog_nm = find_program('nm')
2116
with_symbols_check = with_tests
2117
symbols_check_args = ['--nm', prog_nm.path()]
2118
endif
2119
2120
# This quirk needs to be applied to sources with functions defined in assembly
2121
# as GCC LTO drops them. See: https://bugs.freedesktop.org/show_bug.cgi?id=109391
2122
gcc_lto_quirk = (cc.get_id() == 'gcc') ? ['-fno-lto'] : []
2123
2124
subdir('include')
2125
subdir('bin')
2126
subdir('src')
2127
2128
# Meson 0.49 and earlier seems to have a bug that fails to evaluate the string-
2129
# formatting below unless the first argument is passed as a variable. This has
2130
# been fixed in Meson 0.50 and beyond, but we need to keep it like this for now
2131
# for backwards compatibility.
2132
_with_opengl_string = with_opengl ? 'yes' : 'no'
2133
2134
lines = ['',
2135
'prefix: ' + get_option('prefix'),
2136
'libdir: ' + get_option('libdir'),
2137
'includedir: ' + get_option('includedir'),
2138
'',
2139
'OpenGL: @0@ (ES1: @1@ ES2: @2@)'.format(_with_opengl_string,
2140
with_gles1 ? 'yes' : 'no',
2141
with_gles2 ? 'yes' : 'no'),
2142
]
2143
2144
if with_osmesa
2145
lines += ''
2146
lines += 'OSMesa: lib' + osmesa_lib_name
2147
else
2148
lines += 'OSMesa: no'
2149
endif
2150
2151
if with_dri
2152
lines += ''
2153
lines += 'DRI platform: ' + with_dri_platform
2154
if dri_drivers.length() != 0 and dri_drivers != ['']
2155
lines += 'DRI drivers: ' + ' '.join(dri_drivers)
2156
else
2157
lines += 'DRI drivers: no'
2158
endif
2159
lines += 'DRI driver dir: ' + dri_drivers_path
2160
endif
2161
2162
if with_glx != 'disabled'
2163
lines += ''
2164
if with_glx == 'dri'
2165
lines += 'GLX: DRI-based'
2166
elif with_glx == 'xlib'
2167
lines += 'GLX: Xlib-based'
2168
elif with_glx == 'gallium-xlib'
2169
lines += 'GLX: Xlib-based (Gallium)'
2170
else
2171
lines += 'GLX: ' + with_glx
2172
endif
2173
endif
2174
2175
lines += ''
2176
lines += 'EGL: ' + (with_egl ? 'yes' : 'no')
2177
if with_egl
2178
egl_drivers = []
2179
if with_dri
2180
egl_drivers += 'builtin:egl_dri2'
2181
endif
2182
if with_dri3
2183
egl_drivers += 'builtin:egl_dri3'
2184
endif
2185
lines += 'EGL drivers: ' + ' '.join(egl_drivers)
2186
endif
2187
if with_egl or with_any_vk
2188
_platforms += 'surfaceless'
2189
if with_gbm and not with_platform_android
2190
_platforms += 'drm'
2191
endif
2192
lines += 'EGL/Vulkan/VL platforms: ' + ' '.join(_platforms)
2193
endif
2194
lines += 'GBM: ' + (with_gbm ? 'yes' : 'no')
2195
if with_gbm
2196
lines += 'GBM backends path: ' + gbm_backends_path
2197
endif
2198
2199
lines += ''
2200
if with_any_vk
2201
lines += 'Vulkan drivers: ' + ' '.join(_vulkan_drivers)
2202
lines += 'Vulkan ICD dir: ' + with_vulkan_icd_dir
2203
if with_any_vulkan_layers
2204
lines += 'Vulkan layers: ' + ' '.join(get_option('vulkan-layers'))
2205
endif
2206
else
2207
lines += 'Vulkan drivers: no'
2208
endif
2209
2210
lines += ''
2211
if with_llvm
2212
lines += 'llvm: yes'
2213
lines += 'llvm-version: ' + dep_llvm.version()
2214
else
2215
lines += 'llvm: no'
2216
endif
2217
2218
lines += ''
2219
if with_gallium
2220
lines += 'Gallium drivers: ' + ' '.join(gallium_drivers)
2221
gallium_st = ['mesa']
2222
if with_gallium_xa
2223
gallium_st += 'xa'
2224
endif
2225
if with_gallium_xvmc
2226
gallium_st += 'xvmc'
2227
endif
2228
if with_gallium_vdpau
2229
gallium_st += 'vdpau'
2230
endif
2231
if with_gallium_omx != 'disabled'
2232
gallium_st += 'omx' + with_gallium_omx
2233
endif
2234
if with_gallium_va
2235
gallium_st += 'va'
2236
endif
2237
if with_gallium_st_nine
2238
gallium_st += 'nine'
2239
endif
2240
if with_gallium_opencl
2241
gallium_st += 'clover'
2242
endif
2243
lines += 'Gallium st: ' + ' '.join(gallium_st)
2244
else
2245
lines += 'Gallium: no'
2246
endif
2247
2248
lines += 'HUD lmsensors: ' + (dep_lmsensors.found() ? 'yes' : 'no')
2249
2250
lines += ''
2251
lines += 'Shared-glapi: ' + (with_shared_glapi ? 'yes' : 'no')
2252
2253
lines += ''
2254
lines += 'Perfetto: ' + (with_perfetto ? 'yes' : 'no')
2255
if with_any_datasource
2256
lines += 'Perfetto ds: ' + ' '.join(with_datasources)
2257
endif
2258
2259
2260
indent = ' '
2261
summary = indent + ('\n' + indent).join(lines)
2262
message('Configuration summary:\n@0@\n'.format(summary))
2263
2264