Change the API of bccPrepareSharedObject().

Change-Id: I2d0ecf6b062b52dc4b6b514d93ba8191920a00aa
diff --git a/include/bcc/bcc.h b/include/bcc/bcc.h
index 6a6972e..6843f03 100644
--- a/include/bcc/bcc.h
+++ b/include/bcc/bcc.h
@@ -115,10 +115,8 @@
                           unsigned long flags);
 
 int bccPrepareSharedObject(BCCScriptRef script,
-                           char const *cacheDir,
-                           char const *cacheName,
-                           char const *dsoPath,
                            char const *objPath,
+                           char const *dsoPath,
                            unsigned long flags);
 
 int bccPrepareExecutable(BCCScriptRef script,
diff --git a/lib/ExecutionEngine/Script.cpp b/lib/ExecutionEngine/Script.cpp
index 74f1f01..6e3774b 100644
--- a/lib/ExecutionEngine/Script.cpp
+++ b/lib/ExecutionEngine/Script.cpp
@@ -210,9 +210,7 @@
 }
 
 
-int Script::prepareSharedObject(char const *cacheDir,
-                                char const *cacheName,
-                                char const *objPath,
+int Script::prepareSharedObject(char const *objPath,
                                 char const *dsoPath,
                                 unsigned long flags) {
   // TODO: Support cached shared object.
diff --git a/lib/ExecutionEngine/Script.h b/lib/ExecutionEngine/Script.h
index 070b717..629fd7a 100644
--- a/lib/ExecutionEngine/Script.h
+++ b/lib/ExecutionEngine/Script.h
@@ -177,14 +177,12 @@
      * compiled before and pass it in objPath to generate shared object. If the
      * objPath is NULL, we'll invoke prepareRelocatable() to get .o first (if
      * you haven't done that yet) and then link the output relocatable object
-     * file. The latter case will have libbcc compile with USE_CACHE enabled.
+     * file to .so in dsoPath.
      *
      * TODO: Currently, we only support to link the bitcodes in mSourceList[0].
      *
      */
-    int prepareSharedObject(char const *cacheDir,
-                            char const *cacheName,
-                            char const *objPath,
+    int prepareSharedObject(char const *objPath,
                             char const *dsoPath,
                             unsigned long flags);
 
diff --git a/lib/ExecutionEngine/bcc.cpp b/lib/ExecutionEngine/bcc.cpp
index 057be50..01ef32f 100644
--- a/lib/ExecutionEngine/bcc.cpp
+++ b/lib/ExecutionEngine/bcc.cpp
@@ -160,14 +160,11 @@
 
 
 extern "C" int bccPrepareSharedObject(BCCScriptRef script,
-                                      char const *cacheDir,
-                                      char const *cacheName,
                                       char const *objPath,
                                       char const *dsoPath,
                                       unsigned long flags) {
   BCC_FUNC_LOGGER();
-  return unwrap(script)->prepareSharedObject(cacheDir, cacheName,
-                                             objPath, dsoPath, flags);
+  return unwrap(script)->prepareSharedObject(objPath, dsoPath, flags);
 }
 
 
diff --git a/tools/bcc/main.cpp b/tools/bcc/main.cpp
index f5e85f6..fa936ff 100644
--- a/tools/bcc/main.cpp
+++ b/tools/bcc/main.cpp
@@ -215,9 +215,10 @@
     }
   }
 
-  // Generation of relocatable doesn't need special output file processing (
-  // i.e., prepare cacheDir and cacheName like bccPrepareExecutable)
-  if (OutType != OT_Relocatable) {
+  // Generation of relocatable and shared object doesn't need special output
+  // file processing (i.e., prepare cacheDir and cacheName like
+  // bccPrepareExecutable())
+  if (OutType == OT_Executable) {
     char *lastSlash = strrchr(output, '/');
     if (lastSlash != NULL) {
       outDir = output;
@@ -255,24 +256,7 @@
       break;
     }
     case OT_SharedObject: {
-      // Construct output library path
-      const size_t outDirLen = strlen(outDir);
-      const size_t outFilenameLen = strlen(outFilename);
-      const size_t outLibLen = outDirLen + 1 /* for '/' */ +
-                               outFilenameLen + 3 /* .so */;
-      char *outLib = new char [outLibLen + 1];
-
-      if (snprintf(outLib, outLibLen + 1, "%s/%s.so",
-                   outDir, outFilename) != static_cast<ssize_t>(outLibLen)) {
-        bccResult = -1;
-        errMsg = "failed to construct the path for output library.";
-        break;
-      }
-
-      bccResult = bccPrepareSharedObject(script, outDir, outFilename, NULL,
-                                         outLib, /* flags */0);
-      delete [] outLib;
-
+      bccResult = bccPrepareSharedObject(script, NULL, output, /* flags */0);
       errMsg = "failed to generate shared library.";
       break;
     }