boozook / xcodelegacy

Legacy components for XCode 4-8 (deprecated compilers and Mac OS X SDKs)

Home Page:https://github.com/devernay/xcodelegacy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

XcodeLegacy

Legacy components for XCode 4-8 (deprecated compilers and Mac OS X SDKs).

Home page: https://github.com/devernay/xcodelegacy

Description

Many components were removed in recent versions of Xcode, the most notable being the Mac OS X 10.6 SDK, which is required to build software using the Carbon API (such as wxWidgets 2.8).

I made the script XcodeLegacy.sh to extract these components (the links work if you sign in to Apple Developer first) from Xcode 3.2.6 (10.4, 10.5 and 10.6 SDKs, PPC assembler, GCC 4.0 and 4.2, LLVM-GCC 4.2), Xcode 4.6.3 (10.7 SDK), Xcode 5.1.1 (10.8 SDK), Xcode 6.4 (10.9 and 10.10 SDKs), Xcode 7.3.1 (10.11 SDK) and install them in Xcode 4-8:

  • GCC 4.0, GCC 4.2 and LLVM GCC 4.2 compilers
  • GCC 4.0, GCC 4.2 and LLVM GCC 4.2 Xcode plugins
  • PPC assembler
  • Mac OS X SDK 10.4u, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11

Note: There may be similar tips to compile for older iOS (not Mac OS X) versions, but I don't develop for iOS. However, if you want to enhace the XcodeLegacy script to also include those components, I'll gladly integrate your modifications.

Download

XcodeLegacy.sh (previous versions: 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9)

GitHub repository

Usage

Open a Terminal application, change to the directory where XcodeLegacy.sh, and make it executable, as in:

cd path/to/xcodelegacy
chmod +x XcodeLegacy.sh

Execute the script by typing ./XcodeLegacy.sh <arg>. The script takes one argument, which can be "buildpackages" (to extract components from the legacy Xcode downloads to the current directory), "install" (to install the components in Xcode 4-8), "cleanpackages" (to delete the extracted components from the current directory), "uninstall" (to uninstall the components from Xcode 4-8).

With the "install" or "uninstall" arguments, the script uses sudo to become root, and will thus ask for your password. Please check the script contents before executing it.

Optionally, one of the following options can be passed as the first argument to XcodeLegacy.sh, to limit its operation:

  • -compilers : only install the gcc and llvm-gcc compilers, as well as the corresponding Xcode plugins
  • -osx104 : only install Mac OSX 10.4 SDK
  • -osx105 : only install Mac OSX 10.5 SDK
  • -osx106 : only install Mac OSX 10.6 SDK
  • -osx107 : only install Mac OSX 10.7 SDK
  • -osx108 : only install OSX 10.8 SDK
  • -osx109 : only install OSX 10.9 SDK
  • -osx1010 : only install OSX 10.10 SDK
  • -osx1011 : only install OSX 10.11 SDK

Using the older SDKs

To use any of the older SDKs, you should:

  • compile and link with the options -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
  • set the environment variable MACOSX_DEPLOYMENT_TARGET to the proper value (e.g. 10.5) - this should be redundant with the -mmacosx-version-mincompiler option, but older compilers do not seem to pass this option to the linker.

For example:

env MACOSX_DEPLOYMENT_TARGET=10.6 clang -arch i386 -arch x86_64 -mmacosx-version-min=10.6 -isysroot /Developer/SDKs/MacOSX10.6.sdk main.c -o main

Using the older compilers

Links to the compilers are installed in /usr/bin (or /usr/local/bin on OS X 10.11 El Capitan and later): gcc-4.0 g++-4.0 gcc-4.2 g++-4.2 llvm-cpp-4.2 llvm-g++-4.2 llvm-gcc-4.2.

GCC 4.0, GCC 4.2 and LLVM GCC 4.2 cannot compile for OS X 10.10 or newer.

PowerPC architectures (ppc, ppc7400, ppc970, ppc64) cannot be linked for OS X 10.7 or newer (they would be useless anyway, since PowerPC CPUs were only supported up to 10.5).

Note on Xcode versions

Here are the latest versions of Xcode that are known to /run/ on each OS X version (the links work if you sign in to Apple Developer first):

More information about the compilers included in each version of Xcode can be found on the MacPorts Wiki.

Linking on Xcode 7.3 and later

The following error may appear when linking a program using the older compilers from Xcode (command-line and Makefile-based builds should not be affected):

Running ld for ppc ...
ld: unknown option: -no_deduplicate

The reason is that the newer versions of the linker introduced the option -no_deduplicate, which Xcode adds by default. To disable this, add a User-Defined build setting in Xcode named LD_DONT_RUN_DEDUPLICATION and set its value to NO.

Known bugs (and fixes) in OS X SDKs

Recent GCC versions cannot build universal binaries

The GCC in Apple SDK is actually a small binary that lauches several compilers and merges the results (see driverdriver.c). The same executable can be compiled for recent GCC versions too, see devernay/macportsGCCfixup on github.

bad_typeid dyld Error on Leopard (10.5)

This is a bug in the 10.6 (and later) SDKs, which can be easily fixed:

code compiled with g++ > 4.2.1 crashes with "pointer being freed not allocated"

The problem comes from the fact that some system frameworks load the system libstdc++, which results in incompatible data structures.

After exploring various options (install_name_tool, rpath, etc.), the only solution is to set the environment variable DYLD_LIBRARY_PATH to the path of a directory where you only put a symbolic link to the newest libstdc++ from GCC (libstdc++ is guaranteed to be backward-compatible, not other libraries).

If you are building an application bundle, you should replace your executable by a small executable that sets the environment variable DYLD_LIBRARY_PATH. It can be a script (see below), or a binary (better, because it handles spaces in arguments correctly).

The setdyld_lib_path.c source code can be compiled to act as a "launcher" for your binary that correctly sets the DYLD_LIBRARY_PATH variable. See the full instructions at the top of the source file.

An alternate solution, using a shell-script (doesn't handle spaces in arguments): http://devblog.rarebyte.com/?p=157

Other references:

License

This script is distributed under the Creative Commons BY-NC-SA 3.0 license.

History

  • 1.0 (08/10/2012): First public version, supports Xcode up to version 4.6.3
  • 1.1 (20/09/2013): Xcode 5 removed llvm-gcc and 10.7 SDK support, grab them from Xcode 3 and 4
  • 1.2 (03/02/2014): Xcode 5 broke PPC assembly and linking; fix assembly and grab linker from Xcode 3
  • 1.3 (07/10/2014): Xcode 6 removed 10.8 SDK, grab it from Xcode 5.1.1
  • 1.4 (21/08/2015): Xcode 7 removed 10.9 and 10.10 SDKs, grab them from Xcode 6.4
  • 1.5 (15/10/2015): Fixes for OS X 10.11 El Capitan (nothing can be installed in /usr/bin because of the sandbox)
  • 1.6 (11/11/2015): Fix buildpackages, fix /usr/bin/gcc on recent OS X, fix download messages
  • 1.7 (05/04/2016): Xcode 7.3 disables support for older SDKs, fix that
  • 1.9 (16/09/2016): Xcode 8 dropped 10.11 SDK, get it from Xcode 7.3.1

About

Legacy components for XCode 4-8 (deprecated compilers and Mac OS X SDKs)

https://github.com/devernay/xcodelegacy


Languages

Language:Shell 94.8%Language:C 5.2%