Fink:Packaging:x86 64

From the Fink Wiki
Jump to navigation Jump to search

This page contains information about building packages for the x86_64 architecture.

Fink and x86_64

Fink allows users to choose either a 32- or 64-bit Fink installation on 10.6 systems with 64-bit capable processors. Most packages do not need to be patched to support 64-bit systems because Finks adds /sw/var/lib/fink/path-prefix-10.6 to the PATH environmental variable before a package is built. This directory contains aliases for commonly used compiler driver names such as cc, gcc, c++, g++, and adds the appropriate -arch flag when invoking them: -arch i386 for 32-bit Fink, -arch x86_64 for 64-bit Fink. Note that -arch is an Apple GCC only flag.

This should be enough for most build systems. However, there are some caveats.

Autoconf-based build systems

Autoconf-based systems use the config.guess script to identify the system type; the resulting identification is a triplet cpu-vendor-os. On Mac OS X, these triplets follow the format cpu-apple-darwinX, where cpu is powerpc, i386, or x86_64, and X is the major version outputted by uname -r. Valid examples are i386-apple-darwin9 and x86_64-apple-darwin10.

Depending on the verifications performed by the configure script, it might be necessary to specify on which system type the resulting programs or libraries are meant to run. This is the purpose of the --host=system_type parameter. Also, --build should be defined whenever --host is.

In order to set --build, --host in ConfigureParams, use:

ConfigureParams: --build=%m-apple-darwin`uname -r | cut -d. -f1` --host=%m-apple-darwin`uname -r | cut -d. -f1`

or the equivalent in CompileScript.

Carbon

The Carbon API contains libraries that are 32-bit only as well as libraries that are both 32- and 64-bit. Packages that build against Carbon libraries might need to be restricted to powerpc and i386 architectures (i.e., not x86_64) if they use functions that are only available in 32-bit format.

The LP64 data model

Mac OS X uses the LP64 data model, the same used in Linux. In LP64, int is a 32-bit data type, whilst long, long long, and size_t are 64-bit data types. Pointers are 64-bit and cannot be stored in int variables. When a program is being compiled for x86_64, GCC automatically defines the __LP64__ macro — use it in case you need conditional compilation for that architecture. More information is available in Apple's 64-bit Transition Guide.

-mdynamic-no-pic

In x86_64, GCC's -mdynamic-no-pic flag, which allowed applications not to be position-independent (PIC), is a no operation. This means that in x86_64 code must always be position-independent. See http://lists.apple.com/archives/Darwin-dev/2009/Dec/msg00035.html

Xcode projects

The ARCHS build setting can be used to specify a target architecture for an Xcode project as follows:

xcodebuild ARCHS=target_architecture 

Valid examples of target_architecture include x86_64, i386, ppc. Note that on PowerPC machines Fink expands %m as powerpc instead of the ppc value supported by Xcode.