Building and Using x86_64 MacPorts | blog.imk.cx

Mac OS X supports building software and libraries as 64-bit, but the default when building is inherently 32-bit. Installing everything yourself and tweaking configure, and CFLAGS, is one way of doing it, but it can be cumbersome. I will attempt to explain getting a fully-working MacPorts up and running.

To start off, I built MacPorts from SVN. This will grab the latest, bleeding-edge version. There may be issues with certain revisions, but this is how I built mine.

svn co http://svn.macports.org/repository/macports/trunk macports
cd macports/base
./configure
make
cd ..
sudo make install
sudo port -v selfupdate

You should now have a regular, 32-bit build of MacPorts. This is necessary at first so you can build a 64-bit version of TCL. To force ports to build as 64-bit, you’re going to need to edit /opt/local/etc/macports/macports.conf.

vim /opt/local/etc/macports/macports.conf

Now find the line “universal_archs.” Change this to say:

universal_archs x86_64

Save the file and quit.
Now we need to build TCL. Run these commands:

port variants tcl

You will see universal listed. Remember, you modified the universal_archs line, so you’ll have to specify +universal to build as x86_64.

port install tcl +universal
file /opt/local/bin/tclsh

Running the command above, you should see: /opt/local/bin/tclsh: Mach-O 64-bit executable x86_64. This confirms that you have a 64-bit build of tcl now. Now we need to go back and rebuild MacPorts.

cd macports/base/Mk
vim macports.autoconf.mk

Now modify CFLAGS, OBJCFLAGS, CPPFLAGS, and SHLIB_LD to contain the following:

-m64 -mtune=nocona -O3

Also replace the TCLSH line to have:

/opt/local/bin/tclsh

Save and quit.

cd ..
make
cd ..
sudo make install

If everything built and installed without issues, then you should have a 64-bit version of MacPorts installed.

From here, it’s just a matter of adding +universal to ports that you build. You can always specify variants before you use install so that you can tell whether you can even build a 64-bit version.

sudo port install bzip2 +universal
file /opt/local/bin/bzip2

The above command should return: /opt/local/bin/bzip2: Mach-O 64-bit executable x86_64.

Well that should be it. You can always use the file command to double-check if it is built as 64-bit or not.

Good luck!

This entry was posted in Mac OS X. Bookmark the permalink. Trackbacks are closed, but you can post a comment.

Rate article