From: Alan Coopersmith Date: Tue, 12 Aug 2025 22:00:14 +0000 (-0700) Subject: build: test to see which -D flags are needed on Solaris & illumos X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6cda1e82a1c9900763ca04a2a6d884c42659597b;p=thirdparty%2Fdbus.git build: test to see which -D flags are needed on Solaris & illumos Instead of hardcoding these as always needed, test to see, since they're not needed on Solaris 11.4, but are on older versions & illumos. Signed-off-by: Alan Coopersmith --- diff --git a/meson.build b/meson.build index 3ce4de45d..bcac03702 100644 --- a/meson.build +++ b/meson.build @@ -177,14 +177,30 @@ compile_args = [ compile_args += ['-fno-strict-aliasing'] if platform_sunos - compile_args += [ - # Solaris' C library apparently needs these runes to be threadsafe... - '-D_POSIX_PTHREAD_SEMANTICS', - # ... this opt-in to get sockaddr_in6 and sockaddr_storage... - '-D__EXTENSIONS__', - # ... and this opt-in to get file descriptor passing support - ' -D_XOPEN_SOURCE=500', - ] + # The headers on illumos systems and Solaris versions prior to 11.4.0 + # default to an early draft of the POSIX re-entrant functions that is + # not compatible with the final standard, and need a flag to enable the + # common standard versions of these functions. + pthread_check_code = '''#include + int func(const char *name, struct passwd *pwd, struct passwd **result) { + static char buffer[1024]; + return getpwnam_r(name, pwd, buffer, sizeof(buffer), result); + }''' + if not cc.compiles(pthread_check_code, name: 'sunos pthread check') + compile_args += [ '-D_POSIX_PTHREAD_SEMANTICS' ] + endif + # The headers on illumos systems and Solaris versions prior to 11.4.0 + # require an extra flag to expose POSIX file descriptor passing support. + if not cc.has_member('struct msghdr', 'msg_control', prefix: '#include ') + compile_args += [ '-D_XOPEN_SOURCE=600' ] + endif + # The standard headers on illumos & Solaris systems limit themselves to + # defining just the interfaces from the standard when _XOPEN_SOURCE or + # _POSIX_SOURCE are defined, unless __EXTENSIONS__ is also defined to + # allow defining non-standard extensions to the interfaces. + if not cc.has_function('clearenv', prefix: '#include ', args: compile_args) + compile_args += [ '-D__EXTENSIONS__' ] + endif endif dbus_static_flags = ( get_option('default_library') == 'static'