Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp	(revision 108822)
+++ lib/Driver/Tools.cpp	(working copy)
@@ -3298,6 +3298,11 @@
       CmdArgs.push_back("/usr/lib");
     }
 
+    if (D.CCCIsCXX) {
+      CmdArgs.push_back("-lstdc++");
+      CmdArgs.push_back("-lm");
+    }
+
     if (Args.hasArg(options::OPT_shared)) {
       CmdArgs.push_back("-lgcc_pic");
     } else {
