Opened 6 months ago

Last modified 6 months ago

#69892 assigned defect

python312 fails to build on G3: Python: incompatible cpu-subtype

Reported by: barracuda156 Owned by: jmroot (Joshua Root)
Priority: Normal Milestone:
Component: ports Version: 2.9.3
Keywords: tiger Cc: kencu (Ken), Dave-Allured (Dave Allured), fhgwright (Fred Wright)
Port: python312

Description

I have no way to test this, but apparently Python 3.12 is broken on Tiger if build is done on G3.

:info:build /opt/local/bin/gcc-mp-7 -L/opt/local/lib -Wl,-headerpad_max_install_names -arch ppc    -Wl,-stack_size,1000000  -framework CoreFoundation Python.framework/Versions/3.12/Python -o python.exe Programs/python.o  -lintl -ldl  -framework CoreFoundation                         
:info:build DYLD_FRAMEWORK_PATH=/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/work/Python-3.12.3 ./python.exe -E -S -m sysconfig --generate-posix-vars ;\
:info:build if test $? -ne 0 ; then \
:info:build 	echo "generate-posix-vars failed" ; \
:info:build 	rm -f ./pybuilddir.txt ; \
:info:build 	exit 1 ; \
:info:build fi
:info:build dyld: Library not loaded: /opt/local/Library/Frameworks/Python.framework/Versions/3.12/Python
:info:build   Referenced from: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/work/Python-3.12.3/./python.exe
:info:build   Reason: no suitable image found.  Did find:
:info:build 	/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/work/Python-3.12.3/Python.framework/Versions/3.12/Python: incompatible cpu-subtype
:info:build make: *** [pybuilddir.txt] Error 133
:info:build make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/work/Python-3.12.3'
:info:build Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/work/Python-3.12.3" && /usr/bin/make -w all 
:info:build Exit code: 2
:error:build Failed to build python312: command execution failed
:debug:build Error code: CHILDSTATUS 16000 2

Attachments (1)

main.txt (329.3 KB) - added by barracuda156 6 months ago.

Download all attachments as: .zip

Change History (23)

Changed 6 months ago by barracuda156

Attachment: main.txt added

comment:1 Changed 6 months ago by kencu (Ken)

where does this report come from?

comment:2 Changed 6 months ago by kencu (Ken)

send the person here to work through it. It’s a common error with G3s, but you need access to the machine with the issue to fix it.

comment:3 in reply to:  1 Changed 6 months ago by barracuda156

Replying to kencu:

where does this report come from?

A topic about Discord clients, where I wrote about abaddon port, and someone was interested to get it working on Tiger on G3. We have fixed 2–3 ports recently, but it got stuck on Python for G3 and on gobject-introspection for myself (only on Tiger).

Topic is here: https://forums.macrumors.com/threads/it-is-possible-to-use-voice-chat-on-discord-for-powerpc.2350933/page-2?post=33102479#post-33102479 But I will write there now to ask to join in directly here.

comment:4 Changed 6 months ago by yumikonoua

i'm here, what I can do for fix python 3.12 on my G3?

comment:5 Changed 6 months ago by kencu (Ken)

Hello there.

Most likely we need to broaden out the acceptable CPU subtypes with an option like this -force_cpusubtype_ALL put in the right place.

Figuring out the right place, especially with python builds, can take a bit of trial and error. Josh knows a lot more than I do about building python.

For a start, please show us the result of this:

$ file /opt/local/Library/Frameworks/Python.framework/Versions/3.12/Python

which for my current Tiger G5 machine gives this:

$ file /opt/local/Library/Frameworks/Python.framework/Versions/3.12/Python
/opt/local/Library/Frameworks/Python.framework/Versions/3.12/Python: Mach-O dynamically linked shared library ppc

and also please show us the result of this:

file /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/work/Python-3.12.3/Python.framework/Versions/3.12/Python

comment:6 Changed 6 months ago by kencu (Ken)

Owner: set to jmroot
Status: newassigned

Josh, FYI

comment:7 Changed 6 months ago by yumikonoua

ok, one second

comment:8 Changed 6 months ago by yumikonoua

the file "file /opt/local/Library/Frameworks/Python.framework/Versions/3.12/Python" does not exist

comment:9 Changed 6 months ago by kencu (Ken)

and

file /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/work/Python-3.12.3/Python.framework/Versions/3.12/Python

?

comment:10 Changed 6 months ago by Dave-Allured (Dave Allured)

Cc: Dave-Allured added

comment:11 Changed 6 months ago by yumikonoua

here is /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/work/Python-3.12.3/Python.framework/Versions/3.12/Python: Mach-O dynamically linked shared library ppc\ }

Last edited 6 months ago by yumikonoua (previous) (diff)

comment:12 Changed 6 months ago by kencu (Ken)

that one looks right... "ppc".

can you tell us one more please?

file /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/work/Python-3.12.3/./python.exe

comment:13 Changed 6 months ago by yumikonoua

here /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/work/Python-3.12.3/./python.exe: Mach-O executable ppc

comment:14 Changed 6 months ago by kencu (Ken)

hmm. that file is also "ppc". What we were looking for is a mismatch, where one of the files would be a different architecture, like ppc7400 perhaps, to explain your error. But as far as I can see, the two files do match, and both are "ppc".

OK. Well, in mysterious circumstances like this, sometimes it helps to just try again.

Can you do try this:

sudo port clean python312
sudo port -v install python312

comment:15 Changed 6 months ago by yumikonoua

sure i'm trying now, I will let you know in a while

