CMake/Xcode build fails trying to build asan

[resending to cfe-dev since this is a compiler-rt/asan issue]

I checked out llvm, clang, and compiler-rt, then ran the following
command to generate an Xcode project:

% cmake -G "Xcode" /Users/Shared/objc-namespaces/llvm
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_INSTALL_PREFIX=/Users/Shared/objc-namespaces/llvm/DstRoot
-DLLVM_TARGETS_TO_BUILD="X86"

I opened the resulting LLVM.xcodeproj and tried to build the default
ALL_BUILD target. It failed while trying to build asan:

clang: error: invalid argument '-mmacosx-version-min=10.9' not allowed
with '-mios-simulator-version-min=7.0'
Command
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
failed with exit code 1

Inspecting the entire build command reveals that there are two -isysroot
flags, one specifying the OS X 10.9 SDK and another specifying the iOS
simulator SDK. Since AFAICT, asan tries to specify a minimum deployment
target of 10.7 when building for OS X, I think it's pretty certain that
the first -mmacosx-version-min flag (and its -isysroot companion) are
coming from Xcode's default project settings.

Is it possible to convince CMake to add overrides of the relevant build
settings in the xcodeproj rather than trying to stuff everything into
$(OTHER_CFLAGS)?

--Kyle Sluder

We're basically cross-compiling the iOS simulator version of ASan
runtime here, so supplying an additional -mmacosx-version flag sounds
a wrong thing to do.
If it isn't possible to avoid setting this flag for the iossim builds,
we can just disable building the iossim runtime if
-mmacosx-version-min is present in OTHER_CFLAGS.
But I'm not sure that's what you want.

FYI I’ve disabled building ASan for iossim if -mmacosx-version-min is added to CMAKE_CXX_FLAGS in r201566. Does this fix the build for you?
The problem comes from the fact that we automatically re-use build flags specified for building LLVM/Clang when we build compiler-rt libraries.
I’m working on improving the situation here.