Opened 2 years ago

Closed 2 years ago

#64904 closed enhancement (wontfix)

A fix for python3.x to build with +lto on PowerPC

Reported by: barracuda156 Owned by: jmroot (Joshua Root)
Priority: Normal Milestone:
Component: ports Version: 2.7.2
Keywords: powerpc, leopard, snowleopard Cc:
Port: python39, python310

Description

I have apparently fixed +lto for Pythons on PowerPC. Please try, who can check it.

The following change in a portfile required:

variant lto description {enable Link-Time Optimization} {
    configure.args-append   --with-lto
    if {${os.major} < 11} {
    patchfiles-append	patch-enable_dynamic.diff
    compiler.blacklist	*gcc-4.0 *gcc-4.2
    }
}

This is the patch for python310:

--- configure.orig	2022-03-24 04:12:04.000000000 +0800
+++ configure	2022-03-29 15:03:21.000000000 +0800
@@ -6755,7 +6755,7 @@
       case $ac_sys_system in
         Darwin*)
           # Any changes made here should be reflected in the GCC+Darwin case below
-          LTOFLAGS="-flto -Wl,-export_dynamic"
+          LTOFLAGS="-flto"
           LTOCFLAGS="-flto"
           ;;
         *)
@@ -6766,7 +6766,7 @@
     *gcc*)
       case $ac_sys_system in
         Darwin*)
-          LTOFLAGS="-flto -Wl,-export_dynamic"
+          LTOFLAGS="-flto"
           LTOCFLAGS="-flto"
           ;;
         *)

And for python39:

--- configure.orig	2022-03-24 05:12:08.000000000 +0800
+++ configure	2022-03-29 14:21:47.000000000 +0800
@@ -6696,7 +6696,7 @@
       case $ac_sys_system in
         Darwin*)
           # Any changes made here should be reflected in the GCC+Darwin case below
-          LTOFLAGS="-flto -Wl,-export_dynamic"
+          LTOFLAGS="-flto"
           LTOCFLAGS="-flto"
           ;;
         *)
@@ -6707,7 +6707,7 @@
     *gcc*)
       case $ac_sys_system in
         Darwin*)
-          LTOFLAGS="-flto -Wl,-export_dynamic"
+          LTOFLAGS="-flto"
           LTOCFLAGS="-flto"
           ;;
         *)

Then python upgrades with:

sudo port -v -n upgrade --enforce-variants python310 +lto

Procedure apparently worked for python39 and python310:

36-109% port -v installed python39
The following ports are currently installed:
  python39 @3.9.6_0 requested_variants='' platform='darwin 10' archs='ppc' date='2021-10-04T15:33:04+0800'
  python39 @3.9.9_0 requested_variants='' platform='darwin 10' archs='ppc' date='2021-12-26T10:58:28+0800'
  python39 @3.9.10_0 requested_variants='' platform='darwin 10' archs='ppc' date='2022-02-10T23:05:27+0800'
  python39 @3.9.11_0 requested_variants='' platform='darwin 10' archs='ppc' date='2022-03-18T01:49:38+0800'
  python39 @3.9.12_0 requested_variants='' platform='darwin 10' archs='ppc' date='2022-03-25T16:21:26+0800'
  python39 @3.9.12_0+lto (active) requested_variants='+lto' platform='darwin 10' archs='ppc' date='2022-03-29T14:39:25+0800'
36-109% port -v installed python310
The following ports are currently installed:
  python310 @3.10.1_0 requested_variants='' platform='darwin 10' archs='ppc' date='2021-12-13T01:20:48+0800'
  python310 @3.10.2_0 requested_variants='' platform='darwin 10' archs='ppc' date='2022-02-10T23:55:57+0800'
  python310 @3.10.3_0 requested_variants='' platform='darwin 10' archs='ppc' date='2022-03-18T01:56:20+0800'
  python310 @3.10.4_0 requested_variants='' platform='darwin 10' archs='ppc' date='2022-03-25T16:31:53+0800'
  python310 @3.10.4_0+lto (active) requested_variants='+lto' platform='darwin 10' archs='ppc' date='2022-03-29T15:13:15+0800'

Attachments (2)

patch-enable_dynamic_python39.diff (603 bytes) - added by barracuda156 2 years ago.
patch-enable_dynamic_python310.diff (603 bytes) - added by barracuda156 2 years ago.

Download all attachments as: .zip

Change History (7)

Changed 2 years ago by barracuda156

Changed 2 years ago by barracuda156

comment:1 Changed 2 years ago by mascguy (Christopher Nielsen)

Owner: set to jmroot
Status: newassigned

I'll let Josh speak to the feasibility of adding this. But love the idea of fixing Python 3.x for PPC!

comment:2 in reply to:  1 Changed 2 years ago by barracuda156

Replying to mascguy:

I'll let Josh speak to the feasibility of adding this. But love the idea of fixing Python 3.x for PPC!

Thank you!

  1. S. I hope also to fix Python 3.x for +universal on Leopard (ppc+ppc64), I have WIP and Pythons do build for ppc+ppc64, however some modules fail to work after. Once fixed, I will post an update in a new ticket.

comment:3 in reply to:  1 Changed 2 years ago by barracuda156

Replying to mascguy:

I'll let Josh speak to the feasibility of adding this. But love the idea of fixing Python 3.x for PPC!

Submitted PR: https://github.com/macports/macports-ports/pull/14816 Let’s see how it goes. Should be uncontroversial IMO.

comment:4 in reply to:  1 Changed 2 years ago by barracuda156

Replying to mascguy:

I'll let Josh speak to the feasibility of adding this. But love the idea of fixing Python 3.x for PPC!

Somewhat surprisingly, this simple fix has been rejected outright: https://github.com/macports/macports-ports/pull/14816#issuecomment-1129537497 We all know upstream won’t bother to fix something for old platforms, and that’s exactly why Macports has patches for these and not try to “work with upstream to add support”.

There was a historical precedent when someone requested for ppc+ppc64 build option for python27 (a really easy fix in a single file), and the upstream politely advised to make own patches: https://bugs.python.org/issue26487 And here is the reply for my ticket with upstream for Python3x: https://bugs.python.org/issue47240 (I have actually fixed that since then myself). Upstream may give some hints (or may not), but nothing will be actually implemented in the code.

So, well, I guess I just won’t do anything on Pythons anymore, at least here. Let them remain broken for PPC indefinitely.

comment:5 Changed 2 years ago by jmroot (Joshua Root)

Resolution: wontfix
Status: assignedclosed
Note: See TracTickets for help on using tickets.