Add a -build-checksum flag to bcc
bug 19216507
Add a flag to bcc to pass a build checksum. The checksum is passed to
RSEmbedInfo pass via LLVM metadata.
The old checksum path is tied to RSInfo. Removing this path can be done
along with RSInfo removal.
Change-Id: I3f21c96ddcfe42c16754fbb7749a72595f90964d
diff --git a/lib/Renderscript/RSCompilerDriver.cpp b/lib/Renderscript/RSCompilerDriver.cpp
index 72dfc40..547700e 100644
--- a/lib/Renderscript/RSCompilerDriver.cpp
+++ b/lib/Renderscript/RSCompilerDriver.cpp
@@ -119,8 +119,15 @@
const char* pRuntimePath,
const RSInfo::DependencyHashTy& pSourceHash,
const char* compileCommandLineToEmbed,
+ const char* pBuildChecksum,
bool saveInfoFile, bool pDumpIR) {
// android::StopWatch compile_time("bcc: RSCompilerDriver::compileScript time");
+
+ // embed build checksum metadata into the source
+ if (pBuildChecksum != nullptr && strlen(pBuildChecksum) > 0) {
+ pScript.getSource().addBuildChecksumMetadata(pBuildChecksum);
+ }
+
RSInfo *info = nullptr;
//===--------------------------------------------------------------------===//
@@ -251,6 +258,7 @@
const char *pBitcode,
size_t pBitcodeSize,
const char *commandLine,
+ const char *pBuildChecksum,
const char *pRuntimePath,
RSLinkRuntimeCallback pLinkRuntimeCallback,
bool pDumpIR) {
@@ -313,7 +321,7 @@
Compiler::ErrorCode status = compileScript(script, pResName,
output_path.c_str(),
pRuntimePath, bitcode_sha1, commandLine,
- true, pDumpIR);
+ pBuildChecksum, true, pDumpIR);
return status == Compiler::kSuccess;
}
@@ -333,17 +341,20 @@
uint8_t bitcode_sha1[SHA1_DIGEST_LENGTH];
const char* compileCommandLineToEmbed = "";
+ const char* buildChecksum = nullptr;
llvm::SmallString<80> output_path(pOutputFilepath);
llvm::sys::path::replace_extension(output_path, ".o");
compileScript(script, pOutputFilepath, output_path.c_str(), pRuntimePath,
- bitcode_sha1, compileCommandLineToEmbed, true, dumpIR);
+ bitcode_sha1, compileCommandLineToEmbed, buildChecksum,
+ true, dumpIR);
return true;
}
bool RSCompilerDriver::buildForCompatLib(RSScript &pScript, const char *pOut,
+ const char *pBuildChecksum,
const char *pRuntimePath,
bool pDumpIR) {
// For compat lib, we don't check the RS info file so we don't need the source hash,
@@ -365,7 +376,7 @@
pScript.setEmbedInfo(true);
Compiler::ErrorCode status = compileScript(pScript, pOut, pOut, pRuntimePath, bitcode_sha1,
- compileCommandLineToEmbed, false, pDumpIR);
+ compileCommandLineToEmbed, pBuildChecksum, false, pDumpIR);
if (status != Compiler::kSuccess) {
return false;
}
diff --git a/lib/Renderscript/RSEmbedInfo.cpp b/lib/Renderscript/RSEmbedInfo.cpp
index 0ae97a2..731e778 100644
--- a/lib/Renderscript/RSEmbedInfo.cpp
+++ b/lib/Renderscript/RSEmbedInfo.cpp
@@ -84,6 +84,8 @@
const char **pragmaKeyList = me.getPragmaKeyList();
const char **pragmaValueList = me.getPragmaValueList();
bool isThreadable = me.isThreadable();
+ const char *buildChecksum = me.getBuildChecksum();
+
size_t i;
// We use a simple text format here that the compatibility library can
@@ -121,6 +123,10 @@
}
s << "isThreadable: " << ((isThreadable) ? "yes" : "no") << "\n";
+ if (buildChecksum != nullptr) {
+ s << "buildChecksum: " << buildChecksum << "\n";
+ }
+
s.flush();
return str;
}