Compiling ECL 11.1.1 on Mac OS X 10.7 (Lion) - macos

I have been trying to build ECL under OS X 10.7 and I have been
running into trouble. When I try building it I end up getting a
segfault on the ecl_min stage.
I configure with the following line:
./configure --build=x86_64 --target=x86_64 --prefix=`pwd`/install_ecl
CC=/Developer/usr/bin/gcc-4.2
And the compile fails with:
if [ -f CROSS-COMPILER ]; then \
./CROSS-COMPILER compile; \
else \
ECLDIR=`pwd`/ ./ecl_min compile; \
fi
/bin/sh: line 1: 17433 Segmentation fault: 11 ECLDIR=`pwd`/ ./ecl_min compile
I have tried building gmp and boehm-gc externally and not using the
included ones, but unfortunately it ended up with the same results. I
have also tried the default llvm-gcc without much luck either.
Has anyone been able to compile ECL under Lion, and if so, what configure options / patches did you need to apply.
Update:
I was able to compile thanks to the accepted answer below. Here is the scripts that I used (Note: This is from a fresh git clone of ECL):
#!/bin/sh
ECL_INSTALLDIR="`pwd`/install_ecl"
mkdir -p $ECL_INSTALLDIR
./configure\
--prefix=$ECL_INSTALLDIR\
--enable-boehm\
--enable-unicode=no\
CC=/Developer/usr/bin/gcc\
CXX=/Developer/usr/bin/g++\
CFLAGS="$CFLAGS"
LDFLAGS="$LDFLAGS"
make && make install

