To Move On, or Not…

xcode.jpg

I've been updating some C++ code this afternoon to use Xcode 3.2.2 and the new LLVM compiler that comes with it and I ran into some interesting new warnings and one real issue. The biggest source of the new warnings were the use of char * as a constant. The warning was saying that it wasn't going to cast the string into a char *. For example, the following generates a warning in Xcode 3.2.2:

  char *name = "Bob";

but the fix is pretty easy:

  const char *name = "Bob";

There was another problem with calling methods with optional parameters and needing the interface to declare the argument const. It was easy enough to fix as well.

The biggie was that when I installed Xcode 3.2.2 I didn't include the complete 10.5 compatibility package - including the PowerPC code. And that was a real issue. I spent a ton of time trying to understand what the error message was saying. It was saying __Unwind_Resume was undefined in all the modules, and that had nothing to do with the PPC libraries not being installed.

Yet, it did.

I read in a few places that the link problem was from a bad compiler, or something, and so I got to thinking - What if Xcode 3.2.2 wasn't PPC-aware? And so I checked. And its libraries are all a single CPU type. It's gotta be the case that in one of the installs of Xcode, I didn't ask it to install everything for 10.5, and that dropped the PPC libraries. The compiler generated the code OK, but the link failed.

OK... now I just need to download Xcode 3.2.2 again and re-install it to get the 10.5 libraries for PPC back. I hope it's easier than it sounds.

The alternative is to drop PPC support for the code and just "Move on". I'm not really ready to do that if I don't have to. But there's nothing holding me to PPC and 10.5, but at the same time, there's nothing that says I need Intel-only or 10.6. SO for now, I think I'll try to get it back.

[6/23] UPDATE: It's not nearly as easy to build for PPC and Intel in Snow Leopard. I can still do it, but it's getting to be more and more of a pain. I can see that the legacy systems are just dropping off. While I'll bet I can still build apps with Xcode for PPC, the command-line args are getting tougher to master.

For now, when I used to make my shared library, I had the following arguments in the Makefile:

LDD_32 = -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch i386 \
         -install_name libCKit.$(SO_EXT) -current_version 1.0.0 \
         -compatibility_version 1.0.0
LDD_64 = -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch x86_64 \
         -install_name libCKit.$(SO_EXT) -current_version 1.0.0 \
         -compatibility_version 1.0.0

but to get it working with Xcode 3.2.3 and Snow Leopard - even with all the old development tools, I had to change this to:

LDD_32 = -lgcc_s.1 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -arch ppc \
         -arch i386
LDD_64 = -lgcc_s.1 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -arch ppc64 \
         -arch x86_64

Interestingly, I didn't need the current_version or compatibility_version, but it's nice to have them if you want that information in the code. In my code, I leave in the two values just to be complete:

LDD_32 = -lgcc_s.1 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -arch ppc \
         -arch i386 -install_name libCKit.$(SO_EXT) -current_version 1.0.0 \
         -compatibility_version 1.0.0
LDD_64 = -lgcc_s.1 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -arch ppc \
         -arch x86_64 -install_name libCKit.$(SO_EXT) -current_version 1.0.0 \
         -compatibility_version 1.0.0

I also changed the defines for the 64-bit build from:

CXX_64 = -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch x86_64

to:

CXX_64 = -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch ppc64 -arch x86_64

And then for the tests that only need to work on the one architecture:

CXX_DEFS = -D_REENTRANT -O2 -isysroot /Developer/SDKs/MacOSX10.5.sdk \
           -arch ppc -arch i386
OS_LIBS = -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk

to:

CXX_DEFS = -D_REENTRANT -O2 -arch ppc -arch i386
OS_LIBS = 

as I was getting problems with linking libcrt.1.10.6 and the only way to get it was to let the system default to it's libraries. It's not ideal, but it's working.

The next step is just to remove PPC support and be Intel-only.

[6/24] UPDATE: To get better universal binaries out of Xcode, I'm going to have to switch to Xcode as the build system. Why? The LLVM compiler. Using GCC, I'm not going to be able to make 10.4u binaries as that was GCC 3.3, and Xcode 3.2.3 is on GCC 4.2. Pretty soon, the GCC will move away from that, and I'll be left with nothing to easily compile with. Except the LLVM compiler. Unfortunately, the documentation on this is still a little sketchy, and the best way to really use it is Xcode.

Probably just switch off PPC generation as it's unlikely to come back anytime soon.