Xcode and gcc_select
My work style is such that I typically work on a given project for a few weeks at a time, when my ideas have been satisfied I usually switch to another project for a few weeks, and so on. I switch OS's and machines too, so I have a little mental warm up time between projects and there is always that "duh period" when getting back into a different work environment. Sometimes the "duh period" is good, it forces you to clean up a project such that it does not depend on your mental state in order to be used, you hit a newbie problem because you forgot what you were doing and you go and clean it up.
I had been working on a cross compiling version of gcc, for whatever reason it needed to be compiled with gcc 3.3. On the advice of some instructions floating around I used the command gcc_select to set the compiler version to 3.3 instead of 4.0. The bothersome thing about this command is that it requires root to run and sets the default gcc version for the whole system. Ah, who cares, this is the only project I am working on that I compile from the command line, so it didn't seem like a big deal. All my other projects are done in Xcode which has it's own compiler selection system, right? wrong.
So today I started working on one of my OS X apps which I compile as a Universal Binary with gcc 4.0, or so I thought. I cleaned the project and started a rebuild and the rebuild died. Uh, staring at the build log the first thing I noticed was that it couldn't exec ccobj1, weird, my thoughts instantly turned to "did something get deleted?". Then the second thing I noticed was that it was using gcc-3.3. Uh "did I change something in the project and forget about it?", nope. My SDK was set correctly for building universals. I looked at the build rules and the system default was gcc 3.3, 3.3 doesn't support -arch i386 on my machine and the compiler was dying as one would expect.The first thought was to add build rules which explicitly said 4.0, but something else was going on.
Then I remembered gcc_select, switched it back to 4.0, restarted Xcode and everything was back proper.
This seemed like weird behavior to me, there is so much in Xcode to specify exactly what is going on, yet this command which is for all intents and purposes unrelated to Xcode projects affects which compiler is used. Xcode knows how to run different versions of gcc, the universal SDK needs 4.0, yet it went and used 3.3 by gcc_select's request.
Hopefully I remember that the project that requires gcc 3.3 requires gcc 3.3, or I'll have another one of those "duh period"s. Let's hope this doesn't go on indefinitely.

0 Comments:
Post a Comment
<< Home