With Xcode 4.5.2, Clang compiler seems not to be S

2019-07-07 12:50发布

问题:

With Xcode 4.4 and earlier versions, each SDK used to have either a copy or a symlink to a Clang compiler available at

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/
    SDKs/iPhoneOS${IPHONE_SDKVERSION}.sdk/usr/bin/clang++

With Xcode 4.5.2, there is no Clang compiler at the path above. However, I found it at

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang

b) Why does it not depend on the SDK version anymore ?

回答1:

It's because clang can compile for multiple architectures with a single (top-level) binary. The previous gcc-based toolchains needed one gcc per arch.

See how to compile libcurl with arch armv7s under macosx? for examples of passing arch flags to clang.

Also, you can use xcrun to find your tools instead of hardcoding their locations. For example, when cross compiling for iOS:

export CC=`xcrun --sdk iphoneos --find clang`