Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add PPC/PPC64 support back to Xcode 4.2 under Lion?

I have a Lion (10.7.1) system on which I installed Xcode 4.2. Suppose I have a simple C program helloWorld.c as follows:

#include <stdio.h>
main() {
  printf("hello, world\n");
}

Using this setup, I would like to try to compile helloWorld.c for use on PPC and PPC64 architectures, e.g.:

$ gcc -arch ppc helloWorld.c -o helloWorld

This gives the following error message:

llvm-gcc-4.2: error trying to exec '/usr/bin/../llvm-gcc-4.2/bin/powerpc-apple-darwin11-llvm-gcc-4.2': execvp: No such file or directory

How do I restore support for PowerPC to my Xcode 4 installation?

I have tried the instructions outlined in this previous Stack Overflow post, but these instructions do not work for my Lion installation.

I am using the Xcode 3.2.6 installer located on Apple's dev site.

From the symbolic links, I suspect those instructions work for a 10.6 installation, but not 10.7.

In any case, some of the source files and directories from the Xcode 3.2.6 installation do not exist to make symbolic links from, or are located elsewhere in the Xcode 3 install. (For example, there is no /Xcode3/usr/bin directory from which to link the as binary.)

Has anyone had luck with compiling PPC and PPC64 binaries from a Lion system?

To be awarded the bounty, please write a reasonably detailed answer. For myself, but also for posterity. :)

EDIT - 31 Aug 2011

So I tried the modifications that Laurent pointed to and got further along, but this was not enough to get PPC support working.

I added symbolic links to try to help gcc along in finding the resources it needs:

$ sudo ln -s /Xcode3/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-gcc-4.2 /usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-gcc-4.2 
$ sudo ln -s /Xcode3/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-g++-4.2 /usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-g++-4.2
$ sudo ln -s /Xcode3/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-gcc-4.2 /usr/llvm-gcc-4.2/bin/powerpc-apple-darwin11-llvm-gcc-4.2 
$ sudo ln -s /Xcode3/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-g++-4.2 /usr/llvm-gcc-4.2/bin/powerpc-apple-darwin11-llvm-g++-4.2

When I tried to compile my test app, I get a lot of errors:

$ gcc -arch ppc helloWorld.c -o helloWorld
powerpc-apple-darwin11-llvm-gcc-4.2: 2: No such file or directory
In file included from /usr/include/stdio.h:64,
                 from helloWorld.c:1:
/usr/include/sys/cdefs.h:540:4: error: #error Unknown architecture
In file included from /usr/include/sys/_types.h:33,
                 from /usr/include/_types.h:27,
                 from /usr/include/stdio.h:67,
                 from helloWorld.c:1:
/usr/include/machine/_types.h:36:2: error: #error architecture not supported
In file included from /usr/include/_types.h:27,
                 from /usr/include/stdio.h:67,
                 from helloWorld.c:1:
/usr/include/sys/_types.h:94: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_blkcnt_t’
/usr/include/sys/_types.h:95: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_blksize_t’
/usr/include/sys/_types.h:96: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_dev_t’
/usr/include/sys/_types.h:99: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_gid_t’
/usr/include/sys/_types.h:100: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_id_t’
/usr/include/sys/_types.h:101: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_ino64_t’
/usr/include/sys/_types.h:103: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_ino_t’
/usr/include/sys/_types.h:107: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_mach_port_name_t’
/usr/include/sys/_types.h:108: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_mach_port_t’
/usr/include/sys/_types.h:109: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_mode_t’
/usr/include/sys/_types.h:110: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_off_t’
/usr/include/sys/_types.h:111: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_pid_t’
/usr/include/sys/_types.h:131: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_sigset_t’
/usr/include/sys/_types.h:132: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_suseconds_t’
/usr/include/sys/_types.h:133: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_uid_t’
/usr/include/sys/_types.h:134: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_useconds_t’
...
/usr/include/secure/_stdio.h:62: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__DARWIN_LDBL_COMPAT’
/usr/include/secure/_stdio.h:67: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/secure/_stdio.h:67: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/secure/_stdio.h:68: error: expected declaration specifiers or ‘...’ before ‘va_list’
/usr/include/secure/_stdio.h:69: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__DARWIN_LDBL_COMPAT’
helloWorld.c:3: error: expected declaration specifiers before ‘main’
helloWorld.c:5: error: old-style parameter declarations in prototyped function definition
/usr/include/stdio.h:252: error: parameter name omitted
/usr/include/stdio.h:252: error: parameter name omitted
helloWorld.c:5: error: expected ‘{’ at end of input

Perhaps there compilation options I should add to point to Xcode3 headers, but I'm looking in /Xcode3/usr/include and there's not really much there.

like image 246
Alex Reynolds Avatar asked Aug 21 '11 09:08

Alex Reynolds


1 Answers

If you perform a classical install of Xcode 3.2.6 on Lion, the Xcode toolset is disabled and is not installed. That's why the Xcode3/usr/bin does not exists.

I suggest you to read the following posts (read both of them before going further). They describe a trick to fool the installer into installing everything.

  • Installing Xcode 3.2.6 On Lion
  • Installing Xcode 3.2.6 On Lion Redux

Then, you can apply the trick from the SO entry for restoring PPC support in Xcode.

Note: I have not tested the steps above, but I will be glad to hear your feedback on it. Hope it helps.

Edit 04 Sep. 2011: I have managed to get my hands on a Lion machine to make some experiments and got some results. I have gathered them on my blog.

like image 150
Laurent Etiemble Avatar answered Oct 10 '22 16:10

Laurent Etiemble