Link libclcore.bc for RenderScript by default.
Change-Id: I93eb5a09689373afa973b8c08dd0842152220217
diff --git a/lib/RenderScript/RSInfo.cpp b/lib/RenderScript/RSInfo.cpp
index f3010cf..6f1b309 100644
--- a/lib/RenderScript/RSInfo.cpp
+++ b/lib/RenderScript/RSInfo.cpp
@@ -29,8 +29,11 @@
const char RSInfo::LibBCCPath[] = "/system/lib/libbcc.so";
const char RSInfo::LibRSPath[] = "/system/lib/libRS.so";
+const char RSInfo::LibCLCorePath[] = "/system/lib/libclcore.bc";
+
const uint8_t *RSInfo::LibBCCSHA1 = NULL;
const uint8_t *RSInfo::LibRSSHA1 = NULL;
+const uint8_t *RSInfo::LibCLCoreSHA1 = NULL;
void RSInfo::LoadBuiltInSHA1Information() {
if (LibBCCSHA1 != NULL) {
@@ -47,6 +50,8 @@
LibBCCSHA1 = reinterpret_cast<const uint8_t *>(::dlsym(h, "libbcc_so_SHA1"));
LibRSSHA1 = reinterpret_cast<const uint8_t *>(::dlsym(h, "libRS_so_SHA1"));
+ LibCLCoreSHA1 =
+ reinterpret_cast<const uint8_t *>(::dlsym(h, "libclcore_bc_SHA1"));
return;
}
@@ -69,8 +74,8 @@
bool RSInfo::CheckDependency(const RSInfo &pInfo,
const char *pInputFilename,
const RSScript::SourceDependencyListTy &pDeps) {
- // Built-in dependencies are libbcc.so and libRS.so.
- static const unsigned NumBuiltInDependencies = 2;
+ // Built-in dependencies are libbcc.so, libRS.so and libclcore.bc.
+ static const unsigned NumBuiltInDependencies = 3;
LoadBuiltInSHA1Information();
@@ -85,6 +90,8 @@
pInfo.mDependencyTable[0];
const std::pair<const char *, const uint8_t *> &cache_libRS_dep =
pInfo.mDependencyTable[1];
+ const std::pair<const char *, const uint8_t *> &cache_libclcore_dep =
+ pInfo.mDependencyTable[2];
// Check libbcc.so.
if (::memcmp(cache_libbcc_dep.second, LibBCCSHA1, SHA1_DIGEST_LENGTH) != 0) {
@@ -106,6 +113,17 @@
return false;
}
+ // Check libclcore.bc.
+ if (::memcmp(cache_libclcore_dep.second, LibCLCoreSHA1,
+ SHA1_DIGEST_LENGTH) != 0) {
+ ALOGD("Cache %s is dirty due to %s has been updated.", pInputFilename,
+ LibRSPath);
+ PRINT_DEPENDENCY("current - ", LibCLCorePath, LibCLCoreSHA1);
+ PRINT_DEPENDENCY("cache - ", cache_libclcore_dep.first,
+ cache_libclcore_dep.second);
+ return false;
+ }
+
for (unsigned i = 0; i < pDeps.size(); i++) {
const RSScript::SourceDependency &in_dep = *(pDeps[i]);
const std::pair<const char *, const uint8_t *> &cache_dep =
diff --git a/lib/RenderScript/RSInfoExtractor.cpp b/lib/RenderScript/RSInfoExtractor.cpp
index c303ef3..c9c75b2 100644
--- a/lib/RenderScript/RSInfoExtractor.cpp
+++ b/lib/RenderScript/RSInfoExtractor.cpp
@@ -167,6 +167,7 @@
// pool.
string_pool_size += ::strlen(LibBCCPath) + 1 + SHA1_DIGEST_LENGTH;
string_pool_size += ::strlen(LibRSPath) + 1 + SHA1_DIGEST_LENGTH;
+ string_pool_size += ::strlen(LibCLCorePath) + 1 + SHA1_DIGEST_LENGTH;
for (unsigned i = 0, e = pDeps.size(); i != e; i++) {
const RSScript::SourceDependency *source_dep = pDeps[i];
if (source_dep != NULL) {
@@ -371,6 +372,12 @@
goto bail;
}
+ if (!writeDependency(LibCLCorePath, LibCLCoreSHA1,
+ result->mStringPool, &cur_string_pool_offset,
+ result->mDependencyTable)) {
+ goto bail;
+ }
+
//===--------------------------------------------------------------------===//
// Record dependency information.
//===--------------------------------------------------------------------===//
diff --git a/lib/RenderScript/RSScript.cpp b/lib/RenderScript/RSScript.cpp
index ef39897..0efc43b 100644
--- a/lib/RenderScript/RSScript.cpp
+++ b/lib/RenderScript/RSScript.cpp
@@ -20,6 +20,8 @@
#include <llvm/ADT/STLExtras.h>
+#include "bcc/RenderScript/RSInfo.h"
+#include "bcc/Source.h"
#include "bcc/Support/Log.h"
using namespace bcc;
@@ -31,6 +33,27 @@
return;
}
+bool RSScript::LinkRuntime(RSScript &pScript) {
+ // Using the same context with the source in pScript.
+ BCCContext &context = pScript.getSource().getContext();
+ Source *libclcore_source = Source::CreateFromFile(context,
+ RSInfo::LibCLCorePath);
+ if (libclcore_source == NULL) {
+ ALOGE("Failed to load Renderscript library '%s' to link!",
+ RSInfo::LibCLCorePath);
+ return false;
+ }
+
+ if (!pScript.getSource().merge(*libclcore_source,
+ /* pPreserveSource */false)) {
+ ALOGE("Failed to link RenderScript library '%s'!", RSInfo::LibCLCorePath);
+ delete libclcore_source;
+ return false;
+ }
+
+ return true;
+}
+
RSScript::RSScript(Source &pSource)
: Script(pSource), mInfo(NULL), mCompilerVersion(0),
mOptimizationLevel(kOptLvl3) { }