To expose the CMSG_ macros and new recvmsg() semantics, the socket module
needs to be built in an XPG6 environment.

diff -wpruN '--exclude=*.orig' a~/setup.py a/setup.py
--- a~/setup.py	1970-01-01 00:00:00
+++ a/setup.py	1970-01-01 00:00:00
@@ -1156,6 +1156,10 @@ class PyBuildExt(build_ext):
             if MACOS:
                 # Issue #35569: Expose RFC 3542 socket options.
                 kwargs['extra_compile_args'] = ['-D__APPLE_USE_RFC_3542']
+            if ILLUMOS:
+                kwargs['libraries'] = ['socket', 'nsl']
+                kwargs['extra_compile_args'] = ['-D_XOPEN_SOURCE=600',
+                    '-D__EXTENSIONS__=1']
 
             self.add(Extension('_socket', ['socketmodule.c'], **kwargs))
         elif self.compiler.find_library_file(self.lib_dirs, 'net'):