bcc_compat - convert bitcode to shared object files.
BUG: 7419958
Change-Id: Ie81203b460d60425780657b51ba3aba2b2b77e05
diff --git a/lib/Renderscript/RSCompilerDriver.cpp b/lib/Renderscript/RSCompilerDriver.cpp
index c854b69..31d3807 100644
--- a/lib/Renderscript/RSCompilerDriver.cpp
+++ b/lib/Renderscript/RSCompilerDriver.cpp
@@ -184,7 +184,9 @@
RSCompilerDriver::compileScript(RSScript &pScript,
const char* pScriptName,
const char *pOutputPath,
- const RSInfo::DependencyTableTy &pDeps) {
+ const char *pRuntimePath,
+ const RSInfo::DependencyTableTy &pDeps,
+ bool pSkipLoad) {
android::StopWatch compile_time("bcc: RSCompilerDriver::compileScript time");
RSExecutable *result = NULL;
RSInfo *info = NULL;
@@ -209,7 +211,7 @@
//===--------------------------------------------------------------------===//
// Link RS script with Renderscript runtime.
//===--------------------------------------------------------------------===//
- if (!RSScript::LinkRuntime(pScript)) {
+ if (!RSScript::LinkRuntime(pScript, pRuntimePath)) {
ALOGE("Failed to link script '%s' with Renderscript runtime!", pScriptName);
return NULL;
}
@@ -276,6 +278,12 @@
return NULL;
}
+ // No need to produce an RSExecutable in this case.
+ // TODO: Error handling in this case is nonexistent.
+ if (pSkipLoad) {
+ return NULL;
+ }
+
//===--------------------------------------------------------------------===//
// Create the RSExecutable.
//===--------------------------------------------------------------------===//
@@ -317,7 +325,8 @@
const char *pCacheDir,
const char *pResName,
const char *pBitcode,
- size_t pBitcodeSize) {
+ size_t pBitcodeSize,
+ const char *pRuntimePath) {
android::StopWatch build_time("bcc: RSCompilerDriver::build time");
//===--------------------------------------------------------------------===//
// Check parameters.
@@ -393,7 +402,8 @@
//===--------------------------------------------------------------------===//
// Compile the script
//===--------------------------------------------------------------------===//
- result = compileScript(*script, pResName, output_path.c_str(), dep_info);
+ result = compileScript(*script, pResName, output_path.c_str(), pRuntimePath,
+ dep_info, false);
// Script is no longer used. Free it to get more memory.
delete script;
@@ -404,3 +414,19 @@
return result;
}
+
+
+RSExecutable *RSCompilerDriver::build(RSScript &pScript, const char *pOut,
+ const char *pRuntimePath) {
+ RSInfo::DependencyTableTy dep_info;
+ RSInfo *info = RSInfo::ExtractFromSource(pScript.getSource(), dep_info);
+ if (info == NULL) {
+ return NULL;
+ }
+ pScript.setInfo(info);
+
+ RSExecutable *result = compileScript(pScript, pOut, pOut, pRuntimePath,
+ dep_info, true);
+ return result;
+}
+
diff --git a/lib/Renderscript/RSInfo.cpp b/lib/Renderscript/RSInfo.cpp
index dbf8657..0d8fd68 100644
--- a/lib/Renderscript/RSInfo.cpp
+++ b/lib/Renderscript/RSInfo.cpp
@@ -43,17 +43,18 @@
const uint8_t *RSInfo::LibCLCoreNEONSHA1 = NULL;
#endif
-void RSInfo::LoadBuiltInSHA1Information() {
+bool RSInfo::LoadBuiltInSHA1Information() {
+#ifdef TARGET_BUILD
if (LibBCCSHA1 != NULL) {
// Loaded before.
- return;
+ return true;
}
void *h = ::dlopen("/system/lib/libbcc.sha1.so", RTLD_LAZY | RTLD_NOW);
if (h == NULL) {
ALOGE("Failed to load SHA-1 information from shared library '"
"/system/lib/libbcc.sha1.so'! (%s)", ::dlerror());
- return;
+ return false;
}
LibBCCSHA1 = reinterpret_cast<const uint8_t *>(::dlsym(h, "libbcc_so_SHA1"));
@@ -65,7 +66,10 @@
reinterpret_cast<const uint8_t *>(::dlsym(h, "libclcore_neon_bc_SHA1"));
#endif
- return;
+ return true;
+#else // TARGET_BUILD
+ return false;
+#endif // TARGET_BUILD
}
android::String8 RSInfo::GetPath(const FileBase &pFile) {
diff --git a/lib/Renderscript/RSInfoExtractor.cpp b/lib/Renderscript/RSInfoExtractor.cpp
index 4ba5703..c0775b5 100644
--- a/lib/Renderscript/RSInfoExtractor.cpp
+++ b/lib/Renderscript/RSInfoExtractor.cpp
@@ -360,46 +360,46 @@
}
#undef FOR_EACH_NODE_IN
- //===--------------------------------------------------------------------===//
- // Record built-in dependency information.
- //===--------------------------------------------------------------------===//
- LoadBuiltInSHA1Information();
-
- if (!writeDependency(LibBCCPath, LibBCCSHA1,
- result->mStringPool, &cur_string_pool_offset,
- result->mDependencyTable)) {
- goto bail;
- }
-
- if (!writeDependency(LibRSPath, LibRSSHA1,
- result->mStringPool, &cur_string_pool_offset,
- result->mDependencyTable)) {
- goto bail;
- }
-
- if (!writeDependency(LibCLCorePath, LibCLCoreSHA1,
- result->mStringPool, &cur_string_pool_offset,
- result->mDependencyTable)) {
- goto bail;
- }
-
-#if defined(ARCH_ARM_HAVE_NEON)
- if (!writeDependency(LibCLCoreNEONPath, LibCLCoreNEONSHA1,
- result->mStringPool, &cur_string_pool_offset,
- result->mDependencyTable)) {
- goto bail;
- }
-#endif
-
- //===--------------------------------------------------------------------===//
- // Record dependency information.
- //===--------------------------------------------------------------------===//
- for (unsigned i = 0, e = pDeps.size(); i != e; i++) {
- if (!writeDependency(/* name */pDeps[i].first, /* SHA-1 */pDeps[i].second,
+ if (LoadBuiltInSHA1Information()) {
+ //===------------------------------------------------------------------===//
+ // Record built-in dependency information.
+ //===------------------------------------------------------------------===//
+ if (!writeDependency(LibBCCPath, LibBCCSHA1,
result->mStringPool, &cur_string_pool_offset,
result->mDependencyTable)) {
goto bail;
}
+
+ if (!writeDependency(LibRSPath, LibRSSHA1,
+ result->mStringPool, &cur_string_pool_offset,
+ result->mDependencyTable)) {
+ goto bail;
+ }
+
+ if (!writeDependency(LibCLCorePath, LibCLCoreSHA1,
+ result->mStringPool, &cur_string_pool_offset,
+ result->mDependencyTable)) {
+ goto bail;
+ }
+
+#if defined(ARCH_ARM_HAVE_NEON)
+ if (!writeDependency(LibCLCoreNEONPath, LibCLCoreNEONSHA1,
+ result->mStringPool, &cur_string_pool_offset,
+ result->mDependencyTable)) {
+ goto bail;
+ }
+#endif
+
+ //===------------------------------------------------------------------===//
+ // Record dependency information.
+ //===------------------------------------------------------------------===//
+ for (unsigned i = 0, e = pDeps.size(); i != e; i++) {
+ if (!writeDependency(/* name */pDeps[i].first, /* SHA-1 */pDeps[i].second,
+ result->mStringPool, &cur_string_pool_offset,
+ result->mDependencyTable)) {
+ goto bail;
+ }
+ }
}
//===--------------------------------------------------------------------===//
diff --git a/lib/Renderscript/RSScript.cpp b/lib/Renderscript/RSScript.cpp
index 75cfff9..53c8946 100644
--- a/lib/Renderscript/RSScript.cpp
+++ b/lib/Renderscript/RSScript.cpp
@@ -22,7 +22,7 @@
using namespace bcc;
-bool RSScript::LinkRuntime(RSScript &pScript) {
+bool RSScript::LinkRuntime(RSScript &pScript, const char *rt_path) {
// Using the same context with the source in pScript.
BCCContext &context = pScript.getSource().getContext();
const char* core_lib = RSInfo::LibCLCorePath;
@@ -37,6 +37,10 @@
}
#endif
+ if (rt_path != NULL) {
+ core_lib = rt_path;
+ }
+
Source *libclcore_source = Source::CreateFromFile(context, core_lib);
if (libclcore_source == NULL) {
ALOGE("Failed to load Renderscript library '%s' to link!", core_lib);