This problem has been fixed in git/CVS. As explained above, the cause for the miscompilation was the version of our garbage collector: we shipped the last one available: 7.1, but this does not work with OS X Lion. ECL now ships with two versions (7.1 and 7.2-cvs), using the newest one in OS X Lion. In other words, ECL from git/CVS (http://ecls.sourceforge.net/download.html) should compile and run out of the box.

This page describes the two causes of the problem (an issue with the compiler, and an issue with garbage collector compatibility), and offers a temporary solution until the issue itself is fixed. The instructions come down to:
Download a new build of the Boehm-Weiser garbage collector library, apply a patch (you can get a link to download both the library and the patch from that page as well), and install it somewhere
Configure ECL with these extra options:
--enable-boehm=system
CPPFLAGS=-I/location/for/library/include
LDFLAGS=-L/location/for/library/lib
Where /location/for/library is the prefix you used to install the garbage collector.
And then it should build properly.
I also found this MacPorts ticket which seems to be tracking this issue; check there for future updates to see if it will be fixed.

Related

GCC won't compile anything on macOS

Recently (since Catalina was released and xcode updated, but I am still running Mojave) I have found the gcc, installed via macports, has broken. I get errors saying that the system includes cannot be found:
ld: library not found for -lSystem
I have tried the solution here: Can't compile C program on a Mac after upgrade to Mojave - but when I install macOS_SDK_headers_for_macOS_10.14.pkg it doesn't actually create anything in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs ; all I see in there is the 10.15 (Catalina) sdk!
If I instead just sym link MacOSX10.14.sdk to MacOSX10.15.sdk (possibly not a great idea), I get a different set of errors:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/wchar.h:90,
from /opt/local/include/gcc8/c++/cwchar:44,
from /opt/local/include/gcc8/c++/bits/postypes.h:40,
from /opt/local/include/gcc8/c++/iosfwd:40,
from /opt/local/include/gcc8/c++/ios:38,
from /opt/local/include/gcc8/c++/ostream:38,
from /opt/local/include/gcc8/c++/iostream:39,
from /Users/pae9/soft/src/cmake/LIGO_support/restrictHealMap.cpp:4:
/opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/8.3.0/include-fixed/stdio.h:222:7: error: conflicting declaration of 'char* ctermid(char*)' with 'C' linkage
char *ctermid(char *);
In other words, now it appears that the macports headers are conflicting with the xcode ones.
I never had a problem before; I think this issue dates to the last xcode update (currently on Version 11.2 (11B52))
Any thoughts or suggestions very welcome - I'd really like to be able to go back to compiling code using gcc!
FYI I'm using gcc7 (from macports), for consistency with the linux servers which are my actual live systems, but I have tried gcc 8 and 9 and get the same results.
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
sudo ln -s MacOSX10.15.sdk MacOSX10.14.sdk
OK, it seems that if I do the ln -s as above, and also move #include to be the first include in all my files, the problem goes away.
This looks to me like a serious problem in the Apple SDK headers, because surely conflicting definitions like this shouldn't occur...?

Fortran codes won't compile on Mac with gfortran

I recently moved from the SGI, Sun workstation environment to a Mac. SGI and Sun came with Fortran compilers so I have maybe 100 small f77 codes I wrote over the years for post-processing and analysis of simulated data. I was hoping to get these codes running on my iMac with gfortran. Most of these are very simple codes but I can't get them to compile and execute. I tried starting with the basics and wrote the Hello World code from a gfortran help page. My code, fortran.f is:
program helloworld
print *, "hello world"
end program helloworld
When I tried compiling this according to the example I typed:
gfortran fortran.f
But I keep getting the error message:
FATAL:/opt/local/bin/../libexec/as/x86_64/as: I don't understand 'm' flag!
This is the same error message I get on my other codes. Can someone tell me what I'm doing wrong? I can't think of a simpler example but I can't seem to get it to work.
When it comes to macOS, I think that building form sources is the best approach you can have. You can achieve that quite easily by downloading and compiling GFortran as part of GCC directly from: https://gcc.gnu.org/wiki/GFortran
However, there are few things you have to take care of:
make sure you have XCode installed, you can get it here
XCode
XCode is free of charge
Make sure you have command line tools
You can get them either from developer.apple.com
Command Line Tools
or directly from XCode. It might be that XCode will tell you to install Command Line Tools upon first execution
In the past, running command like "svn", when Command Line Tools were not installed, also triggered the installation.
Compile GCC
> ./configure --prefix=$HOME/opt/usr/local
> make all
> make install
Alternatively, you can install using macOS package from GFortran
gfortran-6.3-Sierra.dmg
Fully working sample with Fortran based MPI code:
http://www.owsiak.org/running-open-mpi-on-macos/
If your gfortran was installed a long time ago and you have updated macOS since installing, it may need re-installing to get correctly aligned and linked with the latest macOS tools and libraries.
My advice would be to:
uninstall gfortran,
check that Xcode and its command line tools are up-to-date,
re-install gfortran.
Hints for each of those steps follow:
Note that gfortran is a part of GCC - the "GNU Compiler Collection".
If you installed gfortran via homebrew, you can remove it with:
brew rm gcc
You can update Xcode by by going to AppStore and clicking Updates at top-right.
The Xcode Command Line tools include make and git and command-line versions of the compilers. You can install/update the Xcode command line tools with:
xcode-select --install
You can install gfortran with homebrew using:
brew install gcc
When you are finished, you should make sure that your PATH includes /usr/local/bin near the start and that there are no errors when you run:
brew doctor
which is a brilliant utility that checks your homebrew configuration is correct.
All I had to do was change the path.
Initially, my PATH was something like
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
Because of this reason, the default assembler (as) was not called which is in the /usr/bin directory.
To enable the call to the right assembler (as), I had to add /usr/bin to the PATH in front of (before) /opt/local/bin, i.e. on a Mac this can be added by editing ~/.bash_profile such that one's $PATH looks like
/usr/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
Once edited, execute at your command prompt:
source /etc/bash_profile
This worked for me.

YouCompleteMe Clang Support Mavericks

I installed YouCompleteMe for VIM via Vundle on my Mac with Mavericks. After Vundle did its magic i ran
./install.sh --clang-completer
which worked without any errors. The Python completion works fine, too. But the C Lang Family support does not seem to work. Also running
./run_tests.sh
gives me
Your C++ compiler supports C++11, compiling in that mode.
-- Found PythonLibs: /usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/Python (found suitable version "2.7.7", minimum required is "2.6")
NOT using libclang, no semantic completion for C/C++/ObjC will be available
Does anybody know how to solve that problem?
Don't run the 2nd command
./run_tests.sh
It's will re-compile ycm_*.so without --clang-completer (that is default option).
To fix it, install again:
./install.sh --clang-completer
add your clang_library_path in .vimrc,such as
let g:clang_library_path='/usr/lib/llvm-3.8/lib/'

Can't upgrade gcc on Mac

So this is after having dropped $30 for Mac OS 10.7 and having downloaded XCode 4.3.2. After installing the command line tools, the installed version of gcc is still 4.2.4. I need 4.7. I've installed it and set the g++ link in /usr/bin to it. But when I try to compile any program via QtCreator, I get
unrecognized command line option -Xarch_x86_64
I found this discussed in a 3-year-old bug report here, but I really couldn't follow all the different shell commands etc. and my attempt to install liblastfm failed with the same error. The comment here,
The problem is that the GCC/G++ that is normally used to compile stuff
on Macs is actually just a wrapper.
And this wrapper has Mac-Only arguments like -Xarch_x86_64, which then
get converted into the correct args.
Seems like it might be hitting the nail on the head. Aaargh! Surely there has to be some way to get around this?
I created a custom makespec - in QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs, I copied the macx-g++ folder to macx-g++47. I then removed the "include(../common/g++macx.conf)" from that and included it's contents, except for the part that generates the error (i.e. the -X... thing).
I also finished with
QMAKE_CC = gcc-mp-4.7
QMAKE_CXX = g++-mp-4.7
QMAKE_LINK = $$QMAKE_CXX
QMAKE_LINK_SHLIB = $$QMAKE_CXX
QMAKE_LINK_C = $$QMAKE_CC
QMAKE_LINK_C_SHLIB = $$QMAKE_CC
...which is similar to the spec for macx-g++42.
Now, if I add '-spec macx-g++47' to the qmake args, it works.
A lot of effort for something simple...would love to know a better way.
There are several sources for newer gcc versions for OSX. Here is a small selection:
http://hpc.sourceforge.net/ (currently gcc 4.8, previous versions might also be available)
http://gcc.gnu.org/wiki/GFortranBinaries (has gcc 4.7.0 binary installer)
I assume that you did install the command line tools from within Xcode. Apple/Xcode is not always up to date with gcc, stability is more important here than bleeding edge.

How can we restore ppc/ppc64 as well as full 10.4/10.5 SDK support to Xcode 4?

Since Apple only ships SDK 10.6 with Xcode4, developing PPC applications with Xcode4 became impossible. While it is possible to develop applications with Xcode4 that can also run on 10.5 and maybe even on 10.4 systems (by selecting SDK 10.6, but deployment target 10.5 or 10.4), they will only run on Intel Macs because you need at least SDK 10.5 for building PPC applications.
Further there are some rare cases, where you really need to build against an SDK prior to 10.6 for full platform support, e.g. if certain deprecated functionality has vanished completely from the 10.6 SDK, but you'll have to use it and dynamic linking is not always the best option in those cases. Also linking against an earlier SDK sometimes will ease development as functionality you are not supposed to use, as it would cause incompatibility to earlier OS versions, won't be available and any attempt to use it anyhow immediately leads to compiler or linker errors.
Last but not least Apple has also removed GCC 4.0 support from Xcode4, which may be necessary for certain software to build correctly and Apple has never allowed to compile software with GCC 4.2 when using SDK 10.4, even though I hardly believe that this would really cause any issues, after all software built with GCC 4.2 and SDK 10.6 can also run on Mac OS 10.4 without any issues as long as the deployment target has been set correctly and no functionality that is unavailable under MacOS 10.4 has been used.
Of course you can always have a parallel installation of Xcode3 next to Xcode4, but that means you must forgo all the (great?) new features of Xcode4 and keep working with the outdated Xcode3 IDE. It would certainly be much better if you could also manage all your old projects within the same IDE as your new ones and benefit from any new features available. Not all projects can be made 10.6 or Intel only in the foreseeable future. Further I'm strictly against abolishing support for older platforms earlier than would be really necessary.
Can we restore this functionality to Xcode4?
The quick answer is: Yes, we can!
Before I get to the "how it is done" part, here are some notes about my patch/hack/fix. Right from the start the major goals have been:
Keep all modifications to an absolute minimum.
We want to keep the Xcode setups as original as possible.
By all means, try to avoid patching or modifying any files.
We want all files to stay untouched and keep their original content.
Try to avoid moving or copying files around, unless absolutely necessary.
I was able to keep all those goals. Almost everything is done by creating symlinks. Only a single existing symlink had to be replaced and we'll back it up before replacement, just in case.
If you are no expert on terminal operations, I strongly advise you to copy/paste all terminal commands from my reply to your terminal, to avoid typos. Bear in mind that even spacing, quoting and especially capitalization can be important. Copy/paste them line by line, never more than one line at once and hit return after each pasted line to execute the command. Should any operation ever prompt you for a password, this will be the password of the currently logged in administrator user (your keystrokes are not displayed while typing, this is normal, don't worry, just keep typing the password and hit return; re-try if you had a typo and get prompted again).
Prerequisite
Before we can start, make sure the following conditions are true:
You are logged in as an administrator user.
You have started Terminal.app (Applications/Utilities) and a terminal window is open.
You have a copy of the Xcode3 (e.g. 3.2.5) and Xcode4 disk image (DMG) or installer available.
If you already have either Xcode version installed, consider uninstalling it first, so you can start with a fresh/clean setup. Uninstalling Xcode will not remove your preferences, color scheme or key binding customizations. Ideally you'd start with a system that has no Xcode version (neither 3 nor 4) currently installed.
Step 1: Installing Xcode3
Important: Do not install "System Tools" or "Unix Development" package of Xcode3.
Whether you want to install "Mac OS X 10.4 SDK" and/or "Documentation" is up to you. If that is a Xcode3 with iOS SDKs, whether you install those or not is also up to you.
You are free to choose any destination folder for your installation. For this guide I have chosen "/Xcode3", but feel free to pick a different one. Just make sure to alter all terminal commands accordingly.
The order of the steps given here is usually not really important, but I strongly advise you to not swap step 1 and step 2. Xcode always installs a couple of files outside of the chosen destination folder and trust me, in the end you want the Xcode4 versions of those files on your disk. By installing Xcode3 before Xcode4, you can be sure that Xcode4 will overwrite those files if necessary. I once swapped steps 1 and 2 and in the end I had some rather strange issues that might have been related to the incorrect order (I cannot say for sure, but after re-installing in the correct order the issues were gone).
Step 2: Installing Xcode4
Chose any packets you like. Installing "System Tools" is advisable, but not strictly necessary (though most people will sooner or later miss that functionality).
Again, feel free to pick any target folder you like. For this guide I chose the normal target folder "/Developer", if you take a different one, alter all terminal commands accordingly.
Step 3: Restoring 10.4/10.5 SDK Support
Switch to your terminal window and run the following commands:
cd /Developer/SDKs
sudo ln -s /Xcode3/SDKs/MacOSX10.4u.sdk .
sudo ln -s /Xcode3/SDKs/MacOSX10.5.sdk .
Of course only run the command for 10.4u if you also installed SDK 10.4 in step 1.
This is enough to bring the SDKs 10.5 (and possibly 10.4) back to the selection list in Xcode4. Give it a try if you like. Fire up Xcode4, open a project, try changing the selected SDK. That was easy, huh? Be sure to close Xcode4 again (the application, not just the window) before proceeding with the next step.
Step 4: Restoring GCC 4.0 Support
If you have not installed MacOS 10.4 SDK or if you don't plan to ever use it, you can safely skip this step and proceed with step 5.
To use SDK 10.4, you'll have to use GCC 4.0, GCC 4.2 won't work. Apple claims that GCC 4.2 is not compatible with SDK 10.4, well, if you ask me, this is a hoax. I have already overwritten this limitations more than once and there was never the tiniest issue because of it. It would be easy to modify SDK 10.4 so that Xcode will allow you to use GCC 4.2 for it, but my goal was to avoid all file modifications, so we just add GCC 4.0 support back to Xcode, which is also a good thing, because some projects really depend on GCC 4.0 (e.g. there are some bugs in GCC 4.2 that prevent valid inline assembly code to compile without errors, while the same code compiles flawlessly on GCC 4.0 and GCC 4.4).
Back to terminal:
cd /Developer/usr/bin
sudo ln -s /Xcode3/usr/bin/*4.0* .
cd /Developer/usr/libexec/gcc/powerpc-apple-darwin10
sudo ln -s /Xcode3/usr/libexec/gcc/powerpc-apple-darwin10/4.0.1 .
Right now we have restored full GCC 4.0 support except for the fact that GCC 4.0 is still not selectable in Xcode4. That is because Xcode4 has no GCC 4.0 compiler plug-in any longer. Fortunately the Xcode3 plug-in also works in Xcode4, only the position has radically changed. Apple now hides those plug-ins deep within a bundle and only plug-ins there seem to work, placing them to their old position seems to have no effect.
cd /Developer/Library/Xcode/PrivatePlugIns
cd Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins
sudo ln -s "/Xcode3/Library/Xcode/Plug-ins/GCC 4.0.xcplugin" .
Now fire up Xcode4 again, open a project and try selecting the compiler. You should have GCC 4.0 back on the list. Now you can actually already select SDK 10.4 or 10.5, GCC 4.0 and you should have no issue to build a PPC binary. Just select "Other..." for the "Architecture" build setting and manually enter "ppc", then alter "Valid Architectures" to also include "ppc". We are almost done, except that trying to build a PPC binary using GCC 4.2 and SDK 10.5 will still fail.
Step 5: Restoring PPC Support for GCC 4.2
Since Apple is only supporting Intel platforms in Xcode4, not all GCC 4.2 tools have been built with PPC support. There is one important tool that has no PPC support, the tool is named "as" and it is the GNU Assembler. To compile ppc/ppc64 binaries with GCC 4.2 we need to use an "as" version with ppc/ppc64 support. This is the one and only file (actually it also a symlink) we have to first move aside (making a backup copy) before we can replace it by a symlink:
cd /Developer/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1
sudo mv as as.bak
sudo ln -s /Xcode3/usr/bin/as .
Step 6: There is No Step 6
That's all folks. Considering how easy that was, you can imagine that Apple has certainly not dropped SDK 10.4/10.5 or ppc/ppc64 or GCC 4.0 support because this was a necessity, they dropped all that because they wanted to drop it.
I hope this setup works as well for you as it does for me. I have been able to compile all my old projects in Xcode4 without any major changes, except for having to alter a search path here and there.
PS:
It may look strange that I answer my own question here, but since I have found out how to solve this problem all by myself, I'd like to share my knowledge with the community, because I believe this is really valuable input to all MacOS developers out there. This question has been asked so many times in so many places and so far I have never seen anyone coming up with a similar fix. Share the wealth, spread the knowledge and so on, you know what I mean.
If You Still Have Issues/Questions:
If you have additional questions regarding this topic or if you still have problems to build your old projects correctly, please do what Stack Overflow has been designed for: Click on "Ask Question" in the upper right corner of this page and create a new question. That way the whole community can help you solving those issues, since the issues may not directly (maybe not even indirectly) be related to this hack.
I would recommend you mention the fact that you did apply this hack at the very beginning of your question. Maybe you even want to directly link to this question, so that people, who never heard of this hack, can easily look it up. Otherwise most people will get rather confused when you mention SDK 10.4/10.5, PPC or GCC 4.0 in combination with Xcode4, which officially supports neither of these. You might get rather stupid comments instead of decent replies if you forget to mention this hack.
Please refrain from posting your questions or issues here either as replies or as comments. Posting them as replies makes no sense because they are no replies and there is no way how people can reply back to you, other then using comments, and comments may not offer enough room for a decent reply to your question or a decent solution to your problem. And posting them as comments means you are limited to very little room and tracking reply comments will be hard as comments have no tree-like hierarchy (further they will still offer to little room for decent replies/solutions). Thank you.
Of course other kind of comments as well as better replies to the original question are always welcome ;-)
Another easy way with only Xcode4, Xcode3 is no longer needed.
$ sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gcc/darwin/ppc /Developer/usr/libexec/gcc/darwin
$ sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gcc/darwin/ppc /usr/libexec/gcc/darwin
EDITS:
For Xcode 4.1,
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gcc/darwin/ppc /Developer/usr/libexec/gcc/darwin
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gcc/darwin/ppc /usr/libexec/gcc/darwin
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/powerpc-apple-darwin10-cpp-4.2.1 /usr/bin/powerpc-apple-darwin11-cpp-4.2.1
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/powerpc-apple-darwin10-gcc-4.2.1 /usr/bin/powerpc-apple-darwin11-gcc-4.2.1
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/powerpc-apple-darwin10-g++-4.2.1 /usr/bin/powerpc-apple-darwin11-g++-4.2.1
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/powerpc-apple-darwin10-cpp-4.2.1 /Developer/usr/bin/powerpc-apple-darwin11-cpp-4.2.1
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/powerpc-apple-darwin10-gcc-4.2.1 /Developer/usr/bin/powerpc-apple-darwin11-gcc-4.2.1
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/powerpc-apple-darwin10-g++-4.2.1 /Developer/usr/bin/powerpc-apple-darwin11-g++-4.2.1
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/powerpc-apple-darwin10 /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc
You can use gcc-4.2 only for PowerPC. And “-isysroot /Developer/SDKs/MacOSX10.6.sdk” option is required, because 10.7 SDK doesn't support PowerPC any more.
I've gathered together all the information from this page, Mac OS X Hints, splhack.org, and the other sources cited here, and put together a set of BASH scripts which automate the process of restoring PPC and GCC 4.0 support using either an XCode 3 installation or just XCode 4's own iPhone platform files.
As always, use with caution! and please contribute any fixes or improvements. These scripts have only been tested on my own system as of this posting.
You can download them from GitHub:
https://github.com/thinkyhead/Legacy-XCode-Scripts
If you want gcc to work from the command line as well, (as well as the above) you'll also need to:
cd /usr/libexec/gcc/powerpc-apple-darwin10/4.2.1
sudo mv as as.bak
sudo ln -s /Xcode3/usr/bin/as .
This still works with Xcode 4.3.2 from the AppStore - the version where everything is self-contained in an App bundle. As in the original hint, install Xcode 3.2.6 first* and then download Xcode 4 from the AppStore.
Then do the following symlink magic:
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
ln -s /Developer/Xcode3.2.6/SDKs/MacOSX10.5.sdk .
cd /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/bin/
ln -s /Developer/Xcode3.2.5/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-g* .
mv powerpc-apple-darwin10-llvm-gcc-4.2 powerpc-apple-darwin11-llvm-gcc-4.2
mv powerpc-apple-darwin10-llvm-g++-4.2 powerpc-apple-darwin11-llvm-g++-4.2
The last two lines rename darwin10 to darwin11 in the symlink - I'm guessing future versions of OS X will require this to be updated as appropriate.
To install Xcode 3.2.x on Lion, mount the Xcode disk image, open Terminal, enter the commands (using bash, or the equivalent commands if you've changed your default shell):
export COMMAND_LINE_INSTALL=1
open "/Volumes/Xcode and iOS SDK/Xcode and iOS SDK.mpkg"
You'll also need to set the clock back to a date prior to 31st March 2012 otherwise security certificates will fail validation during installation. You can safely change the date back again after installation obviously!
Frédéric Devernay has a GitHub project called xcodelegacy which works fantastic for me on Xcode 5.1.1, and needs very little work to get it going, just some downloading.
Using his project, I've managed to create universal binaries containing both ppc and i386 architectures compiled with the 10.4 SDK using GCC 4.0, all from within Xcode 5.1.1 running on Yosemite.
I've verified myself that the universal binaries created work fine on 10.5 Leopard and on Yosemite itself.
Home page here: http://devernay.free.fr/hacks/xcodelegacy
Git hub project here: https://github.com/devernay/xcodelegacy
In case someone need to restore old SDKs and PPC compiler in Xcode 4.3 and 4.5, this is a script I came up with. Note you need to set the path to the Xcode app bundle and path to Xcode 3.2.6 install at the beginning of the script.
#!/bin/bash
XCODE="/Applications/Xcode45-DP1.app"
XCODE3="/Xcode3"
# restore SDKs
cd "$XCODE/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs"
sudo ln -s "$XCODE3/SDKs/MacOSX10.4u.sdk" .
sudo ln -s "$XCODE3/SDKs/MacOSX10.5.sdk" .
sudo ln -s "$XCODE3/SDKs/MacOSX10.6.sdk" .
# restore gcc 4.0
cd "$XCODE/Contents/Developer/usr/bin"
sudo ln -s "$XCODE3/usr/bin/"*4.0* .
sudo ln -s "powerpc-apple-darwin10-g++-4.0.1" "powerpc-apple-darwin11-g++-4.0.1"
sudo ln -s "powerpc-apple-darwin10-gcc-4.0.1" "powerpc-apple-darwin11-gcc-4.0.1"
# restore Xcode option
cd "$XCODE/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins"
sudo ln -s "$XCODE3/Library/Xcode/Plug-ins/GCC 4.0.xcplugin" .
You don't need to symlink 10.6 SDK if you are using Xcode 4.3 since it comes with one.
Also the script does not restore gcc 4.2 since there are a lot of filename conflicts doing that. My goal is to restore PPC compiler and 4.0 is good enough for me.
It would be useful to have a package to just install these files into an XCode 4 implementation. (or a tarball).
FYI: 3.2.6 of Xcode3 does not include an as with ppc architecture. But I had a backup of Leopard on my computer. So I copied that one, seems to work. (Use /usr/libexec/gcc/darwin/ppc/as ).
Considering that both gcc and as are open source the only stuff that may not be redistributable is the xcode plugin and the 10.4 SDK right?

Resources