Bug 256558 - lang/python3[89]: Fix build WITH_DEBUG
Summary: lang/python3[89]: Fix build WITH_DEBUG
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Fukang Chen
URL:
Keywords:
Depends on:
Blocks: 257746
  Show dependency treegraph
 
Reported: 2021-06-11 19:10 UTC by Dmitry Marakasov
Modified: 2021-08-20 00:23 UTC (History)
4 users (show)

See Also:
koobs: maintainer-feedback+
loader: merge-quarterly+


Attachments
Patch (19.80 KB, patch)
2021-06-11 19:10 UTC, Dmitry Marakasov
koobs: maintainer-approval-
Details | Diff
%%ABI%% patch (29.50 KB, patch)
2021-08-17 08:07 UTC, Fukang Chen
koobs: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Marakasov freebsd_committer freebsd_triage 2021-06-11 19:10:04 UTC
Created attachment 225746 [details]
Patch

For python >= 3.8, names of installed .so files are different for DEBUG builds. Cope with that in the plists.
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2021-06-11 22:28:44 UTC
ABIFLAGS was added to handled these cases and worked correctly at the time. What happened?
Comment 2 Dmitry Marakasov freebsd_committer freebsd_triage 2021-06-15 10:57:51 UTC
(In reply to Kubilay Kocak from comment #1)
I have no idea. Why are you asking me? You are python@.
Comment 3 Kubilay Kocak freebsd_committer freebsd_triage 2021-06-15 12:00:00 UTC
(In reply to Dmitry Marakasov from comment #2)

I'm sorry Dmitry but the proposed patch added a new variable, hence the question/review.
Comment 4 Dmitry Marakasov freebsd_committer freebsd_triage 2021-06-15 14:39:02 UTC
(In reply to Kubilay Kocak from comment #3)
The addition of a new variable is well explained in the first comment. The questions of why ABIFLAGS is no longer sufficient and when the breakage happened should be directed to python@.
Comment 5 Dmitry Marakasov freebsd_committer freebsd_triage 2021-07-14 20:32:10 UTC
Note that python310 now needs the similar change. I've marked DEBUG options BROKEN for the time being.
Comment 6 commit-hook freebsd_committer freebsd_triage 2021-07-14 20:32:20 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2d2c2821bca5933475c6c418057f1480b85ded9b

commit 2d2c2821bca5933475c6c418057f1480b85ded9b
Author:     Dmitry Marakasov <amdmi3@FreeBSD.org>
AuthorDate: 2021-07-14 20:27:00 +0000
Commit:     Dmitry Marakasov <amdmi3@FreeBSD.org>
CommitDate: 2021-07-14 20:28:01 +0000

    lang/python{38,39,310}: mark DEBUG option BROKEN (incorrect plist)

    PR:             256558
    Approved by:    portmgr blanket

 lang/python310/Makefile | 1 +
 lang/python38/Makefile  | 1 +
 lang/python39/Makefile  | 1 +
 3 files changed, 3 insertions(+)
Comment 7 Fukang Chen freebsd_committer freebsd_triage 2021-08-17 07:56:03 UTC
(In reply to Kubilay Kocak from comment #1)

It was introduced by this commit on the 3.8 branch, EXT_SUFFIX now contains ${SOABI} on FreeBSD:
https://github.com/python/cpython/commit/b01091a3e71e6636d2df4db45920e820cdf7df3b
commit a44ce6c9f725d336aea51a946b42769f29fed613
Author: Matti Picus <matti.picus@gmail.com>
Date:   Sun Dec 20 04:56:57 2020 +0200

    bpo-42604: always set EXT_SUFFIX=${SOABI}${SHLIB_SUFFIX} when using configure (GH-23708)

    Now all platforms use a value for the "EXT_SUFFIX" build variable derived
    from SOABI (for instance in FreeBSD, "EXT_SUFFIX" is now ".cpython-310d.so"
    instead of ".so"). Previously only Linux, Mac and VxWorks were using a value
    for "EXT_SUFFIX" that included "SOABI".

    Co-authored-by: Pablo Galindo <pablogsal@gmail.com>

diff --git a/configure.ac b/configure.ac
index 445dae1..ee5573c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4786,12 +4786,7 @@ if test "$Py_DEBUG" = 'true' -a "$with_trace_refs" != "yes"; then
 fi

 AC_SUBST(EXT_SUFFIX)
-case $ac_sys_system in
-    Linux*|GNU*|Darwin|VxWorks)
-       EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX};;
-    *)
-       EXT_SUFFIX=${SHLIB_SUFFIX};;
-esac
+EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX}

 AC_MSG_CHECKING(LDVERSION)
 LDVERSION='$(VERSION)$(ABIFLAGS)'


SOABI is "cpython-38d" and configure argument "--with-pydebug" adds "d" to the ABIFLAGS:

https://github.com/python/cpython/blob/v3.8.11/configure.ac#L4693
4693 SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}

https://github.com/python/cpython/blob/v3.8.11/configure.ac#L1231-L1249
  1231	# For calculating the .so ABI tag.
  1232	AC_SUBST(ABIFLAGS)
  1233	ABIFLAGS=""
  1234	
  1235	# Check for --with-pydebug
  1236	AC_MSG_CHECKING(for --with-pydebug)
  1237	AC_ARG_WITH(pydebug,
  1238	            AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
  1239	[
  1240	if test "$withval" != no
  1241	then
  1242	  AC_DEFINE(Py_DEBUG, 1,
  1243	  [Define if you want to build an interpreter with many run-time checks.])
  1244	  AC_MSG_RESULT(yes);
  1245	  Py_DEBUG='true'
  1246	  ABIFLAGS="${ABIFLAGS}d"
  1247	else AC_MSG_RESULT(no); Py_DEBUG='false'
  1248	fi],
  1249	[AC_MSG_RESULT(no)])


disttuiles build_ext.py gets the extension filename ext_suffix from EXT_SUFFIX:

https://github.com/python/cpython/blob/v3.8.11/Lib/distutils/command/build_ext.py#L675-683
   675      def get_ext_filename(self, ext_name):
   676          r"""Convert the name of an extension (eg. "foo.bar") into the name
   677          of the file from which it will be loaded (eg. "foo/bar.so", or
   678          "foo\bar.pyd").
   679          """
   680          from distutils.sysconfig import get_config_var
   681          ext_path = ext_name.split('.')
   682          ext_suffix = get_config_var('EXT_SUFFIX')
   683          return os.path.join(*ext_path) + ext_suffix
Comment 8 Fukang Chen freebsd_committer freebsd_triage 2021-08-17 08:07:47 UTC
Created attachment 227271 [details]
%%ABI%% patch

If I'm not missing anything, it's safe to use %%ABI%% in the pkg-plist?
Comment 9 Kubilay Kocak freebsd_committer freebsd_triage 2021-08-18 23:40:51 UTC
(In reply to Fukang Chen from comment #8)

Yep, that's what is/was currently used in PLIST_SUB. Thanks for the isolation Fukang
Comment 10 Kubilay Kocak freebsd_committer freebsd_triage 2021-08-18 23:43:06 UTC
Comment on attachment 227271 [details]
%%ABI%% patch

Approved if this passes QA, in particular for any/all OPTIONS that modify the ABI variable, in both ON/OFF cases:

Approved by: koobs (python, maintainer)

If quarterly is affected please:

MFH: 2020Q3 (blanket: bug & regression fix)

@Fukang Feel free to self assign, commit and merge (if appropriate) and thank you
Comment 11 Fukang Chen freebsd_committer freebsd_triage 2021-08-19 14:50:29 UTC
Thanks @koobs. Tested with DEBUG ON and OFF.
Comment 12 commit-hook freebsd_committer freebsd_triage 2021-08-19 15:02:05 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=350158a17ebb99b22cbb5098e8003ea14b548c72

commit 350158a17ebb99b22cbb5098e8003ea14b548c72
Author:     Fukang Chen <loader@FreeBSD.org>
AuthorDate: 2021-08-19 12:30:32 +0000
Commit:     Fukang Chen <loader@FreeBSD.org>
CommitDate: 2021-08-19 15:00:36 +0000

    lang/python3[89]: Fix build WITH_DEBUG

    Python 3.8 [0] and 3.9 [1] are using a value for "EXT_SUFFIX"
    that includes "SOABI" on FreeBSD, C extension module filenames
    are affected by this change [2].

    [0]: https://github.com/python/cpython/commit/b01091a3e71e6636d2df4db45920e820cdf7df3b
    [1]: https://github.com/python/cpython/commit/4b155967b3e743cbdc31600f13f1bfcf07f7b6ce
    [2]: https://github.com/python/cpython/blob/v3.8.11/Lib/distutils/command/build_ext.py#L675-683

    PR:             256558
    Approved by:    koobs (python, maintainer)
    MFH:            2020Q3 (blanket: bug & regression fix)

 lang/python38/Makefile  |   1 -
 lang/python38/pkg-plist | 140 +++++++++++++++++++++++------------------------
 lang/python39/Makefile  |   1 -
 lang/python39/pkg-plist | 142 ++++++++++++++++++++++++------------------------
 4 files changed, 141 insertions(+), 143 deletions(-)
Comment 13 commit-hook freebsd_committer freebsd_triage 2021-08-19 15:02:06 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a99955f2f86f2746a65456b8d3ea739f99035f2e

commit a99955f2f86f2746a65456b8d3ea739f99035f2e
Author:     Fukang Chen <loader@FreeBSD.org>
AuthorDate: 2021-08-19 12:51:20 +0000
Commit:     Fukang Chen <loader@FreeBSD.org>
CommitDate: 2021-08-19 15:00:38 +0000

    lang/python310: Fix build WITH_DEBUG

    Python 3.10 [0] is using a value for "EXT_SUFFIX" that includes
    "SOABI" on FreeBSD, C extension module filenames are affected
    by this change [1].

    The limited C API is now supported if Python is built in debug mode [2],
    removed %%NO_DEBUG%% from
    %%NO_DEBUG%%lib/python%%XYDOT%%/lib-dynload/xxlimited.cpython-%%XY%%.so

    [0]: https://github.com/python/cpython/commit/a44ce6c9f725d336aea51a946b42769f29fed613
    [1]: https://github.com/python/cpython/blob/v3.10.0rc1/Lib/distutils/command/build_ext.py#L676-L684
    [2]: https://github.com/python/cpython/commit/3359cab038968935b40344fad7c30d211f9692e4

    PR:             256558
    Approved by:    koobs (python, maintainer)
    MFH:            No (Port does not exist in quarterly)

 lang/python310/Makefile  |   1 -
 lang/python310/pkg-plist | 144 +++++++++++++++++++++++------------------------
 2 files changed, 72 insertions(+), 73 deletions(-)
Comment 14 commit-hook freebsd_committer freebsd_triage 2021-08-19 16:09:18 UTC
A commit in branch 2021Q3 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=f8bdb024e18168f77fa63e2e59412906087846a9

commit f8bdb024e18168f77fa63e2e59412906087846a9
Author:     Fukang Chen <loader@FreeBSD.org>
AuthorDate: 2021-08-19 12:30:32 +0000
Commit:     Fukang Chen <loader@FreeBSD.org>
CommitDate: 2021-08-19 15:10:59 +0000

    lang/python3[89]: Fix build WITH_DEBUG

    Python 3.8 [0] and 3.9 [1] are using a value for "EXT_SUFFIX"
    that includes "SOABI" on FreeBSD, C extension module filenames
    are affected by this change [2].

    [0]: https://github.com/python/cpython/commit/b01091a3e71e6636d2df4db45920e820cdf7df3b
    [1]: https://github.com/python/cpython/commit/4b155967b3e743cbdc31600f13f1bfcf07f7b6ce
    [2]: https://github.com/python/cpython/blob/v3.8.11/Lib/distutils/command/build_ext.py#L675-683

    PR:             256558
    Approved by:    koobs (python, maintainer)
    MFH:            2020Q3 (blanket: bug & regression fix)

    (cherry picked from commit 350158a17ebb99b22cbb5098e8003ea14b548c72)

 lang/python38/pkg-plist | 140 +++++++++++++++++++++++------------------------
 lang/python39/pkg-plist | 142 ++++++++++++++++++++++++------------------------
 2 files changed, 141 insertions(+), 141 deletions(-)
Comment 15 Kubilay Kocak freebsd_committer freebsd_triage 2021-08-20 00:23:58 UTC
^Triage: Assign to committer that resolved

Thanks Fukang. P.S: Please join Python@ :)