gphalkes / tilde

The Tilde text editor
392 stars 20 forks source link

[Darwin PowerPC] tilde fails to launch: `Program received signal EXC_BAD_INSTRUCTION, Illegal instruction/operand` #114

Open barracuda156 opened 9 months ago

barracuda156 commented 9 months ago

While it builds fine, it does not launch:

macmini:~ svacchanda$ /opt/local/bin/tilde
Illegal instruction

Confirmed both on 10.6 ppc (native) and 10.6.8 (Rosetta).

GDB gives:

(gdb) run
Starting program: /opt/local/bin/tilde 
Reading symbols for shared libraries ++++++++++............ done

Program received signal EXC_BAD_INSTRUCTION, Illegal instruction/operand.
0x000bf034 in dyld_stub_uc_is_general_category_withtable ()
(gdb) bt
#0  0x000bf034 in dyld_stub_uc_is_general_category_withtable ()
#1  0x000c2eb4 in _ZN8t3widget14key_bindings_tINS_7split_t6ActionEEC4ESt16initializer_listINS3_7param_tEE ()
#2  0x0011b43c in t3widget::exit_main_loop ()
#3  0x8fe15d60 in __dyld__ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE ()
#4  0x8fe0f70c in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#5  0x8fe0f668 in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#6  0x8fe0f804 in __dyld__ZN11ImageLoader15runInitializersERKNS_11LinkContextE ()
#7  0x8fe02708 in __dyld__ZN4dyld24initializeMainExecutableEv ()
#8  0x8fe08690 in __dyld__ZN4dyld5_mainEPK11mach_headermiPPKcS5_S5_ ()
#9  0x8fe017cc in __dyld__ZN13dyldbootstrap5startEPK11mach_headeriPPKcl ()
#10 0x8fe01064 in __dyld__dyld_start ()
(gdb) where
#0  0x000bf034 in dyld_stub_uc_is_general_category_withtable ()
#1  0x000c2eb4 in _ZN8t3widget14key_bindings_tINS_7split_t6ActionEEC4ESt16initializer_listINS3_7param_tEE ()
#2  0x0011b43c in t3widget::exit_main_loop ()
#3  0x8fe15d60 in __dyld__ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE ()
#4  0x8fe0f70c in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#5  0x8fe0f668 in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#6  0x8fe0f804 in __dyld__ZN11ImageLoader15runInitializersERKNS_11LinkContextE ()
#7  0x8fe02708 in __dyld__ZN4dyld24initializeMainExecutableEv ()
#8  0x8fe08690 in __dyld__ZN4dyld5_mainEPK11mach_headermiPPKcS5_S5_ ()
#9  0x8fe017cc in __dyld__ZN13dyldbootstrap5startEPK11mach_headeriPPKcl ()
#10 0x8fe01064 in __dyld__dyld_start ()

At the same time no problem on 10.6 i386.

@gphalkes Any idea what goes wrong?

programmingkidx commented 7 months ago

I'm guessing the build system is having problems making a PowerPC binary on x86. Could you try building a PowerPC binary on a PowerPC Mac?

barracuda156 commented 7 months ago

I'm guessing the build system is having problems making a PowerPC binary on x86. Could you try building a PowerPC binary on a PowerPC Mac?

@programmingkidx I did build on ppc natively, same error. image

programmingkidx commented 7 months ago

Wow, not very many people know about the PowerPC version of Mac OS 10.6. I think it was only in beta on PowerPC. Would you be able to try on Mac OS 10.5 or on Mac OS 10.4?

If you don't want to do that could you use gdb to debug the program? Start debugging: gdb ./tilde Start tilde: run When you see the error run this command to show the instructions: disassemble $pc,+15 Provide the information you receive from gdb here. Good luck.

barracuda156 commented 7 months ago

@programmingkidx Thank you! Will do this today and update you.

P. S. My 10.5 installation is temporarily broken (needs to build gcc13, I just don’t get time to sort it there), but 10.4 is doable. Don’t use it normally, but as long as dependencies build, it should work.

barracuda156 commented 7 months ago

@programmingkidx This is what I get:

36-249% sudo gdb /opt/local/bin/tilde
Password:
GNU gdb 6.3.50-20050815 (Apple version gdb-1314.1) (Sun Nov 16 22:48:12 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-apple-darwin"...Reading symbols for shared libraries ........... done

(gdb) run
Starting program: /opt/local/bin/tilde 
Reading symbols for shared libraries +++++++++............... done

Program received signal EXC_BAD_INSTRUCTION, Illegal instruction/operand.
0x000bf030 in dyld_stub_uc_is_general_category_withtable ()
(gdb) disassemble $pc,+15
No function contains specified address.
(gdb) where
#0  0x000bf030 in dyld_stub_uc_is_general_category_withtable ()
#1  0x000c25dc in _ZNSsC4ISaIcEEEPKcRKS0_ ()
#2  0x8fe15d60 in __dyld__ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE ()
#3  0x8fe0f70c in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#4  0x8fe0f668 in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#5  0x8fe0f804 in __dyld__ZN11ImageLoader15runInitializersERKNS_11LinkContextE ()
#6  0x8fe02708 in __dyld__ZN4dyld24initializeMainExecutableEv ()
#7  0x8fe08690 in __dyld__ZN4dyld5_mainEPK11mach_headermiPPKcS5_S5_ ()
#8  0x8fe017cc in __dyld__ZN13dyldbootstrap5startEPK11mach_headeriPPKcl ()
#9  0x8fe01064 in __dyld__dyld_start ()
barracuda156 commented 7 months ago

I think I got the disassembling part:

36-249% sudo gdb-apple /opt/local/bin/tilde
GNU gdb 6.3.50.20050815-cvs (Wed Apr 13 04:55:50 UTC 2022)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=powerpc-apple-darwin10.0.0d2 --target="...Reading symbols for shared libraries ........... done

(gdb) run
Starting program: /opt/local/bin/tilde 
Reading symbols for shared libraries +++++++++............... done

Program received signal EXC_BAD_INSTRUCTION, Illegal instruction/operand.
0x000bf030 in dyld_stub_uc_is_general_category_withtable ()
(gdb) disassemble $pc-0x10 $pc+0x10
Dump of assembler code from 0xbf020 to 0xbf040:
0x000bf020: .long 0x214
0x000bf024: rlwnm.  r31,r26,r10,17,2
0x000bf028: rlmi    r20,r2,r0,0,0
0x000bf02c: .long 0x0
0x000bf030: .long 0x0
0x000bf034: .long 0x0
0x000bf038: .long 0x78000
0x000bf03c: .long 0x0
End of assembler dump.
(gdb) info registers
r0             0x0  0
r1             0xbfffd670   3221214832
r2             0x1001b99    16784281
r3             0x1001b90    16784272
r4             0x9  9
r5             0x9  9
r6             0x74 116
r7             0x10fc094    17809556
r8             0x2  2
r9             0x1b5d5710   459101968
r10            0x1a 26
r11            0xbfffd670   3221214832
r12            0xe12ae4 14756580
r13            0x8fe37930   2414049584
r14            0x8fe336bc   2414032572
r15            0x8fe37930   2414049584
r16            0x5efc   24316
r17            0x8fe34d60   2414038368
r18            0x8fe2b954   2414000468
r19            0x10 16
r20            0x8fe36c38   2414046264
r21            0x1  1
r22            0xbf4cc  783564
r23            0xbf230  782896
r24            0x8fe33ca0   2414034080
r25            0x1153e4 1135588
r26            0xbfffd6ac   3221214892
r27            0x9  9
r28            0x1001b90    16784272
r29            0x1001b9c    16784284
r30            0x1153db 1135579
r31            0xc257c  796028
pc             0xbf030  782384
ps             0x100000000008f030   1152921504607432752
cr             0x42000402   1107297282
lr             0xc25dc  796124
ctr            0xe12ae4 14756580
xer            0x0  0
mq             0x0  0
fpscr          0x0  0
vscr           0x10000  65536
vrsave         0x0  0
programmingkidx commented 7 months ago

Thank you for the information. Which version of gcc are you using to build tilde? Are you using the same version of gcc to build all of tilde's dependencies? Which version of ld are you using? ld -v

From the information above it looks like a data section is somehow trying to be executed. That is bad. I hope tilde can build on Mac OS 10.4. If you try it could you let us know how it goes?

barracuda156 commented 7 months ago

@programmingkidx

36-249% /opt/local/bin/gcc-mp-13 -v
Using built-in specs.
COLLECT_GCC=/opt/local/bin/gcc-mp-13
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/powerpc-apple-darwin10/13.2.0/lto-wrapper
Target: powerpc-apple-darwin10
Configured with: /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_gcc13/gcc13/work/gcc-13.2.0/configure --prefix=/opt/local --build=powerpc-apple-darwin10 --enable-languages=c,c++,objc,obj-c++,lto,fortran,jit --libdir=/opt/local/lib/gcc13 --includedir=/opt/local/include/gcc13 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-13 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-13 --with-gxx-include-dir=/opt/local/include/gcc13/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --with-zstd=/opt/local --enable-checking=release --disable-multilib --enable-lto --enable-libstdcxx-time --without-build-config --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --enable-host-shared --with-darwin-extra-rpath=/opt/local/lib/libgcc --with-libiconv-prefix=/opt/local --disable-tls --with-gxx-libcxx-include-dir=/opt/local/libexec/gcc13/libc++/include/c++/v1 --with-pkgversion='MacPorts gcc13 13.2.0_4+stdlib_flag'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (MacPorts gcc13 13.2.0_4+stdlib_flag)
36-249% /opt/local/bin/ld -v
@(#)PROGRAM:ld  PROJECT:ld64-97.17
configured to support archs: i386 x86_64 ppc ppc64 armv6 armv7
LTO support using: LLVM version 3.4.2

Macports normally switches to newer compilers when that is required, so as long as something builds with a default compiler, the latter is used. Of immediate tilde deps, some use gcc13 (where C/C++11 or higher needed or where gcc-4.2 just fails to build a given port), while other use gcc-4.2:

36-249% port deps tilde
Full Name: tilde @1.1.3_0
Extract Dependencies: lbzip2
Build Dependencies:   libtool, pkgconfig, gcc13
Library Dependencies: libt3highlight, libt3widget, libtranscript, libunistring,
                      libgcc
36-249% port deps libt3highlight
Full Name: libt3highlight @0.5.0_0
Extract Dependencies: lbzip2
Build Dependencies:   libtool, pkgconfig
Library Dependencies: libt3config, pcre2, legacy-support
36-249% port deps libt3widget
Full Name: libt3widget @1.2.2_0
Extract Dependencies: lbzip2
Build Dependencies:   libtool, pkgconfig, gcc13
Library Dependencies: libt3config, libt3key, libtranscript, libt3window,
                      libunistring, pcre2, xorg-libxcb, libgcc
36-249% port deps libtranscript
Full Name: libtranscript @0.3.3_0
Extract Dependencies: lbzip2
Build Dependencies:   libtool, pkgconfig

Notice, this behavior will be the same for all PowerPC systems, though 10.4–10.5 gonna pick gcc7 (instead of gcc13).

I can try rebuilding all of these with gcc13 just to check.

programmingkidx commented 7 months ago

Using different versions of gcc is where my vote goes for this problem. You might want to try building tilde and its dependencies yourself from source using my directions: https://trac.macports.org/ticket/68594.

Another suggestion that comes to mind is to force using gcc7 to build everything. I think macport's has an option to do this. This page looks very help: https://trac.macports.org/wiki/UsingTheRightCompiler.

Also your ld version seems kind of low. I think it would be a good idea to upgrade it.

barracuda156 commented 7 months ago

Another suggestion that comes to mind is to force using gcc7 to build everything. I think macport's has an option to do this.

Rather blacklist *gcc-4.* and let Macports pick a newer compiler. Forcing a specific one should be generally avoided.

Also your ld version seems kind of low. I think it would be a good idea to upgrade it.

It is pretty old, but it is the best one for ppc/ppc64 at the moment. While ld-127 build and works on powerpc, it has issues. Linker should not a problem, after all it is good enough to build the current gcc, CMake and thousands of other ports.

barracuda156 commented 7 months ago

@programmingkidx Just in case, can something in those ports referred to in your #68594 ticket set -mcpu=native optflag? I mean, from the sources side; Macports build system does not add that by default.

barracuda156 commented 7 months ago

@programmingkidx Look what I found:

  1. If I build libt3config with gcc-4.2, then libt3key builds normally.

  2. If I force gcc-13 for libt3config, then libt3key does not build with either gcc:

    make[1]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/libt3key-0.2.10'
    /usr/bin/install -d /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/lib
    /opt/local/bin/glibtool --mode=install /usr/bin/install -s -m0644 src/libt3key.la /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/lib
    glibtool: install: /usr/bin/install -m0644 src/.libs/libt3key.1.dylib /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/lib/libt3key.1.dylib
    glibtool: install: strip -x /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/lib/libt3key.1.dylib
    glibtool: install: (cd /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/lib && { ln -s -f libt3key.1.dylib libt3key.dylib || { rm -f libt3key.dylib && ln -s libt3key.1.dylib libt3key.dylib; }; })
    glibtool: install: /usr/bin/install -m0644 src/.libs/libt3key.lai /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/lib/libt3key.la
    glibtool: warning: remember to run 'glibtool --finish /opt/local/lib'
    chmod 0644 /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/lib/libt3key.la
    /usr/bin/install -d /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/include/t3/key/t3key
    /usr/bin/install -m0644 src/key.h src/key_api.h src/key_errors.h /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/include/t3/key/t3key
    /usr/bin/install -d /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/doc/libt3key
    /usr/bin/install -m0644 COPYING README Changelog doc/format.txt doc/format.html doc/supplemental.kmap /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/doc/libt3key
    /usr/bin/install -d /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/lib/pkgconfig
    /usr/bin/install -m0644 libt3key.pc /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/lib/pkgconfig
    /usr/bin/install -d /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/bin
    /usr/bin/install -s src.util/t3keyc/t3keyc /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/bin
    /usr/bin/install -d /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/libt3key1
    find src/database -type f | while read FILE ; do install -m0644 "$FILE" /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/libt3key1 ; \
        /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/bin/t3keyc -l  /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/libt3key1/"${FILE##*/}" ; done
    /bin/sh: line 1: 70526 Illegal instruction     /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/bin/t3keyc -l /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/libt3key1/"${FILE##*/}"
    /bin/sh: line 1: 70529 Illegal instruction     /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/bin/t3keyc -l /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/libt3key1/"${FILE##*/}"
    /bin/sh: line 1: 70531 Illegal instruction     /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/bin/t3keyc -l /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/libt3key1/"${FILE##*/}"
    /bin/sh: line 1: 70533 Illegal instruction     /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/bin/t3keyc -l /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/libt3key1/"${FILE##*/}"
    /bin/sh: line 1: 70535 Illegal instruction     /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/bin/t3keyc -l /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/libt3key1/"${FILE##*/}"
    /bin/sh: line 1: 70537 Illegal instruction     /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/bin/t3keyc -l /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/libt3key1/"${FILE##*/}"
    /bin/sh: line 1: 70540 Illegal instruction     /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/bin/t3keyc -l /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/libt3key1/"${FILE##*/}"
    /bin/sh: line 1: 70542 Illegal instruction     /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/bin/t3keyc -l /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/libt3key1/"${FILE##*/}"
    /bin/sh: line 1: 70544 Illegal instruction     /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/bin/t3keyc -l /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/libt3key1/"${FILE##*/}"
    /bin/sh: line 1: 70546 Illegal instruction     /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/bin/t3keyc -l /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/libt3key1/"${FILE##*/}"
    /bin/sh: line 1: 70549 Illegal instruction     /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/bin/t3keyc -l /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libt3key/libt3key/work/destroot/opt/local/share/libt3key1/"${FILE##*/}"
    make: *** [install] Error 132
barracuda156 commented 7 months ago

This is probably wrong for ppc in libt3config:

typedef char t3_bool;

Bool is 4-byte, unless of course this in fact must be forced to 1-byte size.

programmingkidx commented 7 months ago

@programmingkidx Just in case, can something in those ports referred to in your #68594 ticket set -mcpu=native optflag? I mean, from the sources side; Macports build system does not add that by default.

I think you could using that flag with the CXXFLAGS and CFLAGS variables when using configure. I never used it myself.

programmingkidx commented 7 months ago

@programmingkidx Look what I found:

1. If I build `libt3config` with gcc-4.2, then `libt3key` builds normally.

2. If I force gcc-13 for `libt3config`, then `libt3key` does not build with either gcc:

Good catch. I'm wondering if gcc7 has this issue also.

barracuda156 commented 7 months ago

I think you could using that flag with the CXXFLAGS and CFLAGS variables when using configure. I never used it myself.

My concern was the opposite: we should avoid using it, at least for debugging, since it is unsafe and can cause obscure breakages. But anyway, since it is not used, this is not relevant to the case.

I'm wondering if gcc7 has this issue also.

I have a zoo of gcc here, let me try. (But if anything, gcc13 should have less bugs that gcc7. gcc7 was pretty bad in fact.)

barracuda156 commented 7 months ago

@programmingkidx Yes, both with gcc6 and gcc7 same issue.

programmingkidx commented 7 months ago

This is probably wrong for ppc in libt3config:

typedef char t3_bool;

Bool is 4-byte, unless of course this in fact must be forced to 1-byte size.

I'm not familiar with any issues with bool on PowerPC. I also wonder why the author chose to use char as his own bool type. C99 comes with a bool type built-in.

I have a zoo of gcc here, let me try. (But if anything, gcc13 should have less bugs that gcc7. gcc7 was pretty bad in fact.)

Sorry to hear about gcc7. If it isn't good then I would skip testing it. After reading the notes for libt3widget it looks like C++11 support is required. So pretty much everything after gcc 4.8 should be fine. The key issue is building all the dependencies and tilde using the same compiler. Hopefully that will fix your issue.

barracuda156 commented 7 months ago

We should still verify on 10.5, ideally, to be sure. (I believe my gcc work robustly on 10.6, and this is the only instance of such an error which I can recall, but still, 10.6 is not the standard ppc config.)

barracuda156 commented 7 months ago

@programmingkidx

I'm not familiar with any issues with bool on PowerPC

32-bit ABI uses 4-byte bool, unlike pretty much everything else, including macOS ppc64 ABI (there bool is standard 1-byte). This may break something when it is not considered, and normally it is not. Not just alignments, but sfinae, suddenly, etc.

If it isn't good then I would skip testing it.

I did not mean to discourage testing, since gcc7 is what 10.4–10.5 got at the moment by default, FWIW. I do have specific cases in mind when I say it had issues, but it is far from being broken – it still should work fine for most of the stuff.

The key issue is building all the dependencies and tilde using the same compiler.

Well, since it needs C++11, gcc-4.2 is out of question (some dependencies cannot be built with it), while with gcc13 I cannot build both libt3config and libt3key :) I should try on 10.4, and thought to do that today, but forgot to take a power adapter for the external drive with Tiger. Will return to this.

programmingkidx commented 7 months ago

I was watching this video: https://www.youtube.com/watch?v=gS-_8kl_OpA. It is titled "So broken: GNU binutils regression breaks GCC PowerPC. You can't make this waste of time up :-/". It made me wonder, did you update your binutils?

barracuda156 commented 7 months ago

Looks like Macports has cctools 949.0.1. Generally speaking, it works. Of course we still cannot exclude a) a genuine compiler bug and b) peculiarity of 10.6 ppc.

