NetBSD Problem Report #56161

From www@netbsd.org  Sun May  9 17:16:04 2021
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 6669E1A9268
	for <gnats-bugs@gnats.NetBSD.org>; Sun,  9 May 2021 17:16:04 +0000 (UTC)
Message-Id: <20210509171602.EFA831A9269@mollari.NetBSD.org>
Date: Sun,  9 May 2021 17:16:02 +0000 (UTC)
From: pekdon@gmail.com
Reply-To: pekdon@gmail.com
To: gnats-bugs@NetBSD.org
Subject: python3.8 build issue on Solaris 10
X-Send-Pr-Version: www-1.0

>Number:         56161
>Category:       pkg
>Synopsis:       python3.8 build issue on Solaris 10
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun May 09 17:20:00 +0000 2021
>Closed-Date:    Fri Jan 21 08:35:50 +0000 2022
>Last-Modified:  Fri Jan 21 08:35:50 +0000 2022
>Originator:     Claes Nasten
>Release:        trunk 2021-05-09
>Organization:
>Environment:
SunOS u40 5.10 Generic_147148-26 i86pc i386 i86pc
>Description:
Building Python 3.8 on Solaris 10 x86_64 fails due to:

* Missing declaration of sethostname, fix for it on _AIX is in the source tree already but needed to be extended for Soalris < 11
* No 64bit -lcrypt available, link with -lcrypt_i if os is sunos5 and the library is available
>How-To-Repeat:
Build Python 3.8 on Solaris 10 x86_64.
>Fix:
diff --git a/lang/python38/distinfo b/lang/python38/distinfo
index b3b61961653..fe06649b21c 100644
--- a/lang/python38/distinfo
+++ b/lang/python38/distinfo
@@ -14,7 +14,7 @@ SHA1 (patch-Makefile.pre.in) = d42f9f5bca1dd663f64122dc95b49111452fe6e8
 SHA1 (patch-Modules_makesetup) = a06786eebffadecedba5e3a50a9785fb47613567
 SHA1 (patch-Modules_nismodule.c) = 1bafe9b06359586d027a77011b103877590d947d
 SHA1 (patch-Modules_posixmodule.c) = ea24a1aa19b596b5d4457a4eff761e516406145f
-SHA1 (patch-Modules_socketmodule.c) = e99fd9e30e3feafef1747a2f52446d8fec543362
+SHA1 (patch-Modules_socketmodule.c) = ee0045d464e64fa1ea45ab58a92789d47bb0f196
 SHA1 (patch-Modules_socketmodule.h) = 13a3290eb72078067060d3e71b7baa08f3eb591c
 SHA1 (patch-Modules_timemodule.c) = 10dc2769432bbfd4360f90fedfa6504d8b6f6347
 SHA1 (patch-Python_bootstrap__hash.c) = 2e7d24ded1369624b2983b15784988517a9697a5
@@ -22,4 +22,4 @@ SHA1 (patch-Python_pytime.c) = 41981f821e0b420abcb0334312148deb9a9fed5e
 SHA1 (patch-Python_thread__pthread.h) = fb81eaa604b4ed7c1b64c3f4731d58a8aee257be
 SHA1 (patch-configure) = 5607f103279127b4465294af1f9601a3c1e3e89e
 SHA1 (patch-pyconfig.h.in) = dc98ffe351623df2e8453e9350c30d705f4e99bd
-SHA1 (patch-setup.py) = 0b05bdc61289ee75758dcf8e422b988ff2067cba
+SHA1 (patch-setup.py) = 44fa9cfe506a391f714114d05d9924ad4f569a19
diff --git a/lang/python38/patches/patch-Modules_socketmodule.c b/lang/python38/patches/patch-Modules_socketmodule.c
index 8e26a079467..e57b4b4b9e3 100644
--- a/lang/python38/patches/patch-Modules_socketmodule.c
+++ b/lang/python38/patches/patch-Modules_socketmodule.c
@@ -4,6 +4,15 @@ Support NetBSD's socketcan implementation

 --- Modules/socketmodule.c.orig        2019-09-06 08:21:57.000000000 +0000
 +++ Modules/socketmodule.c
