AppleGeorge

Thangs...

MidwestDJs.com
DesMoinesDJ.com
LimeLounge.com
siteomite.com
DesMoinesGroomer.com
QBFirm.com


Random (usually) Apple Related Tidbits

64-Bit G5 Optimized MySQL 5.1

When you absolutely, positively have to have your MySQL version saying "PowerPC (64-bit)" in the Activity Viewer "kind" window. A.k.a. how to waste a bunch of CPU cycles and time compiling a 64-bit G5 optimized MySQL which will probably break a few other things on your system.


Warning: before you read this article, be aware that I basically did this for my own entertainment. Unless you have a good reason to do so (and hey, maybe you have one) you probably don't need to do this at all. In fact, there's a good chance that you won't see any gain at all from doing this unless you're doing something very particular. But, if you're like me and you take pleasure in knowing that you've done something because it can be done, then by all means...

So, I've got a G5 and it's a 64-bit processor and I'm running Mac OS X 10.5.8. I ought to have a 64-bit version of MySQL right? Probably not, but I wanted one anyways. So, I decided to undertake that task. What lies herein is my effort in that regard.

I've decided that I'm not going to write step by step instructions for compiling your own software. Kudos to those who do that type of thing because God knows I wouldn't have figured out half of this stuff on my own, but I'd find that kind of writeup to be incredibly tedious and I'd probably miss some critical step anyways. If you're here reading this, I'm going to assume that you have half a clue as to how to build software from source. If you don't, then you don't need to be doing this in the first place. Or at the very least, you don't need to be doing it until you've gotten the hang of it on some easier projects. Not to mention that there are a lot of great sites which give very thorough instructions on how to do that type of thing (one of my favorite is osx.topicdesk.com).

Anyhow, you're going to need a source distribution of MySQL. If you're running a "modern" machine, you probably don't need to do this because there's a good chance that there's a MySQL binary distribution. Unfortunately, that's not the case (anymore) for the G5 (at least not as far as a 64-bit distribution is concerned). So, get the source. At the time of this article, the latest version was 5.1.50 and that's what I've used here. Now, here's the magic: use the following command in lieu of the standard ./configure

CFLAGS="-mpowerpc64 -mcpu=G5 -mtune=G5 -arch ppc64 -O2 -pipe -fno-omit-frame-pointer" CPPFLAGS="-mpowerpc64 -mcpu=G5 -mtune=G5 -arch ppc64 -pipe -O2 -fno-omit-frame-pointer" CXXFLAGS="-mpowerpc64 -mcpu=G5 -mtune=G5 -arch ppc64 -O2 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --enable-local-infile --enable-shared --with-plugins=innobase
If you're wondering what specifically I added, here are my additions:

CFLAGS/CPPFLAGS/CXXFLAGS

-mpowerpc64
-mcpu=G5
-mtune=G5
-arch ppc64

Basically, these are the bits that provide the G5 optimized goodness. In addition to making things 64-bit (that's the -arch ppc64 flag) the other flags (courtesy of this article: http://developer.apple.com/legacy/mac/library/#technotes/tn/tn2086.html%23G5options) enable specific optimizations. Also, for those of you who really know what's going on, you'll see that I only compiled with:

-O2

as opposed to:

-O3

(that's the optimization level, FYI). Unfortunately, I had to do a lot of tweaking to get things to properly build and I can't exactly remember if I couldn't get it to compile with -O3 or if I perhaps changed some other option. If you want to try it with -O3, be my guest. I didn't want to waste the time recompiling again just to find out. In any case, as long as the configure script runs fine, you should be able to go ahead and do a make and make install.

A couple of caveats
  • I don't claim to be any sort of an expert when it comes to any of this, but I've read a little and hacked around with this stuff a lot. If I did something drastically wrong, please don't hesitate to let me know. I'm sure there might be other/different options I could/should have turned on. All I know, is I was able to build using these options and MySQL works on my particular configuration.
  • This configuration installs MySQL into /usr/local/mysql which means that without some additional changes, you won't be running your new MySQL without a number of other changes. Again, there are other articles that have already set out how to do this in much better detail than I probably could.
  • I haven't benchmarked my build against the included Apple build to determine how my build compares to a stock version. I'll say that there's a good chance that it's slower (from what I've read, it can be pretty tough to reach the level of optimization that Apple does on a lot of software). The upside is that I have a much more recent version of MySQL which is probably a good thing from a security and stability standpoint.
  • I saved the best for last: if you do any reading or actually build and install a 64-bit MySQL on Mac OS X 10.5.8, you may find that it WILL break certain things because of its 64-bitness. One area where I'm experiencing this (and still haven't gotten worked out, BTW) is that mysqlhotcopy (a perl script which I use for backing up my databases) won't run. You might think that's a simple fix, but it's not. Among other things, it requires a 64-bit perl which you'll probably have to build yourself (more on that later) as well as 64-bit versions of a couple of key perl modules. So, like I said before, you should probably consider this as more of an exercise in computer nerdery than a solution to some real-world problem.
blog comments powered by Disqus