As for the latter, however, I recall that I built tilde on 10.6 i386 which is the same developer build and which uses the same gcc13, like my powerpc system, and there is worked normally. At the same time on 10.6.8 Rosetta it failed (and 10.6.8 is a standard release with standard gcc). So I tend to think that this is not an OS bug, but specifically something does not work on ppc (or big-endian in general).

programmingkidx commented 7 months ago

I didn't think about the endianness of the CPU being a possible cause. Bit operations tend to be sensitive to it. I haven't gone thru all of tilde's source code so it is possible there is something that depends on a little-endian CPU.

With your already built tilde could you have dyld print all the libraries it tries to load for it? I think one of the dependencies is to blame for tilde's failure. To find this out we have to find out where in the loading cycle things fail.

Directions:

This is the output on Mac OS 10.12:

dyld: loaded: /opt/local/bin/tilde dyld: loaded: /opt/local/lib/libunistring.5.dylib dyld: loaded: /opt/local/lib/libtranscript.1.dylib dyld: loaded: /usr/local/lib/libt3widget.2.dylib dyld: loaded: /opt/local/lib/libt3window.0.dylib dyld: loaded: /opt/local/lib/libt3config.0.dylib dyld: loaded: /usr/local/lib/libt3highlight.2.dylib dyld: loaded: /usr/lib/libc++.1.dylib dyld: loaded: /usr/lib/libSystem.B.dylib dyld: loaded: /opt/local/lib/libiconv.2.dylib dyld: loaded: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation dyld: loaded: /usr/lib/system/libcache.dylib dyld: loaded: /usr/lib/system/libcommonCrypto.dylib dyld: loaded: /usr/lib/system/libcompiler_rt.dylib dyld: loaded: /usr/lib/system/libcopyfile.dylib dyld: loaded: /usr/lib/system/libcorecrypto.dylib dyld: loaded: /usr/lib/system/libdispatch.dylib dyld: loaded: /usr/lib/system/libdyld.dylib dyld: loaded: /usr/lib/system/libkeymgr.dylib dyld: loaded: /usr/lib/system/liblaunch.dylib dyld: loaded: /usr/lib/system/libmacho.dylib dyld: loaded: /usr/lib/system/libquarantine.dylib dyld: loaded: /usr/lib/system/libremovefile.dylib dyld: loaded: /usr/lib/system/libsystem_asl.dylib dyld: loaded: /usr/lib/system/libsystem_blocks.dylib dyld: loaded: /usr/lib/system/libsystem_c.dylib dyld: loaded: /usr/lib/system/libsystem_configuration.dylib dyld: loaded: /usr/lib/system/libsystem_coreservices.dylib dyld: loaded: /usr/lib/system/libsystem_coretls.dylib dyld: loaded: /usr/lib/system/libsystem_dnssd.dylib dyld: loaded: /usr/lib/system/libsystem_info.dylib dyld: loaded: /usr/lib/system/libsystem_kernel.dylib dyld: loaded: /usr/lib/system/libsystem_m.dylib dyld: loaded: /usr/lib/system/libsystem_malloc.dylib dyld: loaded: /usr/lib/system/libsystem_network.dylib dyld: loaded: /usr/lib/system/libsystem_networkextension.dylib dyld: loaded: /usr/lib/system/libsystem_notify.dylib dyld: loaded: /usr/lib/system/libsystem_platform.dylib dyld: loaded: /usr/lib/system/libsystem_pthread.dylib dyld: loaded: /usr/lib/system/libsystem_sandbox.dylib dyld: loaded: /usr/lib/system/libsystem_secinit.dylib dyld: loaded: /usr/lib/system/libsystem_symptoms.dylib dyld: loaded: /usr/lib/system/libsystem_trace.dylib dyld: loaded: /usr/lib/system/libunwind.dylib dyld: loaded: /usr/lib/system/libxpc.dylib dyld: loaded: /usr/lib/libobjc.A.dylib dyld: loaded: /usr/lib/libc++abi.dylib dyld: loaded: /usr/lib/libDiagnosticMessagesClient.dylib dyld: loaded: /usr/lib/libicucore.A.dylib dyld: loaded: /usr/lib/libz.1.dylib dyld: loaded: /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit dyld: loaded: /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation dyld: loaded: /opt/local/lib/libt3key.1.dylib dyld: loaded: /opt/local/lib/libpcre2-8.0.dylib dyld: loaded: /System/Library/PrivateFrameworks/RemoteViewServices.framework/Versions/A/RemoteViewServices dyld: loaded: /System/Library/PrivateFrameworks/UIFoundation.framework/Versions/A/UIFoundation dyld: loaded: /System/Library/PrivateFrameworks/DFRFoundation.framework/Versions/A/DFRFoundation dyld: loaded: /usr/lib/libenergytrace.dylib dyld: loaded: /System/Library/PrivateFrameworks/SkyLight.framework/Versions/A/SkyLight dyld: loaded: /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics dyld: loaded: /usr/lib/libScreenReader.dylib dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate dyld: loaded: /System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices dyld: loaded: /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox dyld: loaded: /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit dyld: loaded: /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData dyld: loaded: /System/Library/PrivateFrameworks/DataDetectorsCore.framework/Versions/A/DataDetectorsCore dyld: loaded: /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox dyld: loaded: /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore dyld: loaded: /System/Library/Frameworks/Security.framework/Versions/A/Security dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition dyld: loaded: /usr/lib/libauto.dylib dyld: loaded: /usr/lib/libxml2.2.dylib dyld: loaded: /System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI dyld: loaded: /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio dyld: loaded: /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration dyld: loaded: /usr/lib/liblangid.dylib dyld: loaded: /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport dyld: loaded: /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices dyld: loaded: /System/Library/PrivateFrameworks/PerformanceAnalysis.framework/Versions/A/PerformanceAnalysis dyld: loaded: /System/Library/PrivateFrameworks/GenerationalStorage.framework/Versions/A/GenerationalStorage dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL dyld: loaded: /System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImage dyld: loaded: /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText dyld: loaded: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO dyld: loaded: /System/Library/PrivateFrameworks/Backup.framework/Versions/A/Backup dyld: loaded: /usr/lib/libarchive.2.dylib dyld: loaded: /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork dyld: loaded: /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration dyld: loaded: /usr/lib/libCRFSuite.dylib dyld: loaded: /usr/lib/libbsm.0.dylib dyld: loaded: /usr/lib/system/libkxld.dylib dyld: loaded: /usr/lib/libcoretls.dylib dyld: loaded: /usr/lib/libcoretls_cfhelpers.dylib dyld: loaded: /usr/lib/libOpenScriptingUtil.dylib dyld: loaded: /usr/lib/libpam.2.dylib dyld: loaded: /usr/lib/libsqlite3.dylib dyld: loaded: /usr/lib/libxar.1.dylib dyld: loaded: /usr/lib/libbz2.1.0.dylib dyld: loaded: /usr/lib/liblzma.5.dylib dyld: loaded: /usr/lib/libnetwork.dylib dyld: loaded: /usr/lib/libpcap.A.dylib dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/FSEvents.framework/Versions/A/FSEvents dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList dyld: loaded: /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS dyld: loaded: /System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth dyld: loaded: /System/Library/PrivateFrameworks/login.framework/Versions/A/Frameworks/loginsupport.framework/Versions/A/loginsupport dyld: loaded: /System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC dyld: loaded: /usr/lib/libmecabra.dylib dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBNNS.dylib dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libQuadrature.dylib dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLinearAlgebra.dylib dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libSparseBLAS.dylib dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontParser.dylib dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontRegistry.dylib dyld: loaded: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib dyld: loaded: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib dyld: loaded: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib dyld: loaded: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib dyld: loaded: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJP2.dylib dyld: loaded: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib dyld: loaded: /usr/lib/libcompression.dylib dyld: loaded: /System/Library/PrivateFrameworks/AppleJPEG.framework/Versions/A/AppleJPEG dyld: loaded: /usr/lib/libcups.2.dylib dyld: loaded: /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos dyld: loaded: /System/Library/Frameworks/GSS.framework/Versions/A/GSS dyld: loaded: /usr/lib/libresolv.9.dylib dyld: loaded: /usr/lib/libiconv.2.dylib dyld: loaded: /System/Library/PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal dyld: loaded: /usr/lib/libheimdal-asn1.dylib dyld: loaded: /System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory dyld: loaded: /System/Library/PrivateFrameworks/CommonAuth.framework/Versions/A/CommonAuth dyld: loaded: /System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory.framework/Versions/A/CFOpenDirectory dyld: loaded: /System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation dyld: loaded: /System/Library/PrivateFrameworks/LanguageModeling.framework/Versions/A/LanguageModeling dyld: loaded: /usr/lib/libmarisa.dylib dyld: loaded: /usr/lib/libChineseTokenizer.dylib dyld: loaded: /usr/lib/libcmph.dylib dyld: loaded: /System/Library/PrivateFrameworks/CoreEmoji.framework/Versions/A/CoreEmoji dyld: loaded: /System/Library/Frameworks/ServiceManagement.framework/Versions/A/ServiceManagement dyld: loaded: /usr/lib/libxslt.1.dylib dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink dyld: loaded: /System/Library/PrivateFrameworks/TextureIO.framework/Versions/A/TextureIO dyld: loaded: /System/Library/Frameworks/Metal.framework/Versions/A/Metal dyld: loaded: /usr/lib/libate.dylib dyld: loaded: /System/Library/PrivateFrameworks/GPUCompiler.framework/libmetal_timestamp.dylib dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreFSCache.dylib dyld: loaded: /System/Library/PrivateFrameworks/IOAccelerator.framework/Versions/A/IOAccelerator dyld: loaded: /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo dyld: loaded: /usr/lib/libFosl_dynamic.dylib dyld: loaded: /System/Library/PrivateFrameworks/MetalPerformanceShaders.framework/Versions/A/MetalPerformanceShaders dyld: loaded: /System/Library/PrivateFrameworks/FaceCore.framework/Versions/A/FaceCore dyld: loaded: /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCVMSPluginSupport.dylib dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib dyld: loaded: /System/Library/PrivateFrameworks/CrashReporterSupport.framework/Versions/A/CrashReporterSupport dyld: loaded: /System/Library/PrivateFrameworks/Sharing.framework/Versions/A/Sharing dyld: loaded: /System/Library/PrivateFrameworks/IconServices.framework/Versions/A/IconServices dyld: loaded: /System/Library/PrivateFrameworks/ProtocolBuffer.framework/Versions/A/ProtocolBuffer dyld: loaded: /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Apple80211 dyld: loaded: /System/Library/Frameworks/CoreWLAN.framework/Versions/A/CoreWLAN dyld: loaded: /System/Library/PrivateFrameworks/CoreUtils.framework/Versions/A/CoreUtils dyld: loaded: /System/Library/Frameworks/IOBluetooth.framework/Versions/A/IOBluetooth dyld: loaded: /System/Library/PrivateFrameworks/CoreWiFi.framework/Versions/A/CoreWiFi dyld: loaded: /System/Library/Frameworks/CoreBluetooth.framework/Versions/A/CoreBluetooth dyld: loaded: /System/Library/Frameworks/CoreDisplay.framework/Versions/A/CoreDisplay dyld: loaded: /System/Library/PrivateFrameworks/IOPresentment.framework/Versions/A/IOPresentment dyld: loaded: /System/Library/PrivateFrameworks/DSExternalDisplay.framework/Versions/A/DSExternalDisplay dyld: loaded: /System/Library/PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols dyld: loaded: /System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/CoreSymbolication dyld: loaded: /System/Library/PrivateFrameworks/Symbolication.framework/Versions/A/Symbolication dyld: loaded: /System/Library/PrivateFrameworks/AppleFSCompression.framework/Versions/A/AppleFSCompression dyld: loaded: /System/Library/PrivateFrameworks/SpeechRecognitionCore.framework/Versions/A/SpeechRecognitionCore dyld: loaded: /System/Library/PrivateFrameworks/ChunkingLibrary.framework/Versions/A/ChunkingLibrary dyld: loaded: /usr/lib/libncurses.5.4.dylib

