Cross compilation of clang/llvm to Darwin from OS X

Hi all,

I am trying to cross-compile a “straight” Darwin toolchain, completely separate from the toolchain that ships with Xcode on OS X (working with OS X 10.9).
I want to remove all OS X-level dependencies and work purely with the Darwin layer. In order to do this, it seemed appropriate to follow the cross-compilation instructions at:

And I ended up with the following build commands:

mkdir build
cd build
CC='clang' CXX='clang++' cmake -G "Unix Makefiles" ../llvm/ -DCMAKE_CROSSCOMPILING=True \
-DCMAKE_INSTALL_PREFIX=/vanillaTools/tools -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-novendor-darwin13.1.0 \
-DCMAKE_CXX_FLAGS="-target x86_64-novendor-darwin13.1.0"
make install

I noticed the following output in the CMake script:
-- Target triple: x86_64-apple-darwin13.1.0 # Should the vendor still be -apple- ?
-- Native target architecture is X86

Once installed, I ran the “which clang” command, with the (expected) output: /vanillaTools/tools/bin/clang

But then I ran:
echo "int main() { return 0; }" | clang -v -x c -

Which resulted in the following output:

clang version 3.5.0 (208516)
Target: x86_64-novendor-darwin13.1.0
Thread model: posix
"/Volumes/DarwinHD/tools/bin/clang-3.5" -cc1 -triple x86_64-novendor-macosx10.9.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name - -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -v -resource-dir /Volumes/DarwinHD/tools/bin/../lib/clang/3.5.0 -fdebug-compilation-dir /Volumes/DarwinHD/sources/build -ferror-limit 19 -fmessage-length 130 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fencode-extended-block-signature -fdiagnostics-show-option -fcolor-diagnostics -o /var/tmp/--2f1bef.o -x c -
clang -cc1 version 3.5.0 based upon LLVM 3.5.0svn default target x86_64-novendor-darwin13.1.0
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/usr/bin/ld" -dynamic -arch x86_64 -macosx_version_min 10.9.0 -o a.out /var/tmp/--2f1bef.o -lSystem # This is a separate issue - still using the default linker.

Although the target always says “…darwin13.1.0” the "-triple x86_64-novendor-macosx10.9.0” and "-fobjc-runtime=macosx-10.9.0” arguments are inserted by default, even though I have cross compiled the suite for Darwin, not OS X.

Is this expected behaviour, or have I missed something in the cross-compilation?

I understand that the Obj-C runtime would default to the OS X brand (rather than the GNU one) - though the fact that it identifies the 10.9.0 version is concerning - and I would have expected the -triple option to read x86_64-novendor-darwin13.1.0. Any insight would be much appreciated!

Many thanks in advance,
David Piper