meson: bump required glvnd version
[mesa.git] / meson.build
index 8d89bf9781ef64f4888f54f527a1c226f663e810..c76748b7162890ecbee54a1bec36935fde9caaf4 100644 (file)
@@ -51,6 +51,7 @@ pre_args = [
 
 with_vulkan_icd_dir = get_option('vulkan-icd-dir')
 with_tests = get_option('build-tests')
+with_aco_tests = get_option('build-aco-tests')
 with_glx_read_only_text = get_option('glx-read-only-text')
 with_glx_direct = get_option('glx-direct')
 with_osmesa = get_option('osmesa')
@@ -181,7 +182,7 @@ with_dri_r200 = dri_drivers.contains('r200')
 with_dri_nouveau = dri_drivers.contains('nouveau')
 with_dri_swrast = dri_drivers.contains('swrast')
 
-with_dri = dri_drivers.length() != 0 and dri_drivers != ['']
+with_dri = dri_drivers.length() != 0
 
 gallium_drivers = get_option('gallium-drivers')
 if gallium_drivers.contains('auto')
@@ -228,7 +229,7 @@ with_gallium_swr = gallium_drivers.contains('swr')
 with_gallium_lima = gallium_drivers.contains('lima')
 with_gallium_zink = gallium_drivers.contains('zink')
 
-with_gallium = gallium_drivers.length() != 0 and gallium_drivers != ['']
+with_gallium = gallium_drivers.length() != 0
 
 if with_gallium and system_has_kms_drm
   _glx = get_option('glx')
@@ -261,7 +262,7 @@ endif
 with_intel_vk = _vulkan_drivers.contains('intel')
 with_amd_vk = _vulkan_drivers.contains('amd')
 with_freedreno_vk = _vulkan_drivers.contains('freedreno')
-with_any_vk = _vulkan_drivers.length() != 0 and _vulkan_drivers != ['']
+with_any_vk = _vulkan_drivers.length() != 0
 
 if with_dri_swrast and (with_gallium_softpipe or with_gallium_swr)
   error('Only one swrast provider can be built')
@@ -275,6 +276,9 @@ endif
 if with_gallium_tegra and not with_gallium_nouveau
   error('tegra driver requires nouveau driver')
 endif
+if with_aco_tests and not with_amd_vk
+  error('ACO tests require Radv')
+endif
 
 if host_machine.system() == 'darwin'
   with_dri_platform = 'apple'
@@ -293,9 +297,9 @@ endif
 _platforms = get_option('platforms')
 if _platforms.contains('auto')
   if system_has_kms_drm
-    _platforms = ['x11', 'wayland', 'drm', 'surfaceless']
+    _platforms = ['x11', 'wayland']
   elif ['darwin', 'cygwin'].contains(host_machine.system())
-    _platforms = ['x11', 'surfaceless']
+    _platforms = ['x11']
   elif ['haiku'].contains(host_machine.system())
     _platforms = ['haiku']
   elif host_machine.system() == 'windows'
@@ -309,33 +313,21 @@ endif
 with_platform_android = _platforms.contains('android')
 with_platform_x11 = _platforms.contains('x11')
 with_platform_wayland = _platforms.contains('wayland')
-with_platform_drm = _platforms.contains('drm')
 with_platform_haiku = _platforms.contains('haiku')
-with_platform_surfaceless = _platforms.contains('surfaceless')
 with_platform_windows = _platforms.contains('windows')
 
-with_platforms = false
-if _platforms.length() != 0 and _platforms != ['']
-  # sanity check that list contains no empty strings
-  if _platforms.contains('')
-    error('Invalid argument list given to -Dplatforms, please fix.')
-  endif
-  with_platforms = true
-  egl_native_platform = _platforms[0]
+if _platforms.contains('surfaceless')
+  warning('Platform `surfaceless` is now always selected; setting this option will be an error in Mesa 20.3')
 endif
 
-_xlib_lease = get_option('xlib-lease')
-if _xlib_lease == 'true'
-  _xlib_lease = 'enabled'
-  warning('xlib_lease option "true" deprecated, please use "enabled" instead.')
-elif _xlib_lease == 'false'
-  _xlib_lease = 'disabled'
-  warning('xlib_lease option "false" deprecated, please use "disabled" instead.')
+if _platforms.contains('drm')
+  warning('Platform `drm` is now automatically selected; setting this option will be an error in Mesa 20.3')
 endif
-if _xlib_lease == 'auto'
-  with_xlib_lease = with_platform_x11 and with_platform_drm
+
+if _platforms.length() != 0
+  egl_native_platform = _platforms[0]
 else
-  with_xlib_lease = _xlib_lease == 'enabled'
+  egl_native_platform = 'surfaceless'
 endif
 
 with_glx = get_option('glx')
@@ -388,6 +380,20 @@ if with_gbm and not system_has_kms_drm
   error('GBM only supports DRM/KMS platforms')
 endif
 
+_xlib_lease = get_option('xlib-lease')
+if _xlib_lease == 'true'
+  _xlib_lease = 'enabled'
+  warning('xlib_lease option "true" deprecated, please use "enabled" instead.')
+elif _xlib_lease == 'false'
+  _xlib_lease = 'disabled'
+  warning('xlib_lease option "false" deprecated, please use "disabled" instead.')
+endif
+if _xlib_lease == 'auto'
+  with_xlib_lease = with_platform_x11 and system_has_kms_drm
+else
+  with_xlib_lease = _xlib_lease == 'enabled'
+endif
+
 _egl = get_option('egl')
 if _egl == 'true'
   _egl = 'enabled'
@@ -399,15 +405,13 @@ endif
 if _egl == 'auto'
   with_egl = (
     not ['darwin', 'windows'].contains(host_machine.system()) and
-    with_dri and with_shared_glapi and with_platforms
+    with_dri and with_shared_glapi
   )
 elif _egl == 'enabled'
   if not with_dri
     error('EGL requires dri')
   elif not with_shared_glapi
     error('EGL requires shared-glapi')
-  elif not with_platforms
-    error('No platforms specified, consider -Dplatforms=drm,x11,surfaceless at least')
   elif not ['disabled', 'dri'].contains(with_glx)
     error('EGL requires dri, but a GLX is being built without dri')
   elif ['darwin', 'windows'].contains(host_machine.system())
@@ -418,17 +422,8 @@ else
   with_egl = false
 endif
 
-if with_egl and not (with_platform_drm or with_platform_surfaceless or with_platform_android)
-  if with_gallium_radeonsi
-    error('RadeonSI requires the drm, surfaceless or android platform when using EGL')
-  endif
-  if with_gallium_virgl
-    error('Virgl requires the drm, surfaceless or android platform when using EGL')
-  endif
-endif
-
 # Android uses emutls for versions <= P/28. For USE_ELF_TLS we need ELF TLS.
-if host_machine.system() != 'windows' and (not with_platform_android or get_option('platform-sdk-version') >= 29)
+if not ['windows', 'freebsd'].contains(host_machine.system()) and (not with_platform_android or get_option('platform-sdk-version') >= 29)
   pre_args += '-DUSE_ELF_TLS'
 endif
 
@@ -548,6 +543,10 @@ if with_gallium_zink
   dep_vulkan = dependency('vulkan')
 endif
 
+if with_vulkan_overlay_layer or with_aco_tests
+  prog_glslang = find_program('glslangValidator')
+endif
+
 _xvmc = get_option('gallium-xvmc')
 if _xvmc == 'true'
   _xvmc = 'enabled'
@@ -783,7 +782,6 @@ if _power8 != 'disabled'
 endif
 
 _opencl = get_option('gallium-opencl')
-clover_cpp_std = []
 if _opencl != 'disabled'
   if not with_gallium
     error('OpenCL Clover implementation requires at least one gallium driver.')
@@ -802,14 +800,6 @@ if _opencl != 'disabled'
     dep_spirv_tools = null_dep
     dep_llvmspirvlib = null_dep
   endif
-
-  if host_machine.cpu_family().startswith('ppc') and cpp.compiles('''
-      #if !defined(__VEC__) || !defined(__ALTIVEC__)
-      #error "AltiVec not enabled"
-      #endif''',
-      name : 'Altivec')
-    clover_cpp_std += ['cpp_std=gnu++11']
-  endif
 else
   dep_clc = null_dep
   dep_spirv_tools = null_dep
@@ -843,28 +833,32 @@ else
   pre_args += '-DEGL_NO_X11'
   gl_pkgconfig_c_flags += '-DEGL_NO_X11'
 endif
-if with_platform_drm
-  if with_egl and not with_gbm
-    error('EGL drm platform requires gbm')
-  endif
+if with_gbm
   pre_args += '-DHAVE_DRM_PLATFORM'
 endif
-if with_platform_surfaceless
-  pre_args += '-DHAVE_SURFACELESS_PLATFORM'
+
+with_android_stub = get_option('android-stub')
+if with_android_stub and not with_platform_android
+  error('`-D android-stub=true` makes no sense without `-D platforms=android`')
 endif
+
 if with_platform_android
-  dep_android = [
-    dependency('cutils'),
-    dependency('hardware'),
-    dependency('sync'),
-  ]
-  if with_gallium
-    dep_android += dependency('backtrace')
-  endif
-  if get_option('platform-sdk-version') >= 26
-    dep_android += dependency('nativewindow')
+  if not with_android_stub
+    dep_android = [
+      dependency('cutils'),
+      dependency('hardware'),
+      dependency('sync'),
+      dependency('backtrace')
+    ]
+    if get_option('platform-sdk-version') >= 26
+      dep_android += dependency('nativewindow')
+    endif
   endif
-  pre_args += '-DHAVE_ANDROID_PLATFORM'
+  pre_args += [
+    '-DHAVE_ANDROID_PLATFORM',
+    '-DANDROID',
+    '-DANDROID_API_LEVEL=' + get_option('platform-sdk-version').to_string()
+  ]
 endif
 if with_platform_haiku
   pre_args += '-DHAVE_HAIKU_PLATFORM'
@@ -915,9 +909,6 @@ if _shader_cache != 'disabled'
     with_shader_cache = true
   endif
 endif
-if with_amd_vk and not with_shader_cache
-  error('Radv requires shader cache support')
-endif
 
 # Check for GCC style builtins
 foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
@@ -1009,6 +1000,7 @@ else
     '-Werror=empty-body',
     '-Werror=incompatible-pointer-types',
     '-Werror=int-conversion',
+    '-Wimplicit-fallthrough',
     '-Wno-missing-field-initializers',
     '-Wno-format-truncation',
     '-fno-math-errno',
@@ -1208,7 +1200,14 @@ if (cc.has_header_symbol('sys/mkdev.h', 'major') and
   pre_args += '-DMAJOR_IN_MKDEV'
 endif
 
-foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'execinfo.h', 'sys/shm.h', 'cet.h']
+if not ['linux'].contains(host_machine.system())
+  # Deprecated on Linux and requires <sys/types.h> on FreeBSD and OpenBSD
+  if cc.check_header('sys/sysctl.h', prefix : '#include <sys/types.h>')
+    pre_args += '-DHAVE_SYS_SYSCTL_H'
+  endif
+endif
+
+foreach h : ['xlocale.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'execinfo.h', 'sys/shm.h', 'cet.h']
   if cc.check_header(h)
     pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
   endif
@@ -1374,7 +1373,7 @@ dep_libdrm_intel = null_dep
 
 _drm_amdgpu_ver = '2.4.100'
 _drm_radeon_ver = '2.4.71'
-_drm_nouveau_ver = '2.4.66'
+_drm_nouveau_ver = '2.4.102'
 _drm_intel_ver = '2.4.75'
 _drm_ver = '2.4.81'
 
@@ -1554,7 +1553,7 @@ endif
 
 dep_glvnd = null_dep
 if with_glvnd
-  dep_glvnd = dependency('libglvnd', version : '>= 1.2.0')
+  dep_glvnd = dependency('libglvnd', version : '>= 1.3.2')
   pre_args += '-DUSE_LIBGLVND=1'
 endif
 
@@ -1776,6 +1775,19 @@ else
   dep_lmsensors = null_dep
 endif
 
+# If the compiler supports it, put function and data symbols in their
+# own sections and GC the sections after linking.  This lets drivers
+# drop shared code unused by that specific driver (particularly
+# relevant for Vulkan drivers).
+if cc.has_link_argument('-Wl,--gc-sections')
+  add_project_arguments('-Wl,--gc-sections', language : ['c', 'cpp'])
+  foreach a: ['-ffunction-sections', '-fdata-sections']
+    if cc.has_argument(a)
+      add_project_arguments(a, language : ['c', 'cpp'])
+    endif
+  endforeach
+endif
+
 foreach a : pre_args
   add_project_arguments(a, language : ['c', 'cpp'])
 endforeach
@@ -1898,7 +1910,11 @@ if with_egl
   lines += 'EGL drivers:     ' + ' '.join(egl_drivers)
 endif
 lines += 'GBM:             ' + (with_gbm ? 'yes' : 'no')
-if with_platforms
+if with_egl or with_any_vk
+  _platforms += 'surfaceless'
+  if with_gbm
+    _platforms += 'drm'
+  endif
   lines += 'EGL/Vulkan/VL platforms:   ' + ' '.join(_platforms)
 endif