I'm trying to get a cross-compiler for my Intel MacBook Pro running macOS Mojave to compile for PowerPC G5 Macs. I've tried to follow a modified version of the steps from here but my configure command fails with this error message:

Assertion failed: (*offset_ptr == end_prologue_offset), function ParsePrologue, file /SourceCache/dwarf_utilities/dwarf_utilities-121.1/source/DWARFDebugLine.cpp, line 619.
collect2: fatal error: dsymutil terminated with signal 6 [Abort trap: 6]
compilation terminated.
*** The command 'gcc-8 -o conftest -g -O2   conftest.c' failed.
*** You must set the environment variable CC to a working compiler.

My configure command was:

CC=gcc-8 CXX=g++-8 ../gcc-8.3.0/configure \    
--prefix=/opt/gcc/ppc/8 --disable-nls --disable-multilib --enable-languages=c,c++,objc,obj-c++,lto --with-dwarf2 \
--target=powerpc64-apple-darwin10.8.0 --with-sysroot=/Developer/SDKs/MacOSX10.5.sdk \
CFLAGS_FOR_TARGET="-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -g -O2" \
LDFLAGS_FOR_TARGET="-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5" \
CXXFLAGS_FOR_TARGET="-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -g -O2"

My config log (available here) states this after the error message:

configure:5025: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| #if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
| #error -static-libstdc++ not implemented
| #endif
| int main() {}

I am using the GCC 8.3.0 source code and the script-downloaded mpfr (3.1.4), gmp (6.1.0), mpc (1.0.3), and isl (0.18), as well as GCC and G++ version 8.3.0_2 installed using Homebrew as the actual compilers (accessible through gcc-8 and g++-8, respectively). I also have the Mac OS X 10.5 SDK installed via XcodeLegacy and an extracted dsymutil from Xcode 6.4.

The 32-bit PowerPC configuration command given in the original article also gives the same failure output, as do any other commands when a target is specified (e.g. powerpc64-unknown-linux-gnu failed, as did x86_64-unknown-linux-gnu and x86_64-apple-darwin18.5.0). This exact command (without target specification) completed successfully:

CC=gcc-8 CXX=g++-8 ../gcc-8.3.0/configure \
--prefix=/opt/gcc/x86/8 --disable-nls --disable-multilib --enable-languages=c,c++,objc,obj-c++,lto --with-dwarf2

I also noticed that in the output of the configuration of the command without a specified target, it stated that g++ accepted -static-libstdc++ -static-libgcc while in the cross-compiler configuration command outputs it stated that it didn't. I looked in the configure script to see what it actually did there, and it tries to compile and then link the sample C++ code, which ends up failing. Thus, the problem seems to be to either be a lack of the static libraries installed or an issue with the linker or compiler.

EDIT: I also have Xcode 10.2.1 and Command Line Tools for Xcode 10.2.1 (10E1001) installed.

EDIT 2: I tried configuring a Linux x86-64 build with the command:

CC=gcc-8 CXX=g++-8 ../gcc-8.3.0/configure \
--prefix=/opt/gcc/x86-64/8 --disable-nls --disable-multilib --enable-languages=c,c++,objc,obj-c++,lto --with-dwarf2 \

without first adding the old version of dsymutil to my path (which I didn't remove when I tried the command the first time), which did successfully create a configuration file (note that macOS also comes with a newer version of dysmutil that doesn't support PowerPC devices anymore, and that the older version's location was specifically added to the front of the PATH so that it was found first).

Additionally, the output stated that g++ did accept -static-libstdc++ -static-libgcc as well. As I'm using the same compiler, I would think that this would suggest that the issue lies in the Mac linker or static libraries. However, from what I understand of dysmutil and the console logs, it isn't the cause of the failure but fails as a result of it, so I don't know the significance of this. I also tried invoking the failed command itself directly with the old version of dysmutil in my path and without it (with no other changes), and it gives the same error message (assertion failed, etc.) with it and no error message without it.

EDIT 3: So I did some searching, and apparently static-libstdc++ and static-libgcc are part of GCC and require GNU binutils to be built (which I have). I was using ld as defined in the article (which basically just calls the Apple system ld if targeting PowerPC) as GNU binutils' ld does not support Darwin. Could this be the source of the issue?

0 Answers