comment:16 Changed 6 months ago by fhgwright (Fred Wright)

Cc: fhgwright added

comment:17 Changed 6 months ago by yumikonoua

after a while, it made the same error:

rpad_max_install_names -arch ppc    -dynamiclib \
        -all_load libpython3.12.a -Wl,-single_module \
        -install_name /opt/local/Library/Frameworks/Python.framework/Versions/3.12/Python \
        -compatibility_version 3.12 \
        -current_version 3.12 \
        -framework CoreFoundation -lintl -ldl  -framework CoreFoundation;
/usr/bin/install -c -d -m 755  \
        Python.framework/Versions/3.12/Resources/English.lproj
/usr/bin/install -c -m 644 Mac/Resources/framework/Info.plist \
        Python.framework/Versions/3.12/Resources/Info.plist
ln -fsn 3.12 Python.framework/Versions/Current
ln -fsn Versions/Current/Python Python.framework/Python
ln -fsn Versions/Current/Resources Python.framework/Resources
/opt/local/bin/gcc-mp-7 -L/opt/local/lib -Wl,-headerpad_max_install_names -arch ppc    -Wl,-stack_size,1000000  -framework CoreFoundation Python.framework/Versions/3.12/Python -o python.exe Programs/python.o  -lintl -ldl  -framework CoreFoundation                         
DYLD_FRAMEWORK_PATH=/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/work/Python-3.12.3 ./python.exe -E -S -m sysconfig --generate-posix-vars ;\
if test $? -ne 0 ; then \
        echo "generate-posix-vars failed" ; \
        rm -f ./pybuilddir.txt ; \
        exit 1 ; \
fi
dyld: Library not loaded: /opt/local/Library/Frameworks/Python.framework/Versions/3.12/Python
  Referenced from: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/work/Python-3.12.3/./python.exe
  Reason: no suitable image found.  Did find:
        /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/work/Python-3.12.3/Python.framework/Versions/3.12/Python: incompatible cpu-subtype
make: *** [pybuilddir.txt] Error 133
make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/work/Python-3.12.3'
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/work/Python-3.12.3" && /usr/bin/make -w all 
Exit code: 2
Error: Failed to build python312: command execution failed
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_python312/python312/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a bug.
Error: Processing of port python312 failed

comment:18 Changed 6 months ago by kencu (Ken)

If you look at the python311 Portfile, it has this added:

https://github.com/macports/macports-ports/blob/b89544daea33be9f48ea990fa763ddc45b2a11cd/lang/python311/Portfile#L47

if {${configure.build_arch} in "ppc ppc64"} {
    # https://trac.macports.org/ticket/66483
    configure.ldflags-append -Wl,-read_only_relocs,suppress
    # G3 builds fail without this flag, as converting a static library
    # to dynamic using -all_load inadvertently sets the arch to ppc7400
    configure.ldflags-append -Wl,-force_cpusubtype_ALL
}

so most likely, that block, probably all of it, but at least the force_cpusubtype_ALL part of it, needs to be added to the python312 Portfile.

You would open them with this:

sudo port clean python312
bbedit `port file python311`
bbedit `port file python312`

and then copy the block from the python311 Portfile, and add it to the python312 Portfile.

Hopefully that is all that will be needed.

Last edited 6 months ago by kencu (Ken) (previous) (diff)

comment:19 Changed 6 months ago by kencu (Ken)

Summary: python312 reportedly fails to build on G3: Python: incompatible cpu-subtypepython312 fails to build on G3: Python: incompatible cpu-subtype

comment:20 in reply to:  18 Changed 6 months ago by barracuda156

Replying to kencu:

so most likely, that block, probably all of it, but at least the force_cpusubtype_ALL part of it, needs to be added to the python312 Portfile.

It may also be needed by the way if Python is built with native optimizations on G5. (The chunk should work as-is, nothing to modify specifically for G5.)

comment:21 in reply to:  17 Changed 6 months ago by barracuda156

Replying to yumikonoua:

Hi, did adding a proposed fix work for you? We cannot test, nobody has G3 hardware.

comment:22 Changed 6 months ago by miles-martin-66 (Miles Martin)

I'm glad I found this ticket. I just ran into this issue and tried your workaround on my aging iMac G3 PPC, 1GB Ram and can confirm that it works and that python312 builds and installs.

1)

sudo port clean python312
vi `port file python312`

2) Added the suggested code block just below the check for "darwin" so that the port file looks like this:

if {${os.platform} eq "darwin" && ${os.major} <= 10} {
    # work around no copyfile and/or pthread_threadid_np on older systems
    patchfiles-append  patch-no-copyfile-on-Tiger.diff \
                       patch-threadid-older-systems.diff
}

if {${configure.build_arch} in "ppc ppc64"} {
    # https://trac.macports.org/ticket/66483
    configure.ldflags-append -Wl,-read_only_relocs,suppress
    # G3 builds fail without this flag, as converting a static library
    # to dynamic using -all_load inadvertently sets the arch to ppc7400
    configure.ldflags-append -Wl,-force_cpusubtype_ALL
}

One observation, I see these warnings when building and installing both python311 and python312.

Warning: Configuration logfiles contain indications of -Wimplicit-function-declaration; check that features were not accidentally disabled:

lchflags: found in Python-3.12.3/config.log dbm_open: found in Python-3.12.3/config.log getrandom: found in Python-3.12.3/config.log le64toh: found in Python-3.12.3/config.log

Last edited 6 months ago by miles-martin-66 (Miles Martin) (previous) (diff)
Note: See TracTickets for help on using tickets.