Check the ability to link library during setup.

Checking at the right place fixes the missing functions when we were
trying to link the function later on.

Change-Id: I4ebae8a3cb6d31988510d09552215f4ff0ab0078
diff --git a/lib/ExecutionEngine/Script.cpp b/lib/ExecutionEngine/Script.cpp
index 2030db9..128aa48 100644
--- a/lib/ExecutionEngine/Script.cpp
+++ b/lib/ExecutionEngine/Script.cpp
@@ -348,9 +348,19 @@
     return 1;
   }
 
-  // Parse Bitcode File (if necessary)
-  if (mSourceList[0]->prepareModule() != 0)
+  // Parse Source bitcode file (if necessary)
+  if (mSourceList[0]->prepareModule() != 0) {
+    ALOGE("Unable to setup source module\n");
     return 1;
+  }
+
+  // Parse Library bitcode file (if necessary)
+  if (mSourceList[1]) {
+    if (mSourceList[1]->prepareModule(mSourceList[0]->getContext()) != 0) {
+      ALOGE("Unable to setup library module\n");
+      return 1;
+    }
+  }
 
   // Set the main source module
   if (mCompiled->readModule(mSourceList[0]->getModule()) != 0) {
@@ -359,8 +369,7 @@
   }
 
   // Link the source module with the library module
-  if (mSourceList[1] &&
-      mSourceList[1]->prepareModule(mSourceList[0]->getContext())) {
+  if (mSourceList[1]) {
     if (mCompiled->linkModule(mSourceList[1]->getModule()) != 0) {
       ALOGE("Unable to link library module\n");
       return 1;