aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLuke Drummond <luke.drummond@codeplay.com>2017-01-18 16:20:55 -0800
committerDavid Gross <dgross@google.com>2017-04-12 13:59:20 -0700
commitf4c3483f3abc4cadd20672ce49acfe0c88a1c1da (patch)
treeeddaca055619a30926c9ed6f0c7e619b9bb55dfe /lib
parentcdaa220180816502916106fce603b6961a020357 (diff)
downloadlibbcc-f4c3483f3abc4cadd20672ce49acfe0c88a1c1da.tar.gz
Insert a new `versionInfo` field into the `.rs.info` symbol
This allows us to warn the user when compiling bitcode with different frontend / backend versions both at compile time, as well as debug time (a check is to be inserted into lldb as well). - Extract from the bitcode metadata the version of LLVM slang has generated used to emit bitcode (if possible) and embed it alongside the version of LLVM this version of libbcc is linked against. This allows us to notify the user of any possible known or unknown incompatibilities between the version, and in our case let the debugger track the difference between versions of LLVM used to generate the debug symbols which is known to have no cross-version compatibility guarantees - update bcc to emit a warning when the bitcode version doesn't match - Add positive version match tests + compatibility tests + negative tests Test: aosp_x86_64-eng (emulator) - libbcc/tests - RsTest (32-bit, 64-bit) - cts -m RenderscriptTest - rs/lldb (required various other pending CLs) Change-Id: I3b0ad8bbaba1846adb615da0988980cb1c95ad02 Signed-off-by: Luke Drummond <luke.drummond@codeplay.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/RSEmbedInfo.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/RSEmbedInfo.cpp b/lib/RSEmbedInfo.cpp
index 0acea3d..77208cd 100644
--- a/lib/RSEmbedInfo.cpp
+++ b/lib/RSEmbedInfo.cpp
@@ -23,11 +23,13 @@
#include "bcc/Config.h"
#include "bcinfo/MetadataExtractor.h"
+#include <string>
#include <cstdlib>
#include <vector>
#include <llvm/IR/DerivedTypes.h>
#include <llvm/IR/Function.h>
+#include <llvm/IR/Metadata.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Module.h>
@@ -157,6 +159,32 @@ public:
s << "buildChecksum: " << buildChecksum << "\n";
}
+ {
+ // As per `exportReduceCount`'s linewise fields, we use the literal `"."`
+ // to signify the empty field. This makes it easy to parse when it's
+ // missing.
+ llvm::StringRef slangVersion(".");
+ if (auto nmd = module->getNamedMetadata("slang.llvm.version")) {
+ if (auto md = nmd->getOperand(0)) {
+ if (const auto ver =
+ llvm::dyn_cast<llvm::MDString>(md->getOperand(0))) {
+ slangVersion = ver->getString();
+ }
+ }
+ }
+ s << "versionInfo: 2\n";
+ s << "bcc - " << LLVM_VERSION_STRING << "\n";
+ s << "slang - " << slangVersion << "\n";
+ if (slangVersion != LLVM_VERSION_STRING && me.hasDebugInfo()) {
+ ALOGW(
+ "The debug info in module '%s' has a different version than "
+ "expected (%s, expecting %s). The debugging experience may be "
+ "unreliable.",
+ module->getModuleIdentifier().c_str(), slangVersion.str().c_str(),
+ LLVM_VERSION_STRING);
+ }
+ }
+
s.flush();
return str;
}