+@@ -5409,7 +5409,7 @@
+     Py_buffer buf;
+     int res, flag = 0;
+ 
+-#ifdef _AIX
++#if defined(_AIX) || (defined(__sun) && _POSIX_VERSION < 200809L)
+ /* issue #18259, not declared in any useful header file */
+ extern int sethostname(const char *, size_t);
+ #endif
 @@ -7709,6 +7709,20 @@ PyInit__socket(void)
      PyModule_AddIntConstant(m, "CAN_BCM_CAN_FD_FRAME", CAN_FD_FRAME);
  #endif
diff --git a/lang/python38/patches/patch-setup.py b/lang/python38/patches/patch-setup.py
index ed9ed9852de..13c4d7b23f3 100644
--- a/lang/python38/patches/patch-setup.py
+++ b/lang/python38/patches/patch-setup.py
@@ -80,6 +80,17 @@ $NetBSD: patch-setup.py,v 1.6 2021/05/04 05:16:07 adam Exp $
              self.add(Extension('_curses_panel', ['_curses_panel.c'],
                                 include_dirs=curses_includes,
                                 define_macros=curses_defines,
+@@ -1017,7 +1017,9 @@
+             # the encryption.
+             return
+ 
+-        if self.compiler.find_library_file(self.lib_dirs, 'crypt'):
++        if HOST_PLATFORM == 'sunos5' and self.compiler.find_library_file(self.lib_dirs, 'crypt_i'):
++            libs = ['crypt_i']
++        elif self.compiler.find_library_file(self.lib_dirs, 'crypt'):
+             libs = ['crypt']
+         else:
+             libs = []
 @@ -1248,6 +1248,31 @@ class PyBuildExt(build_ext):
          dbm_order = ['gdbm']
          # The standard Unix dbm module:

>Release-Note:

>Audit-Trail:
From: =?utf-8?q?Claes_N=C3=A4st=C3=A9n?= <pekdon@gmail.com>
To: gnats-bugs <gnats-bugs@netbsd.org>
Cc: 
Subject: Re: pkg/56161: python3.8 build issue on Solaris 10
Date: Wed, 24 Nov 2021 21:52:21 +0100

 --=-1637787141-163853-10393-2638-5-=
 Content-Type: text/plain; charset=UTF-8
 Content-Disposition: inline

 Excerpts from gnats-admin's message of 2021-05-09 17:20:00 +0000:
 > Thank you very much for your problem report.
 > It has the internal identification `pkg/56161'.
 > The individual assigned to look at your
 > report is: pkg-manager. 
 > 
 > >Category:       pkg
 > >Responsible:    pkg-manager
 > >Synopsis:       python3.8 build issue on Solaris 10
 > >Arrival-Date:   Sun May 09 17:20:00 +0000 2021

 Another approach, against 3.9, being a bit more restrictive avoiding any
 changes on more current Solarish variants.

 If this is acceptable I can provide patches for the Python versions in
 pkgsrc.


 --=-1637787141-163853-10393-2638-5-=
 Content-Disposition: attachment; filename="patch-Modules_socketmodule.c"
 Content-Type: text/plain; name="patch-Modules_socketmodule.c"
 Content-Transfer-Encoding: quoted-printable

 $NetBSD: patch-Modules_socketmodule.c,v 1.2 2021/05/22 11:36:01 bouyer Ex=
 p $

 Support NetBSD's socketcan implementation

 --- Modules/socketmodule.c.orig	2021-11-15 17:43:00.000000000 +0000
 +++ Modules/socketmodule.c
 @@ -2154,7 +2154,7 @@ getsockaddrarg(PySocketSockObject *s, Py
              PyObject *interfaceName;
              struct ifreq ifr;
              Py_ssize_t len;
 -            struct sockaddr_can *addr =3D &addrbuf->can;
 +            struct sockaddr_can *addr =3D (struct sockaddr_can *)addrbuf=
 ;
  =

              if (!PyTuple_Check(args)) {
                  PyErr_Format(PyExc_TypeError,
 @@ -5489,7 +5489,7 @@ socket_sethostname(PyObject *self, PyObj
      Py_buffer buf;
      int res, flag =3D 0;
  =

 -#ifdef _AIX
 +#if defined(_AIX) || defined(SOLARIS_PRE_11)
  /* issue #18259, not declared in any useful header file */
  extern int sethostname(const char *, size_t);
  #endif
 @@ -7824,6 +7824,20 @@ PyInit__socket(void)
  =

      PyModule_AddIntMacro(m, J1939_FILTER_MAX);
  #endif
 +#ifdef HAVE_NETCAN_CAN_H
 +    PyModule_AddIntMacro(m, CAN_EFF_FLAG);
 +    PyModule_AddIntMacro(m, CAN_RTR_FLAG);
 +    PyModule_AddIntMacro(m, CAN_ERR_FLAG);
 +
 +    PyModule_AddIntMacro(m, CAN_SFF_MASK);
 +    PyModule_AddIntMacro(m, CAN_EFF_MASK);
 +    PyModule_AddIntMacro(m, CAN_ERR_MASK);
 +
 +    PyModule_AddIntMacro(m, CAN_RAW_FILTER);
 +    /* PyModule_AddIntMacro(m, CAN_RAW_ERR_FILTER); */
 +    PyModule_AddIntMacro(m, CAN_RAW_LOOPBACK);
 +    PyModule_AddIntMacro(m, CAN_RAW_RECV_OWN_MSGS);
 +#endif
  #ifdef SOL_RDS
      PyModule_AddIntMacro(m, SOL_RDS);
  #endif

 --=-1637787141-163853-10393-2638-5-=
 Content-Disposition: attachment; filename="patch-setup.py"
 Content-Type: application/x-python; name="patch-setup.py"
 Content-Transfer-Encoding: 8bit

 $NetBSD: patch-setup.py,v 1.5 2021/11/06 12:24:35 adam Exp $

 Disable certain modules, so they can be built as separate packages.
 Do not look for ncursesw.
 Assume panel_library is correct; this is a fix for ncurses' gnupanel
 which will get transformed to panel in buildlink.

 --- setup.py.orig	2021-11-15 17:43:00.000000000 +0000
 +++ setup.py
 @@ -30,7 +30,7 @@ except ImportError:
      SUBPROCESS_BOOTSTRAP = True


 -from distutils import log
 +from distutils import log, text_file
  from distutils.command.build_ext import build_ext
  from distutils.command.build_scripts import build_scripts
  from distutils.command.install import install
 @@ -44,7 +44,7 @@ from distutils.spawn import find_executa
  TEST_EXTENSIONS = True

  # This global variable is used to hold the list of modules to be disabled.
 -DISABLED_MODULE_LIST = []
 +DISABLED_MODULE_LIST = ["_curses", "_curses_panel", "_elementtree", "_gdbm", "pyexpat", "readline", "_sqlite3", "_tkinter", "xxlimited"]


  def get_platform():
 @@ -65,7 +65,13 @@ CYGWIN = (HOST_PLATFORM == 'cygwin')
  MACOS = (HOST_PLATFORM == 'darwin')
  AIX = (HOST_PLATFORM.startswith('aix'))
  VXWORKS = ('vxworks' in HOST_PLATFORM)
 -
 +if HOST_PLATFORM == 'sunos5':
 +    # not using -o to check for variant here as -o is unsupported on
 +    # Solaris 10
 +    uname = sys.modules['subprocess'].check_output(['uname', '-r'])
 +    SOLARIS_PRE_11 = uname[:4] != '5.11'
 +else:
 +    SOLARIS_PRE_11 = False

  SUMMARY = """
  Python is an interpreted, interactive, object-oriented programming
 @@ -224,6 +230,16 @@ def grep_headers_for(function, headers):
                  return True
      return False

 +def grep_headers_for(function, headers):
 +    for header in headers:
 +        try:
 +            with open(header, 'r') as f:
 +                if function in f.read():
 +                    return True
 +        except UnicodeDecodeError:
 +            pass
 +    return False
 +
  def find_file(filename, std_dirs, paths):
      """Searches for the directory where a given file is located,
      and returns a possibly-empty list of additional directories, or None
 @@ -728,15 +744,15 @@ class PyBuildExt(build_ext):
                          add_dir_to_list(dir_list, directory)

      def configure_compiler(self):
 -        # Ensure that /usr/local is always used, but the local build
 -        # directories (i.e. '.' and 'Include') must be first.  See issue
 -        # 10520.
 -        if not CROSS_COMPILING:
 -            add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
 -            add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
 -        # only change this for cross builds for 3.3, issues on Mageia
 -        if CROSS_COMPILING:
 -            self.add_cross_compiling_paths()
 +        # Add the buildlink directories for pkgsrc
 +        if os.environ.get('BUILDLINK_DIR'):
 +            dir = os.environ['BUILDLINK_DIR']
 +            libdir = dir + '/lib'
 +            incdir = dir + '/include'
 +            if libdir not in self.compiler.library_dirs:
 +                self.compiler.library_dirs.insert(0, libdir)
 +            if incdir not in self.compiler.include_dirs:
 +                self.compiler.include_dirs.insert(0, incdir)
          self.add_multiarch_paths()
          self.add_ldflags_cppflags()

 @@ -784,6 +800,9 @@ class PyBuildExt(build_ext):
              self.lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32']

          if MACOS:
 +            self.inc_dirs.append(macosx_sdk_root() + '/usr/include')
 +            self.lib_dirs.append(macosx_sdk_root() + '/usr/lib')
 +
              # This should work on any unixy platform ;-)
              # If the user has bothered specifying additional -I and -L flags
              # in OPT and LDFLAGS we might as well use them here.
 @@ -1001,8 +1020,6 @@ class PyBuildExt(build_ext):
          # use the same library for the readline and curses modules.
          if 'curses' in readline_termcap_library:
              curses_library = readline_termcap_library
 -        elif self.compiler.find_library_file(self.lib_dirs, 'ncursesw'):
 -            curses_library = 'ncursesw'
          # Issue 36210: OSS provided ncurses does not link on AIX
          # Use IBM supplied 'curses' for successful build of _curses
          elif AIX and self.compiler.find_library_file(self.lib_dirs, 'curses'):
 @@ -1104,8 +1121,7 @@ class PyBuildExt(build_ext):
          # If the curses module is enabled, check for the panel module
          # _curses_panel needs some form of ncurses
          skip_curses_panel = True if AIX else False
 -        if (curses_enabled and not skip_curses_panel and
 -                self.compiler.find_library_file(self.lib_dirs, panel_library)):
 +        if curses_enabled and not skip_curses_panel:
              self.add(Extension('_curses_panel', ['_curses_panel.c'],
                             include_dirs=curses_includes,
                             define_macros=curses_defines,
 @@ -1121,7 +1137,9 @@ class PyBuildExt(build_ext):
              # the encryption.
              return

 -        if self.compiler.find_library_file(self.lib_dirs, 'crypt'):
 +        if SOLARIS_PRE_11 and self.compiler.find_library_file(self.lib_dirs, 'crypt_i'):
 +            libs = ['crypt_i']
 +        elif self.compiler.find_library_file(self.lib_dirs, 'crypt'):
              libs = ['crypt']
          else:
              libs = []
 @@ -1136,6 +1154,8 @@ class PyBuildExt(build_ext):
              if MACOS:
                  # Issue #35569: Expose RFC 3542 socket options.
                  kwargs['extra_compile_args'] = ['-D__APPLE_USE_RFC_3542']
 +            elif SOLARIS_PRE_11:
 +                kwargs['extra_compile_args'] = ['-DSOLARIS_PRE_11=1']

              self.add(Extension('_socket', ['socketmodule.c'], **kwargs))
          elif self.compiler.find_library_file(self.lib_dirs, 'net'):
 @@ -1356,6 +1376,31 @@ class PyBuildExt(build_ext):
          dbm_order = ['gdbm']
          # The standard Unix dbm module:
          if not CYGWIN:
 +            # Top half based on find_file
 +            def find_ndbm_h(dirs):
 +                ret = None
 +                if MACOS:
 +                    sysroot = macosx_sdk_root()
 +                for dir in dirs:
 +                    f = os.path.join(dir, 'ndbm.h')
 +                    if MACOS and is_macosx_sdk_path(dir):
 +                        f = os.path.join(sysroot, dir[1:], 'ndbm.h')
 +                    if not os.path.exists(f):
 +                        continue
 +
 +                    ret = True
 +                    input = text_file.TextFile(f)
 +                    while True:
 +                        line = input.readline()
 +                        if not line:
 +                            break
 +                        if re.search('This file is part of GDBM', line):
 +                            ret = None
 +                            break
 +                    input.close()
 +                    break
 +                return ret
 +
              config_args = [arg.strip("'")
                             for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
              dbm_args = [arg for arg in config_args
 @@ -1367,7 +1412,7 @@ class PyBuildExt(build_ext):
              dbmext = None
              for cand in dbm_order:
                  if cand == "ndbm":
 -                    if find_file("ndbm.h", self.inc_dirs, []) is not None:
 +                    if find_ndbm_h(self.inc_dirs) is not None:
                          # Some systems have -lndbm, others have -lgdbm_compat,
                          # others don't have either
                          if self.compiler.find_library_file(self.lib_dirs,
 @@ -2207,10 +2252,7 @@ class PyBuildExt(build_ext):
              sources = ['_decimal/_decimal.c']
              depends = ['_decimal/docstrings.h']
          else:
 -            include_dirs = [os.path.abspath(os.path.join(self.srcdir,
 -                                                         'Modules',
 -                                                         '_decimal',
 -                                                         'libmpdec'))]
 +            include_dirs = ['Modules/_decimal/libmpdec']
              libraries = ['m']
              sources = [
                '_decimal/_decimal.c',
 @@ -2595,7 +2637,7 @@ def main():
            # If you change the scripts installed here, you also need to
            # check the PyBuildScripts command above, and change the links
            # created by the bininstall target in Makefile.pre.in
 -          scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
 +          scripts = ["Tools/scripts/pydoc3",
                       "Tools/scripts/2to3"]
          )


 --=-1637787141-163853-10393-2638-5-=--

From: =?UTF-8?B?Q2xhZXMgTsOkc3TDqW4=?= <pekdon@gmail.com>
To: gnats-bugs <gnats-bugs@netbsd.org>
Cc: 
Subject: Re: pkg/56161: python3.8 build issue on Solaris 10
Date: Fri, 21 Jan 2022 06:57:21 +0100

 Fixes for 2.7, 3.7-3.10 has been committed, this issue can be closed.

 On Sun, May 9, 2021 at 7:20 PM <gnats-admin@netbsd.org> wrote:
 >
 > Thank you very much for your problem report.
 > It has the internal identification `pkg/56161'.
 > The individual assigned to look at your
 > report is: pkg-manager.
 >
 > >Category:       pkg
 > >Responsible:    pkg-manager
 > >Synopsis:       python3.8 build issue on Solaris 10
 > >Arrival-Date:   Sun May 09 17:20:00 +0000 2021
 >

State-Changed-From-To: open->closed
State-Changed-By: bsiegert@NetBSD.org
State-Changed-When: Fri, 21 Jan 2022 08:35:50 +0000
State-Changed-Why:
Submitter says this is fixed


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.