Link libclcore.bc for RenderScript by default.
Change-Id: I93eb5a09689373afa973b8c08dd0842152220217
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) { }