programmingkidx commented 7 months ago

I had AI look at your stack trace. This is what it said:

The crash you’re seeing is due to an EXC_BAD_INSTRUCTION error. This error generally means that there was an assertion failure in your code1.

The stack trace shows the sequence of function calls leading up to the crash. Here’s a brief explanation of some of the functions involved:

[dyld_stub_uc_is_general_category_withtable: This function is a stub, which is a small piece of code used as a placeholder or substitute for another programming functionality](https://stackoverflow.com/questions/8825537/mach-o-symbol-stubs-ios)[2](https://stackoverflow.com/questions/8825537/mach-o-symbol-stubs-ios).

_ZNSsC4ISaIcEEEPKcRKS0_: This is a mangled name for a C++ function. The actual name and functionality can’t be determined without demangling it.

[__dyld__ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE: This function is part of the dynamic linker dyld, and it’s responsible for initializing an image](https://stackoverflow.com/questions/17703510/dyld-library-not-loaded-reason-image-not-found)[3](https://stackoverflow.com/questions/17703510/dyld-library-not-loaded-reason-image-not-found).

[__dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj: This function is also part of dyld, and it’s responsible for initializing all images required by the program](https://github.com/google/sanitizers/issues/33)[4](https://github.com/google/sanitizers/issues/33).

[__dyld__ZN11ImageLoader15runInitializersERKNS_11LinkContextE: This function runs initializers for the images](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dyld.3.html)[5](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dyld.3.html).

[__dyld__ZN4dyld24initializeMainExecutableEv: This function initializes the main executable](https://blogs.blackberry.com/en/2017/02/running-executables-on-macos-from-memory)[6](https://blogs.blackberry.com/en/2017/02/running-executables-on-macos-from-memory).

[__dyld__ZN4dyld5_mainEPK11mach_headermiPPKcS5_S5_: This function is the main function of dyld](https://github.com/llvm/llvm-project/issues/1253)[7](https://github.com/llvm/llvm-project/issues/1253).

[__dyld__ZN13dyldbootstrap5startEPK11mach_headeriPPKcl: This function is the start function of dyld](https://stackoverflow.com/questions/9778774/more-info-on-functions-like-dyld-dyld-start-on-macos)[8](https://stackoverflow.com/questions/9778774/more-info-on-functions-like-dyld-dyld-start-on-macos).

[__dyld__dyld_start: This is the entry point of the dynamic linker](https://stackoverflow.com/questions/28804654/what-does-error-thread-1exc-bad-instruction-code-exc-i386-invop-subcode-0x0)[9](https://medium.com/geekculture/code-injection-with-dyld-interposing-3008441c62dd).

The exact cause of the crash would depend on the specifics of your code and what it’s trying to do when the crash occurs. It could be due to an issue with dynamic linking, a problem with initialization of some component, or a variety of other reasons. You might need to debug your code to find out the exact cause. If you’re using assertions in your code, you might want to check if those are being triggered incorrectly. If you’re dynamically loading code or libraries, you might want to verify that all dependencies are correctly installed and accessible.

barracuda156 commented 7 months ago

uc_is_general_category_withtable comes from libunistring.

programmingkidx commented 7 months ago

Ok lets test libunistring.

This program uses libunistring to make an uppercase string:

#include <stdio.h>
#include <stdlib.h>
#include <unistr.h>
#include <unictype.h>

int main() {
    uint8_t input[] = "Hello, World!";
    uint8_t output[100];
    size_t length;

    // Convert the input string to uppercase using libunistring
    for (length = 0; input[length] != '\0'; length++) {
        uint32_t ch;
        u8_mbtouc(&ch, &input[length], 1);
        ch = uc_toupper(ch);
        u8_uctomb(&output[length], ch, 1);
    }
    output[length] = '\0';

    printf("%s\n", output);

    return 0;
}

Try to run this program on your system. Copy this source code into a file called main.c. Then run this command to build the program: gcc -o test main.c -L/opt/local/lib -lunistring -I/opt/local/include/ Then run the program test: ./test You should see this output if successful: HELLO, WORLD!

Note: the paths for the libaries and include files might be different on your computer. The find command could help you here.

barracuda156 commented 7 months ago

@programmingkidx I will do Tiger testing today, but here tilde runs on 10.6 i386 (10a190). Notice, it uses identical gcc13 (with a patch for 10a190), it also builds some dependencies with gcc-4.2, however there is no breakage. This does not rule out ppc-specific bug in either gcc or binutils, but it rules out, IMO, libstdc++ incompatibility, 10.6 SDK issues and possible general bugs in gcc13.

image

barracuda156 commented 7 months ago

@programmingkidx So it is also broken on Tiger:

36-64:~ svacchanda$ tilde
Illegal instruction
36-64:~ svacchanda$ sudo gdb tilde
Password:
GNU gdb 6.3.50-20050815 (Apple version gdb-696) (Sat Oct 20 18:20:28 GMT 2007)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-apple-darwin"...
warning: --arch option not supported in this gdb.
Reading symbols for shared libraries ........... done

(gdb) run
Starting program: /opt/local/bin/tilde 
Reading symbols for shared libraries .+.....+.+.+..+.+.+ done

Program received signal EXC_BAD_INSTRUCTION, Illegal instruction/operand.
0x003bd034 in resultbuf.3175 ()
(gdb) where
#0  0x003bd034 in resultbuf.3175 ()
#1  0x003c18c0 in t3widget::key_bindings_t<t3widget::split_t::Action>::key_bindings_t ()
#2  0x00418ab0 in typeinfo name for t3widget::expander_group_t ()
#3  0x8fe15670 in __dyld__ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE ()
#4  0x8fe0babc in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextE ()
#5  0x8fe0ba4c in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextE ()
#6  0x8fe0d604 in __dyld__ZN11ImageLoader15runInitializersERKNS_11LinkContextE ()
#7  0x8fe02cb4 in __dyld__ZN4dyld24initializeMainExecutableEv ()
#8  0x00006888 in option_access_t::option_access_t ()
#9  0x00006754 in option_access_t::option_access_t ()
(gdb) disassemble $pc-0x10 $pc+0x10
Dump of assembler code from 0x3bd024 to 0x3bd044:
0x003bd024 <resultbuf.3175+64908>:      rlwnm.  r31,r26,r10,17,2
0x003bd028 <resultbuf.3175+64912>:      rlmi    r20,r2,r0,0,0
0x003bd02c <resultbuf.3175+64916>:      .long 0x0
0x003bd030 <resultbuf.3175+64920>:      .long 0x0
0x003bd034 <resultbuf.3175+64924>:      .long 0x0
0x003bd038 <resultbuf.3175+64928>:      .long 0x71000
0x003bd03c <resultbuf.3175+64932>:      .long 0x0
0x003bd040 <resultbuf.3175+64936>:      .long 0x71000
End of assembler dump.
(gdb) info registers
r0             0x3c18c0 3938496
r1             0xbffff800       3221223424
r2             0x43ca54 4442708
r3             0xbffff848       3221223496
r4             0x43ca50 4442704
r5             0x1100c30        17828912
r6             0x3      3
r7             0x4      4
r8             0x120201c        18882588
r9             0x35     53
r10            0x1200018        18874392
r11            0xbffff800       3221223424
r12            0x3c13e4 3937252
r13            0x0      0
r14            0x0      0
r15            0x0      0
r16            0x0      0
r17            0xbffff838       3221223480
r18            0x0      0
r19            0x43ca68 4442728
r20            0xbffff848       3221223496
r21            0xbffff8e8       3221223656
r22            0x43ca50 4442704
r23            0xbffff8cc       3221223628
r24            0x1100c20        17828896
r25            0x43ca54 4442708
r26            0x1100c30        17828912
r27            0x43ca50 4442704
r28            0x43ca54 4442708
r29            0x0      0
r30            0xbffff848       3221223496
r31            0x3c1784 3938180
pc             0x3bd034 3919924
ps             0x100000000208f030       1152921504640987184
cr             0x84000202       2214593026
lr             0x3c18c0 3938496
ctr            0x3c13e4 3937252
xer            0x0      0
mq             0x0      0
fpscr          0x82024000       2181185536
vscr           0x10000  65536
vrsave         0x0      0
barracuda156 commented 7 months ago

On 10.4.1 with libraries:

36-64:~ svacchanda$ export DYLD_PRINT_LIBRARIES=1
36-64:~ svacchanda$ tilde
dyld: loaded: /opt/local/bin/tilde
dyld: loaded: /opt/local/lib/libtranscript.1.dylib
dyld: loaded: /opt/local/lib/libunistring.5.dylib
dyld: loaded: /opt/local/lib/libt3widget.2.dylib
dyld: loaded: /opt/local/lib/libt3window.0.dylib
dyld: loaded: /opt/local/lib/libt3config.0.dylib
dyld: loaded: /opt/local/lib/libt3highlight.2.dylib
dyld: loaded: /opt/local/lib/libgcc/libstdc++.6.dylib
dyld: loaded: /usr/lib/libgcc_s.1.dylib
dyld: loaded: /opt/local/lib/libgcc/libgcc_s.1.dylib, cpu-sub-type: 0
dyld: loaded: /usr/lib/libSystem.B.dylib, cpu-sub-type: 0
dyld: loaded: /usr/lib/system/libmathCommon.A.dylib, cpu-sub-type: 0
dyld: loaded: /opt/local/lib/libiconv.2.dylib
dyld: loaded: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
dyld: loaded: /usr/lib/libicucore.A.dylib
dyld: loaded: /usr/lib/libauto.dylib
dyld: loaded: /usr/lib/libobjc.A.dylib
dyld: loaded: /opt/local/lib/libt3key.1.dylib
dyld: loaded: /opt/local/lib/libpcre2-8.0.dylib
dyld: loaded: /usr/lib/libstdc++.6.dylib, cpu-sub-type: 0
dyld: loaded: /opt/local/lib/libncurses.6.dylib
dyld: loaded: /opt/local/lib/libMacportsLegacySupport.dylib
Illegal instruction
programmingkidx commented 7 months ago

@programmingkidx So it is also broken on Tiger:

36-64:~ svacchanda$ tilde Illegal instruction

So tilde is always broken on PowerPC whether it is in Rosetta, Mac OS 10.4, or Mac OS 10.6. The problem is always EXC_BAD_INSTRUCTION.

The problem before was with libunistring. Now it is with libt3widget. I did a grep search for "resultbuf" in libt3widget. Nothing was found. I am not sure where it is coming from. I then looked for the key_bindings_t in libt3widget. I did find it mentioned in src/key_binding.h. The thing is this is a header file and they are usually used for just defining constants and function prototypes. This file has all the function definitions. But this isn't illegal so I don't know what exactly is wrong with this code.

Here is what I found:

class T3_WIDGET_API key_bindings_base_t {
 public:
  virtual ~key_bindings_base_t();
  virtual size_t names_size() const = 0;
  virtual const std::string &names(size_t idx) const = 0;
  virtual bool bind_key(key_t key, const std::string &name) = 0;
};

template <typename T>
class T3_WIDGET_API key_bindings_t : public key_bindings_base_t {
 public:
  struct param_t {
    T action;
    std::string name;
    std::initializer_list<key_t> bound_keys;
  };

  key_bindings_t(std::initializer_list<param_t> actions) {
    for (const param_t &action : actions) {
      name_mapping[action.name] = action.action;
      for (key_t key : action.bound_keys) {
        if (key >= 0) {
          key_bindings[key] = action.action;
        }
      }
    }
  }
  key_bindings_t() {}

I'm not great at C++ so I'm not sure if there are any problems here. One thought I had was about the compiler being used to build tilde. I and pretty much everyone else who installs tilde on Mac OS is probably going to be using clang++. You are using gcc. I was going to suggest trying clang but I don't it would work on PowerPC very well. Then again you said you were able to build and run tilde successfully on Mac 10.6 x86. You used gcc13. So I guess my vote goes with binutils being the problem.

Another thought I had was what if someone tried to build tilde on Linux running on PowerPC? Would that work or have the same problems? I don't expect you to install Linux, but if you did and tried to install tilde, please post your results. If it fails on Linux with gcc13 or another gcc version then it might indicate an issue with binutils. On Linux you would have access to clang. This does not use GNU binutils so we might see some success there.

barracuda156 commented 7 months ago

I and pretty much everyone else who installs tilde on Mac OS is probably going to be using clang++

No version of clang works or worked on any macOS PowerPC. We have flexibility with gcc versions, but no clangs.

Another thought I had was what if someone tried to build tilde on Linux running on PowerPC?

@kencu Ken, maybe you could try building it on Debian and see if it runs normally or crashes?

barracuda156 commented 7 months ago

@programmingkidx I wonder if it is also broken on 10.4–10.5 Intel. If the issue is related to dyld_stub_binder, that was not supported until 10.6 and is not supported on 10.6 ppc (and in Rosetta either).

https://trac.macports.org/ticket/64188 https://lists.macports.org/pipermail/macports-dev/2016-March/032621.html

programmingkidx commented 7 months ago

Sounds like an interesting experiment. I'll see if I can do it myself.

barracuda156 commented 7 months ago

Sounds like an interesting experiment. I'll see if I can do it myself.

Great, please let me know! I would like to fix this, and it seems helpful to know if older Intel works or not. That gonna narrow down possible causes of the problem.

programmingkidx commented 7 months ago

Well I currently ran into a problem. While trying to install software using MacPorts in my Mac OS 10.5 x86 vm I saw an error with M4. I did report the issue but the ticket was closed for being a duplicate of this ticket: https://trac.macports.org/ticket/62994. Would you know a way to avoid having to install M4 thru MacPort? It is a dependency of a lot of software. I was able to make is successfully outside of MacPorts. Unfortunately I don't know of a way to tell MacPorts to use my own M4.

barracuda156 commented 7 months ago

Does that help? https://trac.macports.org/ticket/62994#comment:94

barracuda156 commented 6 months ago

@programmingkidx This should fix the issue with a failing m4 on Leopard: https://github.com/macports/macports-ports/pull/23426

programmingkidx commented 6 months ago

I just made it past the m4 issue. I am still trying to install Tilde on Mac OS 10.5 x86. There is a lot of prerequisites I have to go thru first, so it will take a while.

barracuda156 commented 3 months ago

@programmingkidx Any update on this?

BTW, I am getting this error now, pretty consistently:

(gdb) run
Starting program: /opt/local/bin/tilde 
Reading symbols for shared libraries ++++++++++............................... done

Program received signal EXC_BAD_INSTRUCTION, Illegal instruction/operand.
0x000bd034 in dyld_stub_t3_config_xdg_get_path ()
(gdb) bt
#0  0x000bd034 in dyld_stub_t3_config_xdg_get_path ()
#1  0x000c1d5c in _ZN8t3widget14key_bindings_tINS_7split_t6ActionEEC4ESt16initializer_listINS3_7param_tEE ()
#2  0x000c2020 in _ZN8t3widget14key_bindings_tINS_7split_t6ActionEEC4ESt16initializer_listINS3_7param_tEE ()
#3  0x8fe15d60 in __dyld__ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE ()
#4  0x8fe0f70c in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#5  0x8fe0f668 in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#6  0x8fe0f804 in __dyld__ZN11ImageLoader15runInitializersERKNS_11LinkContextE ()
#7  0x8fe02708 in __dyld__ZN4dyld24initializeMainExecutableEv ()
#8  0x8fe08690 in __dyld__ZN4dyld5_mainEPK11mach_headermiPPKcS5_S5_ ()
#9  0x8fe017cc in __dyld__ZN13dyldbootstrap5startEPK11mach_headeriPPKcl ()
#10 0x8fe01064 in __dyld__dyld_start ()
programmingkidx commented 2 months ago

Sorry I haven't been working on this issue. I think I should try again.

barracuda156 commented 2 months ago

Sorry I haven't been working on this issue. I think I should try again.

@programmingkidx Can we somehow avoid using libtool and link instead normally with the compiler?

programmingkidx commented 2 months ago

A thought did come to my mind about forking all the packages that make up tilde, removing all the newer C++ features, and making them compatible with Mac OS 10.5. I see a lot of advantages to doing things this way.

As for avoiding libtool, that sounds like a good idea.

barracuda156 commented 2 months ago

Why I asked about libtool: I had a case recently when libtool added an unsupported symbol on ppc (infamous dyld stub helper), but simply dropping libtool part from linking command fixed it. Not necessarily related to the present case, but may be worth trying.

programmingkidx commented 2 months ago

Is this a problem with Apple's libtool or with GNU's libtool?

barracuda156 commented 2 months ago

Is this a problem with Apple's libtool or with GNU's libtool?

The code explicitly allows only GNU one. So the port uses that.

Won’t be surprised if it has a bug, perhaps never tested in a decade…

programmingkidx commented 2 months ago

Would you know which version of GNU's libtool is the problem? hint: glibtool --version

barracuda156 commented 2 months ago

2.4.7

https://ports.macports.org/port/libtool

(But if the bug is here, it should be something rather subtle, otherwise everything would be broken which uses GNU libtool, which is not the case, of course.)