Install multiple versions of Apple LLVM on MacOS Maverick (10.9) - xcode

To test the portability of a piece of code, I would like to install both Apple/LLVM 4.2 (based on LLVM 3.2svn, from XCode 4), and Apple/LLVM 5.0 (based on LLVM 3.3svn, from XCode 5) on the same machine, running Maverick (10.9). I do not need XCode itself, only the compiler suite. Is there a recommended way to install two different versions of Apple/LLVM?

Related

Compile with gcc on Macos 10.14.5 that will support earlier versions of Mac

I have a c ++ code that I wrote that uses almost nothing, which is not the language itself (except using osascript).
After compiling it on my operating system version (10.14.5) with the following flags:
D_DEBUG, Os, Wall, Wextra
I found that it was not running on older operating systems (in 10.13 for example - it raises an error that it can only run on 10.14 or later)
What are the right flags to use to tell GCC, that I want to support as many MacOs versions as possible?
You will need a versioning flag: -mmacosx-version-min=10.9
And let the compiler know where the SDK is: -isysroot= =/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
The older SDKs are available in older xcode bundles, or via https://github.com/phracker/MacOSX-SDKs/releases. You need to decompress the SDK and place the folder inside the xcode bundle, as shown in the sysroot flag above.
Apple sayeth: You must target your compile for the oldest version of OS X on which you want to run the executable. In addition, you should install and use the cross-development SDK for that version of OS X. For more information, see SDK Compatibility Guide

How to install a library with homebrew to use older Xcode SDK on OSX

I use Xcode 7.2 on OS X 10.11.
However, I must build using older Xcode SDK (10.8) to support older platform.
I have a problem when I link to libpng installed using homebrew.
A bunch of warnings like following pop up:
Object file
(/usr/local/Cellar/libpng/1.6.21/lib/libpng.16.a(pngwutil.o)) was
built for newer OSX version (10.11) than being linked (10.8)
The problem would be obviously solved if I could force homebrew to compile recipe using older Xcode SDK (10.8) but haven't find a way to accomplish this.
Any suggestion is welcome.

how does compilation work exactly on os x

I just started getting into LLVM and clang compilers and the whole thing. I am following the book "Getting started with llvm core libraries". I was under the impression that OS X comes bundled with llvm. However it seems that is not the case. I need to install llvm separately to get command line tools like llc or lli.
So my question is, when I do a "clang" to compile my c/c++ code, what backend does the work of creating the machine code ? My installation shows commands like llvm-gcc and llvm-g++ . Does it mean that it uses gcc internally for creating machine code? And do i need to brew install llvm to switch completely to llvm ?
If you just want clang, and plan to do mostly high-level language development (C, C++, ObjC), then I recommend installing the Xcode command line tools. You can get those from https://developer.apple.com/downloads/index.action?name=for%20Xcode (or you can install all of Xcode if you prefer).
If you want lower-level tools like llc, then my recommendation is brew, as you suggest.
If you're goal is just Mac development, then Xcode is the better solution. If your goal is working on LLVM, then brew is the better answer (or pull the sources and build it yourself).
If you want both on the same machine, I'd recommend not installing the command line tools. Just install Xcode and LLVM. Then you can run the Xcode versions using xcrun without colliding with your LLVM installation.
clang doesn't use llvm-gcc as a backend. It includes LLVM. llvm-gcc is a modified version of GCC that integrates with the LLVM backend, which allows programs that expect GCC-specific features to work with LLVM.

From PPC OSX, generate Intel binaries with Xcode?

I assume XCode 3.2.2 is the latest version which can run on PPC OSX (10.5.8). Can it generate universal binaries which will work on Intel Macs too, even Mavericks?
I.e: platform: G4 OSX 10.5.8
XCode: 3.2.2.
Xcode 3.1.4 is the latest version that runs on 10.5. Xcode 3.1 can create universal binaries that run on Intel Macs.
Whether or not the binary you create in Xcode 3.1 runs in Mavericks depends on your code. Avoid using deprecated APIs, such as QuickDraw, and your binary should run on Mavericks.

Desperately trying to build open source tools (octave) on a Mac 10.6 Snow Leopard (involves Xcode, gcc, fink)

The ironic thing is that all this used to work on my Mac, but Apple no longer supports 10.5.8, so I was forced to update to Snow Leopard, 10.6. And everything broke (thank you Apple).
On the surface, it seems simple. Build an open source package like octave under Snow Leopard (Mac OS X 10.6)
Apple has made this difficult, to say the least. They no longer download XCode for older operating systems unless you are a paid developer. My Macbook pro 2.16Ghz cannot load Lion, so that option is not available.
My old fink doesn't work because it was old. In order to build a new one, I need Xcode 3.2, which I can't get (see above).
I downloaded a free gcc 4.2, and it works fine.
So in order to try to build octave, it's the old style gnu install:
./configure
make
make install
./configure fails because there is no fortran installed. That's a special case because the install of gcc didn't include fortran. So a fallback would be building a complete gcc which I have done in the past.
downloaded gcc 4.9:
gcc-4.9-20130728
inside, gcc49
gcc can't build because it needs the three subsidiary packages gmp, mpfr and mpc
I am now trying to build these, so that I can bootstrap a complete gcc build, but in the meantime, is there any simpler way to bootstrap these things? I find it hard to understand why no binaries are available for:
fink
octave
which would solve part of my current problems.
You can still get XCode. You just have to be registered on Apple Developer, but you do not have to pay for the license. You then download it through the Mac App store, or you can get a link that opens it in the App store here. Finally, you have to install the command line tools from within Xcode. These can be found under the Components tab of the Download Preferences panel.
Let me know if that does not help. My iMac running 10.6 is currently in for repairs, so I am on my 10.7 laptop and cannot test all the specifics yet.

Resources