$OpenBSD: patch-meson_build,v 1.11 2021/12/02 21:08:54 ajacoutot Exp $

-fexceptions:
ld: error: undefined symbol: _Unwind_Resume

Should match b_lundef in meson(1).

Index: meson.build
--- meson.build.orig
+++ meson.build
@@ -234,7 +234,6 @@ array_bounds = get_option('b_sanitize') == 'none' ? 2 
 
 cc_flags += [
   '-fasynchronous-unwind-tables',
-  '-fexceptions',
   '-fipa-pure-const',
   '-fno-common',
   '-Wabsolute-value',
@@ -497,11 +496,6 @@ libvirt_nodelete = cc.get_supported_link_arguments([
 ])
 
 libvirt_no_undefined = []
-if get_option('b_sanitize') == 'none'
-  libvirt_no_undefined += cc.get_supported_link_arguments([
-    '-Wl,-z,defs',
-  ])
-endif
 
 libvirt_no_indirect = cc.get_supported_link_arguments([
   '-Wl,--no-copy-dt-needed-entries',
@@ -890,7 +884,7 @@ if host_machine.system() == 'windows'
   xdr_dep = cc.find_library('portablexdr', required: false)
 elif host_machine.system() == 'linux'
   xdr_dep = dependency('libtirpc', required: false)
-elif host_machine.system() in [ 'freebsd', 'darwin' ]
+elif host_machine.system() in [ 'freebsd', 'darwin', 'openbsd' ]
   xdr_dep = cc.find_library('c', required: false)
 else
   xdr_dep = dependency('', required: false)
@@ -979,15 +973,18 @@ if devmapper_dep.found()
   conf.set('WITH_DEVMAPPER', 1)
 endif
 
-dlopen_use = host_machine.system() != 'windows'
-dlopen_dep = cc.find_library('dl', required: dlopen_use)
-if dlopen_dep.found()
-  if not cc.has_header('dlfcn.h')
-    error('Unable to find dlfcn.h')
-  endif
-  conf.set('WITH_DLFCN_H', 1)
-endif
+#dlopen_use = host_machine.system() != 'windows'
+#dlopen_dep = cc.find_library('dl', required: dlopen_use)
+#if dlopen_dep.found()
+#  if not cc.has_header('dlfcn.h')
+#    error('Unable to find dlfcn.h')
+#  endif
+#  conf.set('WITH_DLFCN_H', 1)
+#endif
 
+dlopen_dep = []
+conf.set('WITH_DLFCN_H', 1)
+
 fuse_version = '2.8.6'
 fuse_dep = dependency('fuse', version: '>=' + fuse_version, required: get_option('fuse'))
 if fuse_dep.found()
@@ -2005,7 +2002,7 @@ endif
 
 driver_modules_flags = []
 if conf.has('WITH_LIBVIRTD')
-  if not conf.has('WITH_DLFCN_H') or not dlopen_dep.found()
+  if not conf.has('WITH_DLFCN_H') #or not dlopen_dep.found()
     error('You must have dlfcn.h / dlopen() support to build driver modules')
   endif
   driver_modules_flags = libvirt_export_dynamic
@@ -2340,7 +2337,7 @@ libs_summary = {
   'capng': capng_dep.found(),
   'curl': curl_dep.found(),
   'devmapper': devmapper_dep.found(),
-  'dlopen': dlopen_dep.found(),
+#  'dlopen': dlopen_dep.found(),
   'fuse': fuse_dep.found(),
   'glusterfs': glusterfs_dep.found(),
   'libiscsi': libiscsi_dep.found(),
