Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Useful tips for ppc and i386 in XCode12 and others #68

Open
kspes opened this issue Dec 30, 2023 · 0 comments
Open

Useful tips for ppc and i386 in XCode12 and others #68

kspes opened this issue Dec 30, 2023 · 0 comments

Comments

@kspes
Copy link

kspes commented Dec 30, 2023

Hi Everyone,
this is not an "issue" but just useful info which may hopefully end up in improvements to the script, but in the mean time, here it is in text form:

Xcode 12 blocks compilation of i386, even if you have a working compiler imported that supports i386.
Through painful trial and error, I traced which file you need to change in order to make it work:

  • Open: /Applications/Xcode12.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/PrivatePlugIns/IDEOSXSupportCore.ideplugin/Contents/Resources/MacOSX Architectures.xcspec
  • Find: DeprecatedError = YES;
  • Change to: DeprecatedError = NO;

GCC 4.2 i386 creates linker problems
Once you get i386 working with xcode12, you'll have problems linking, with weird output.
The solution is to use the i386 assembler from xcode 3.2.6 and replace the one in xcode12 that XcodeLegacy.sh has put in

  • go to /Applications/Xcode12.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec/as/i386
  • rename as to as_old
  • copy i386 assembler from xcode3.2.6: /Developer/usr/libexec/gcc/darwin/i386/as

GCC 4.2 compiles ppc but resulting binary lists as ppc7400
"ppc" is G3 compatible while "ppc7400" is G4.
After a while I figured out that the compiler provides proper binaries but the final linker messes it up!
The reason is that gcc4.2 links with crt3.o which only has ppc7400 in it. So to solve it, just take crc3.o from gcc4.0 (which is ppc) and merge it into a fat binary with gcc4.2'sn crt3.o. After that you get proper ppc binaries that I confirm work properly on actual G3 devices.

commands:

  • mv /Applications/Xcode12.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/gcc/powerpc-apple-darwin10/4.2.1/crt3.o /Applications/Xcode12.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/gcc/powerpc-apple-darwin10/4.2.1/crt3_old_ppc7400_only.o
  • lipo /Applications/Xcode12.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/gcc/powerpc-apple-darwin10/4.0.1/crt3.o /Applications/Xcode12.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/gcc/powerpc-apple-darwin10/4.2.1/crt3_old_ppc7400_only.o -create -output /Users/kreso/Downloads/GPP/lib/gcc/powerpc-apple-darwin10/4.2.1/crt3.o

Linker crashes with 'Bus Error 10'
g++-4.2 is called by xcode 12 to link the final binary, and it gives wrong parameters (-target instead of -arch) and some params and environment variables are missing compared to what xcode 3.2.6 does when installed on osx 10.6.8.
So I made a python script that you replace g++-4.2 with to intercept and transform linker calls and forward them to the old binary. File attached

Instructions:

  • rename g++-4.2 into g++-4.2_old, xcode 12 calls it with wrong arguments when linking so we have to put our middleman script in it's place to handle that
  • extract hacked_linker_g++-4.2.zip, it'll create a file 'g++-4.2', put in where the old one was. it's a python script
  • make it executable using chmod +x <path_to_g++-4.2>

Libtool merges ppc and ppc7400 when creating a fat binary
If you need to compile a binary that has G3 and G4 code separate, then you'll find that libtool messes this up, with many warnings. Basically it removes ppc7400 and just leaves in ppc. To solve this, you'll need to replace libtool file in xcode12's gcc toolchain with a script that uses "lipo" instead of libtool when this situation is detected. I'm attaching a python script I wrote.

  • Go to /Applications/Xcode12.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  • rename libtool to libtool_old
  • put my script there as 'libtool' and make it executable

That's it from me, let me know if you run into any further trouble and I'll try to help out, I spent 2 days on this, but in the end I have a working xcode12 that I use to compile for powerpc, i386 and x86_64, targeting osx 10.4 and it works like a charm! Thanks xcodelegacy! Hope my contribution will have value to someone else :)

Attachments:
hacked_libtool.zip
hacked_linker_g++-4.2.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant