天道酬勤,学无止境

How do we create a 32-bit build of Perl 5.12.3 in /usr/local on Mac OS X Snow Leopard?

For one reason or another we need to create a custom 32-bit build of Perl 5.12.3 in /usr/local on Mac OS X Snow Leopard.

Can anyone explain the process or point us the direction of a tutorial or example?

标签

评论

On Snowleopard the kernel runs in 32bit mode and the userland mostly in 64bit mode. The kernel is able to run 32bit and 64bit userland apps without a problem. You need to tell the perl build system to create a 32bit only binary. This is done by setting the -arch gcc flag.

For a simple singe file app you would do it like this:

gcc -arch i386 -o app app.m -lobjc -framework CoreFoundation -framework Cocoa

In your case you have to pass the arch flag to the build system. Iam not a perl expert but i would configure perl like this:

./Configure -Dprefix=/usr/local -A ccflags="-arch i386"

If your system doesn't have 64bit kernel extensions turned on, then you should just be able to build Perl straight from source and pass DESTDIR=/usr/local on the make install command line. If the system is in 64bit mode, you'll need to look up how to cross-compile for i386, which isn't something I've had to do before as I just build perl for my native architecture, or install from a package.

Here's how I did it using Perlbrew:

  1. Install Perlbrew
  2. Make sure you have followed all of the proper steps including adding the bit to the end of .bash_profile.
  3. Run the following (for perl 5.14.2, with threading. Adjust as necessary for other perl versions and options) (Thanks to WildPerl for this bit of wisdom):

    perlbrew install 5.14.2 -ders -Dusethreads -Duseithreads -Accflags="-arch i386" -Accflags="-B/Developer/SDKs/MacOSX10.6.sdk/usr/include/gcc" -Accflags="-B/Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc" -Accflags="-isystem/Developer/SDKs/MacOSX10.6.sdk/usr/include" -Accflags="-F/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks" -Accflags="-mmacosx-version-min=10.5" -Aldflags="-arch i386 -Wl,-search_paths_first" -Aldflags="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk" -Aldflags="-mmacosx-version-min=10.5" -Alddlflags="-arch i386 -Wl,-search_paths_first" -Alddlflags="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk" -Alddlflags="-mmacosx-version-min=10.5" -Duseshrplib

  4. If you have a newer version of Xcode with the Developer SDKs as part of the app bundle, you'll need to create a symlink to them from /Developer:

    sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/ /Developer

  5. Install the local copy of cpanm:

    perlbrew install-cpanm

  6. After that finishes, go to the place where perlbrew installed perl (on my system that is: ~/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2/darwin-thread-multi-2level/ and edit Config.pm to change this line:

    cc => 'cc',

to this:

cc => 'cc -m32',

受限制的 HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。

相关推荐