Make it possible to link against libstdc++ as well as libsupc++ with CMake.

Linking against libstdc++, rather than libsupc++, is probably better
for people who need to link against clients of libstdc++.  Because
libsupc++ is provided only as a static library, its globals are not
shared between the static library and the copy linked into libstdc++.
This has been found to cause at least one test failure.

This also removes a number of symbols which were multiply defined
between libstdc++ and libc++, only when linking with libstdc++.

Differential Revision: http://llvm-reviews.chandlerc.com/D1825

llvm-svn: 192075
diff --git a/libcxx/test/lit.cfg b/libcxx/test/lit.cfg
index dca6219..b07046b 100644
--- a/libcxx/test/lit.cfg
+++ b/libcxx/test/lit.cfg
@@ -234,14 +234,27 @@
 if link_flags_str is None:
     link_flags_str = getattr(config, 'link_flags', None)
     if link_flags_str is None:
-        if sys.platform == 'darwin':
-            link_flags += ['-lSystem']
-        elif sys.platform == 'linux2':
-            link_flags += ['-lsupc++', '-lgcc_eh', '-lc', '-lm', '-lpthread',
-                '-lrt', '-lgcc_s']
-        else:
-            lit_config.fatal("unrecognized system")
-        lit_config.note("inferred link_flags as: %r" % (link_flags,))
+      cxx_abi = getattr(config, 'cxx_abi', None)
+      if cxx_abi == 'libstdc++':
+        link_flags += ['-lstdc++']
+      elif cxx_abi == 'libsupc++':
+        link_flags += ['-lsupc++']
+      elif cxx_abi == 'libcxxabi':
+        link_flags += ['-lc++abi']
+      elif cxx_abi == 'none':
+        pass
+      else:
+        lit_config.fatal('C++ ABI setting %s unsupported for tests' % cxx_abi)
+
+      if sys.platform == 'darwin':
+        link_flags += ['-lSystem']
+      elif sys.platform == 'linux2':
+        link_flags += [ '-lgcc_eh', '-lc', '-lm', '-lpthread',
+              '-lrt', '-lgcc_s']
+      else:
+        lit_config.fatal("unrecognized system")
+
+      lit_config.note("inferred link_flags as: %r" % (link_flags,))
 if not link_flags_str is None:
     link_flags += shlex.split(link_flags_str)
 
diff --git a/libcxx/test/lit.site.cfg.in b/libcxx/test/lit.site.cfg.in
index 61406bf..5343eda 100644
--- a/libcxx/test/lit.site.cfg.in
+++ b/libcxx/test/lit.site.cfg.in
@@ -5,6 +5,7 @@
 config.libcxx_obj_root       = "@LIBCXX_BINARY_DIR@"
 config.python_executable     = "@PYTHON_EXECUTABLE@"
 config.enable_shared         = @LIBCXX_ENABLE_SHARED@
+config.cxx_abi               = "@LIBCXX_CXX_ABI@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")