[libcxx] How to compile libcxx with MemorySanitizer in MacOS and Linux

How can I compile libcxx with MemorySanitizer in MacOS and Linux?

A step-by-step description would be greatly appreciated but a bash script that
fetches trunk (and/or libcxx abi) from svn and compiles it would be enough.

This should probably be added to the documentation.

Best regards,
Gonzalo

MemorySanitizer is not supported on OS X
(http://clang.llvm.org/docs/MemorySanitizer.html). You can compile
libc++ using AddressSanitizer or UndefinedSanitizer on OS X using the
cmake options -DLLVM_USE_SANITIZER=Address and
-DLLVM_USE_SANITIZER=Undefined respectively.

Support for building libc++ on OS X with sanitizers is experimental
and may not work. Let me know if you have any issues.

/Eric

I see, thanks for the fast answer!

Do you know anything about compiling it with the MemorySanitizer under
Linux?

It seems that there is a circular dependency between libcxx and libcxxabi
but the docs do not really mention how to solve this (libcxx docs say it
needs libcxxabi and libcxxabi says it needs libcxx).

Do you know anything about compiling it with the MemorySanitizer under Linux?

Yes. You can use the '-DLLVM_USE_SANITIZER=Memory` or
`-DLLVM_USE_SANITIZER=MemoryWithOrigins`
when building libc++ and libc++ to build using MemorySanitizer.

It seems that there is a circular dependency between libcxx and libcxxabi but the docs do not really mention
how to solve this (libcxx docs say it needs libcxxabi and libcxxabi says it needs libcxx).

They both need each other :). However libc++abi only needs the libc++
headers, not the compiled library, so you build libc++abi first and
then build libc++ after.

Better docs are in progress.

/Eric

It seems that there is a circular dependency between libcxx and
libcxxabi but the docs do not really mention how to solve this (libcxx
docs say it needs libcxxabi and libcxxabi says it needs libcxx).

libcxxabi's dependence on libcxx is only on libcxx's headers (i.e. there are no symbols from libcxx used in libcxxabi). The build system takes care of this for you.

Jon

I’ve managed to compile the new cmake system following the instructions.

I haven’t managed install libc++ without installing llvm besides it.

Is there a way to do this?

There currently is not :(. However I have two patches up for review
that add a "install-libcxx" and "install-libcxxabi" targets so you can
avoid that.

http://reviews.llvm.org/D11697
http://reviews.llvm.org/D11682

Thanks that is exactly what I was looking for.