Export the names of extenerals that are declared as weak (#268)

This allows the js compiler to avoid warning/errors when such symbols are missing.
diff --git a/lib/Target/JSBackend/JSBackend.cpp b/lib/Target/JSBackend/JSBackend.cpp
index 78091ec..c41757c 100644
--- a/lib/Target/JSBackend/JSBackend.cpp
+++ b/lib/Target/JSBackend/JSBackend.cpp
@@ -254,6 +254,7 @@
     NameSet Externals; // vars
     NameSet ExternalFuncs; // funcs
     NameSet Declares; // funcs
+    NameSet WeakDeclares; // funcs
     StringMap Redirects; // library function redirects actually used, needed for wrapper funcs in tables
     std::vector<std::string> Relocations;
     NameIntMap NamedGlobals; // globals that we export as metadata to JS, so it can access them by name
@@ -3942,6 +3943,10 @@
         continue;
       }
 
+      if (I->hasExternalWeakLinkage()) {
+        WeakDeclares.insert(fullName);
+      }
+
       if (first) {
         first = false;
       } else {
@@ -3961,6 +3966,19 @@
   }
   Out << "],";
 
+  Out << "\"weakDeclares\": [";
+  first = true;
+  for (NameSet::const_iterator I = WeakDeclares.begin(), E = WeakDeclares.end();
+       I != E; ++I) {
+    if (first) {
+      first = false;
+    } else {
+      Out << ", ";
+    }
+    Out << "\"" << *I << "\"";
+  }
+  Out << "],";
+
   Out << "\"redirects\": {";
   first = true;
   for (StringMap::const_iterator I = Redirects.begin(), E = Redirects.end();