D16945: LLVM overhaul to avoid linking LLVM component libraries with libLLVM

Hans,
      I have posted a complete patch for solving the linkage issues
with LLVM_LINK_LLVM_DYLIB on Phabricator at
http://reviews.llvm.org/D16945. The bulk of the fix the simple
changes of...

Index: cmake/modules/AddLLVM.cmake

Chris Bieneman is probably your best bet, and maybe also Dan Liew.

Hans,
      My current, and hopefully final, revision of the proposed patch
is simplified and reworked to solve the problem entirely from cmake
without touching the the llvm-build python scripts. Basically, the new
fix for avoiding the Support library dependency set from the
'required_libraries = Support' in llvm/utils/unittest/LLVMBuild.txt is
not read it for LLVM_LINK_LLVM_DYLIB. The new patch modifies
llvm_add_library() in cmake/modules/AddLLVM.cmake to manually set the
LLVMBUILD_LIB_DEPS_gtest property to LLVM when LLVM_LINK_LLVM_DYLIB
is set and the library name is gtest rather than read from the
tools/llvm-config/LibraryDependencies.inc generated by llvm-build.
                     Jack
ps As soon as this patch lands, I'll look at trying to rework the
unittests handling of the LLVMSupport dependency and see if setting
that explicitly can be dropped (as it should be pulled in from the
LLVMBUILD_LIB_DEPS_gtest property setting of Support). However that
really isn't suitable for back porting to 3.8 so I want to avoid
conflating those changes with those required to solve the test suite
failures in bug 26393.

Index: cmake/modules/AddLLVM.cmake

Hans and Chris,
       Andrew Wilkins refactored my last patch for
http://reviews.llvm.org/D16945 into a version that properly handles
the Support library dependency of the gtest library without requiring
conditionals on LLVM_LINK_LLVM_DYLIB in
cmake/modules/LLVM-Config.cmake and utils/unittest/CMakeLists.txt. He
is awaiting a review from Chris before committing it to trunk. I have
successfully regression tested this version on the stock (static),
BUILD_SHARED_LIBS and LLVM_LINK_LLVM_DYLIB builds of
llvm/clang/clang-tools-extra/compiler-rt/openmp/polly/libc++ on x86_64
darwin, The patch also successfully applies and regression tests on
3.8 branch so hopefully we can squeeze this in for the 3.8.0 releases
since currently the LLVM_LINK_LLVM_DYLIB build produces broken
binaries on both trees.
         Jack

Index: cmake/modules/AddLLVM.cmake

Confirmed on current trunk that Bug 26393,
-DLLVM_LINK_LLVM_DYLIB:BOOL=ON produces many llvm test suite
regressions, is now fixed at r260641 on x86_64 darwin for the stock
(static), BUILD_SHARED_LIBS and LLVM_LINK_LLVM_DYLIB builds which all
produce clean test suite results for
llvm/clang/clang-tools/compiler-rt/polly/openmp/libc++. Since no build
bot regressions appear at http://lab.llvm.org:8011/console, the
changes in r260641 appear safe for a back port to 3.8 to fix the
LLVM_LINK_LLVM_DYLIB feature there.
               Jack