[cfe-dev] CMake/Xcode build fails trying to build asan

Kyle Sluder kyle at ksluder.com
Tue Feb 18 17:40:12 PST 2014


On Tue, Feb 18, 2014, at 04:09 AM, Alexey Samsonov wrote:
> 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.

Sadly, that doesn't work.

I think the root problem is that Xcode automatically specifies -isysroot
and -mmacosx-version-min based on the $(SDKROOT) and
$(MACOSX_DEPLOYMENT_TARGET) project settings. It sticks these flags
_before_ those specified by the $(OTHER_CFLAGS) project setting, which
is where the values of the DARWIN_osx_FLAGS and DARWIN_ios_CFLAGS CMake
variables wind up.

Inspecting the RTSanitizerCommon.iossim target in Xcode, the $(SDKROOT)
project setting points at the location of my OS X SDK on disk. This is
why the build command includes both the "-isysroot …/MacOSX10.9.sdk"
(which comes from $(SDKROOT)) and "-isysroot …/iphonesimulator7.0.sdk"
(which comes from $(OTHER_CXXFLAGS)) settings.

I think the solution requires not putting the -isysroot and
-mmacosx-version-min flags in OTHER_CFLAGS when using the Xcode
generator. Instead, the ios targets should set the $(SDKROOT) and
$(MACOSX_DEPLOYMENT_TARGET) build settings in the generated pbxproj. I
took a first pass at that:
<https://github.com/kylesluder/objc-namespaces/commit/46fee77b6b8687ca463e6bde07d61ce27fd975e1>

Unfortunately, this doesn't seem to successfully set the $(SDKROOT) to
iphonesimulator on the ios targets.

On a side note, I don't know _why_ it's building the iPhone Simulator
target even though I specified '-DLLVM_TARGETS_TO_BUILD="X86"' on the
command line.

--Kyle Sluder




More information about the cfe-dev mailing list