aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Luc Brouillet <jeanluc@google.com>2014-06-18 18:14:02 -0700
committerJean-Luc Brouillet <jeanluc@google.com>2014-06-19 18:21:27 -0700
commitc5e607adff80a66bc5420baffd299862abdf368d (patch)
treeccf24dd4206dfc54f4587b7908a084a888d75a41
parentdc6c3df32c527dcfd1b454559e80e6b74d59750b (diff)
downloadlibbcc-c5e607adff80a66bc5420baffd299862abdf368d.tar.gz
Change cache dependency tracking.
Remove the fix dependencies and make it depend only on the source hash. More changes coming soon to add dependencies on the Android build fingerprint and the command line used to compile. Change-Id: I8964044affccf52326ce286f879307eca79d0b24
-rw-r--r--Android.mk33
-rw-r--r--CleanSpec.mk2
-rw-r--r--include/bcc/Config/BuildInfo.h37
-rw-r--r--include/bcc/Renderscript/RSCompilerDriver.h4
-rw-r--r--include/bcc/Renderscript/RSInfo.h65
-rw-r--r--lib/Renderscript/RSCompilerDriver.cpp37
-rw-r--r--lib/Renderscript/RSInfo.cpp218
-rw-r--r--lib/Renderscript/RSInfoExtractor.cpp101
-rw-r--r--lib/Renderscript/RSInfoReader.cpp39
-rw-r--r--lib/Renderscript/RSInfoWriter.cpp29
-rw-r--r--lib/Renderscript/RSScript.cpp25
-rw-r--r--libbcc-gen-build-info.mk57
-rw-r--r--tools/bcc/Main.cpp16
-rw-r--r--tools/bcc_compat/Main.cpp13
-rwxr-xr-xtools/build/gen-build-info.py154
-rwxr-xr-xtools/build/gen-sha1-stamp.py121
16 files changed, 97 insertions, 854 deletions
diff --git a/Android.mk b/Android.mk
index 2fc8fb3..dc7ca8f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -34,18 +34,6 @@ libbcc_WHOLE_STATIC_LIBRARIES += \
libbccSupport
#=====================================================================
-# Calculate SHA1 checksum for libbcc.so, libRS.so and libclcore.bc
-#=====================================================================
-
-my_2nd_arch_prefix :=
-include $(LOCAL_PATH)/libbcc.sha1.mk
-ifneq ($(TARGET_2ND_ARCH),)
-my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
-include $(LOCAL_PATH)/libbcc.sha1.mk
-endif
-my_2nd_arch_prefix :=
-
-#=====================================================================
# Device Shared Library libbcc
#=====================================================================
ifneq (true,$(DISABLE_LLVM_DEVICE_BUILDS))
@@ -71,7 +59,7 @@ LOCAL_SHARED_LIBRARIES := libbcinfo libLLVM libdl libutils libcutils liblog libc
# Modules that need get installed if and only if the target libbcc.so is
# installed.
-LOCAL_REQUIRED_MODULES := libclcore.bc libclcore_debug.bc libbcc.sha1 libcompiler_rt
+LOCAL_REQUIRED_MODULES := libclcore.bc libclcore_debug.bc libcompiler_rt
LOCAL_REQUIRED_MODULES_x86 += libclcore_x86.bc
LOCAL_REQUIRED_MODULES_x86_64 += libclcore_x86.bc
@@ -80,15 +68,6 @@ ifeq ($(ARCH_ARM_HAVE_NEON),true)
LOCAL_REQUIRED_MODULES_arm += libclcore_neon.bc
endif
-# Generate build information (Build time + Build git revision + Build Semi SHA1)
-my_2nd_arch_prefix :=
-include $(LIBBCC_ROOT_PATH)/libbcc-gen-build-info.mk
-ifdef TARGET_2ND_ARCH
-my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
-include $(LIBBCC_ROOT_PATH)/libbcc-gen-build-info.mk
-endif
-my_2nd_arch_prefix :=
-
include $(LIBBCC_DEVICE_BUILD_MK)
include $(BUILD_SHARED_LIBRARY)
endif
@@ -123,16 +102,6 @@ ifndef USE_MINGW
LOCAL_LDLIBS := -ldl -lpthread
endif
-# Generate build information (Build time + Build git revision + Build Semi SHA1)
-# For the host generate BuildInfo for a 32-bit build.
-ifdef HOST_2ND_ARCH
-my_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX)
-else
-my_2nd_arch_prefix :=
-endif
-include $(LIBBCC_ROOT_PATH)/libbcc-gen-build-info.mk
-my_2nd_arch_prefix :=
-
include $(LIBBCC_HOST_BUILD_MK)
include $(BUILD_HOST_SHARED_LIBRARY)
diff --git a/CleanSpec.mk b/CleanSpec.mk
index d3bc2f9..86467c6 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -64,6 +64,8 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libbc*_interme
$(call add-clean-step, rm -rf $(HOST_OUT)/obj/SHARED_LIBRARIES/libbc*_intermediates)
$(call add-clean-step, rm -rf $(HOST_OUT)/obj/STATIC_LIBRARIES/libbc*_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libbc*_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libbcc_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libbcc.sha1_intermediates)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
diff --git a/include/bcc/Config/BuildInfo.h b/include/bcc/Config/BuildInfo.h
deleted file mode 100644
index b2bbac0..0000000
--- a/include/bcc/Config/BuildInfo.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2012, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef BCC_CONFIG_BUILD_INFO_H
-#define BCC_CONFIG_BUILD_INFO_H
-
-namespace bcc {
-
-class BuildInfo {
-private:
- // Disable constructor since this is an utility class.
- BuildInfo();
-
-public:
- // The implementation of these functions is generated during build. See
- // libbcc-gen-build-info.mk and tools/build/gen-build-info.py for detail.
- static const char *GetBuildTime();
- static const char *GetBuildRev();
- static const char *GetBuildSourceBlob();
-};
-
-} // end namespace bcc
-
-#endif // BCC_CONFIG_BUILD_INFO_H
diff --git a/include/bcc/Renderscript/RSCompilerDriver.h b/include/bcc/Renderscript/RSCompilerDriver.h
index 765d9b2..f0246b4 100644
--- a/include/bcc/Renderscript/RSCompilerDriver.h
+++ b/include/bcc/Renderscript/RSCompilerDriver.h
@@ -62,7 +62,7 @@ private:
const char* pScriptName,
const char *pOutputPath,
const char *pRuntimePath,
- const RSInfo::DependencyTableTy &pDeps,
+ const RSInfo::DependencyHashTy &pSourceHash,
bool pSkipLoad, bool pDumpIR = false);
public:
@@ -111,7 +111,7 @@ public:
bool pDumpIR = false);
// Returns true if script is successfully compiled.
- bool build(RSScript &pScript, const char *pOut, const char *pRuntimePath);
+ bool buildForCompatLib(RSScript &pScript, const char *pOut, const char *pRuntimePath);
static RSExecutable *loadScript(const char *pCacheDir, const char *pResName,
const char *pBitcode, size_t pBitcodeSize,
diff --git a/include/bcc/Renderscript/RSInfo.h b/include/bcc/Renderscript/RSInfo.h
index 969ac4d..e88b410 100644
--- a/include/bcc/Renderscript/RSInfo.h
+++ b/include/bcc/Renderscript/RSInfo.h
@@ -48,7 +48,7 @@ namespace rsinfo {
#define RSINFO_MAGIC "\0rsinfo\n"
/* RS info file version, encoded in 4 bytes of ASCII */
-#define RSINFO_VERSION "004\0"
+#define RSINFO_VERSION "005\0"
struct __attribute__((packed)) ListHeader {
// The offset from the beginning of the file of data
@@ -59,6 +59,8 @@ struct __attribute__((packed)) ListHeader {
uint8_t itemSize;
};
+typedef uint32_t StringIndexTy;
+
/* RS info file header */
struct __attribute__((packed)) Header {
// Magic versus version
@@ -72,7 +74,10 @@ struct __attribute__((packed)) Header {
uint32_t strPoolSize;
- struct ListHeader dependencyTable;
+ // The SHA-1 checksum of the source file is stored as a string in the string pool.
+ // It has a fixed-length of SHA1_DIGEST_LENGTH (=20) bytes.
+ StringIndexTy sourceSha1Idx;
+
struct ListHeader pragmaList;
struct ListHeader objectSlotList;
struct ListHeader exportVarNameList;
@@ -80,18 +85,10 @@ struct __attribute__((packed)) Header {
struct ListHeader exportForeachFuncList;
};
-typedef uint32_t StringIndexTy;
// Use value -1 as an invalid string index marker. No need to declare with
// 'static' modifier since 'const' variable has internal linkage by default.
const StringIndexTy gInvalidStringIndex = static_cast<StringIndexTy>(-1);
-struct __attribute__((packed)) DependencyTableItem {
- StringIndexTy id;
- // SHA-1 checksum is stored as a string in string pool (and has fixed-length
- // SHA1_DIGEST_LENGTH (=20) bytes)
- StringIndexTy sha1;
-};
-
struct __attribute__((packed)) PragmaItem {
// Pragma is a key-value pair.
StringIndexTy key;
@@ -121,10 +118,6 @@ template<typename Item>
inline const char *GetItemTypeName();
template<>
-inline const char *GetItemTypeName<DependencyTableItem>()
-{ return "rs dependency info"; }
-
-template<>
inline const char *GetItemTypeName<PragmaItem>()
{ return "rs pragma"; }
@@ -148,8 +141,7 @@ inline const char *GetItemTypeName<ExportForeachFuncItem>()
class RSInfo {
public:
- typedef android::Vector<std::pair<const char *,
- const uint8_t *> > DependencyTableTy;
+ typedef const uint8_t* DependencyHashTy;
typedef android::Vector<std::pair<const char*, const char*> > PragmaListTy;
typedef android::Vector<uint32_t> ObjectSlotListTy;
typedef android::Vector<const char *> ExportVarNameListTy;
@@ -158,49 +150,19 @@ public:
uint32_t> > ExportForeachFuncListTy;
public:
- // Calculate or load the SHA-1 information of the built-in dependencies.
- static bool LoadBuiltInSHA1Information();
-
// Return the path of the RS info file corresponded to the given output
// executable file.
static android::String8 GetPath(const char *pFilename);
- static const char LibBCCPath[];
- static const char LibCompilerRTPath[];
- static const char LibRSPath[];
- static const char LibCLCorePath[];
- static const char LibCLCoreDebugPath[];
-#if defined(__i386__) || defined(__x86_64__)
- static const char LibCLCoreX86Path[];
-#endif
-#if defined(ARCH_ARM_HAVE_NEON)
- static const char LibCLCoreNEONPath[];
-#endif
+ bool CheckDependency(const char* pInputFilename, const DependencyHashTy& expectedSourceHash);
private:
- // SHA-1 of the built-in dependencies. Will be initialized in
- // LoadBuiltInSHA1Information().
- static const uint8_t *LibBCCSHA1;
- static const uint8_t *LibCompilerRTSHA1;
- static const uint8_t *LibRSSHA1;
- static const uint8_t *LibCLCoreSHA1;
- static const uint8_t *LibCLCoreDebugSHA1;
-#if defined(ARCH_ARM_HAVE_NEON)
- static const uint8_t *LibCLCoreNEONSHA1;
-#endif
-
- static bool CheckDependency(const RSInfo &pInfo,
- const char *pInputFilename,
- const DependencyTableTy &pDeps);
- static bool AddBuiltInDependencies(RSInfo &pInfo);
rsinfo::Header mHeader;
char *mStringPool;
- // In most of the time, there're 4 source dependencies stored (libbcc.so,
- // libRS.so, libclcore and the input bitcode itself.)
- DependencyTableTy mDependencyTable;
+ DependencyHashTy mSourceHash;
PragmaListTy mPragmas;
ObjectSlotListTy mObjectSlots;
ExportVarNameListTy mExportVarNames;
@@ -220,11 +182,10 @@ public:
// Implemented in RSInfoExtractor.cpp.
static RSInfo *ExtractFromSource(const Source &pSource,
- const DependencyTableTy &pDeps);
+ const DependencyHashTy &sourceHash);
// Implemented in RSInfoReader.cpp.
- static RSInfo *ReadFromFile(InputFile &pInput,
- const DependencyTableTy &pDeps);
+ static RSInfo *ReadFromFile(InputFile &pInput);
// Implemneted in RSInfoWriter.cpp
bool write(OutputFile &pOutput);
@@ -236,8 +197,6 @@ public:
{ return mHeader.isThreadable; }
inline bool hasDebugInformation() const
{ return mHeader.hasDebugInformation; }
- inline const DependencyTableTy &getDependencyTable() const
- { return mDependencyTable; }
inline const PragmaListTy &getPragmas() const
{ return mPragmas; }
inline const ObjectSlotListTy &getObjectSlots() const
diff --git a/lib/Renderscript/RSCompilerDriver.cpp b/lib/Renderscript/RSCompilerDriver.cpp
index 0f845bd..5adc362 100644
--- a/lib/Renderscript/RSCompilerDriver.cpp
+++ b/lib/Renderscript/RSCompilerDriver.cpp
@@ -70,8 +70,7 @@ RSCompilerDriver::loadScript(const char *pCacheDir, const char *pResName,
return NULL;
}
- RSInfo::DependencyTableTy dep_info;
- uint8_t bitcode_sha1[20];
+ uint8_t bitcode_sha1[SHA1_DIGEST_LENGTH];
Sha1Util::GetSHA1DigestFromBuffer(bitcode_sha1, pBitcode, pBitcodeSize);
// {pCacheDir}/{pResName}.o
@@ -79,8 +78,6 @@ RSCompilerDriver::loadScript(const char *pCacheDir, const char *pResName,
llvm::sys::path::append(output_path, pResName);
llvm::sys::path::replace_extension(output_path, ".o");
- dep_info.push(std::make_pair(output_path.c_str(), bitcode_sha1));
-
//===--------------------------------------------------------------------===//
// Acquire the read lock for reading the Script object file.
//===--------------------------------------------------------------------===//
@@ -121,7 +118,7 @@ RSCompilerDriver::loadScript(const char *pCacheDir, const char *pResName,
// Open and load the RS info file.
//===--------------------------------------------------------------------===//
InputFile info_file(info_path.string());
- RSInfo *info = RSInfo::ReadFromFile(info_file, dep_info);
+ RSInfo *info = RSInfo::ReadFromFile(info_file);
// Release the lock on object_file.
object_file->unlock();
@@ -131,6 +128,15 @@ RSCompilerDriver::loadScript(const char *pCacheDir, const char *pResName,
return NULL;
}
+ // If the info file contains a different hash for the source than what we are
+ // looking for, bail. The bit code found on disk is out of date and needs to
+ // be recompiled first.
+ if (!info->CheckDependency(output_path.c_str(), bitcode_sha1)) {
+ delete object_file;
+ delete info;
+ return NULL;
+ }
+
//===--------------------------------------------------------------------===//
// Create the RSExecutable.
//===--------------------------------------------------------------------===//
@@ -194,7 +200,7 @@ RSCompilerDriver::compileScript(RSScript &pScript,
const char* pScriptName,
const char *pOutputPath,
const char *pRuntimePath,
- const RSInfo::DependencyTableTy &pDeps,
+ const RSInfo::DependencyHashTy &pSourceHash,
bool pSkipLoad, bool pDumpIR) {
//android::StopWatch compile_time("bcc: RSCompilerDriver::compileScript time");
RSInfo *info = NULL;
@@ -204,7 +210,7 @@ RSCompilerDriver::compileScript(RSScript &pScript,
//===--------------------------------------------------------------------===//
// RS info may contains configuration (such as #optimization_level) to the
// compiler therefore it should be extracted before compilation.
- info = RSInfo::ExtractFromSource(pScript.getSource(), pDeps);
+ info = RSInfo::ExtractFromSource(pScript.getSource(), pSourceHash);
if (info == NULL) {
return Compiler::kErrInvalidSource;
}
@@ -354,8 +360,7 @@ bool RSCompilerDriver::build(BCCContext &pContext,
//===--------------------------------------------------------------------===//
// Prepare dependency information.
//===--------------------------------------------------------------------===//
- RSInfo::DependencyTableTy dep_info;
- uint8_t bitcode_sha1[20];
+ uint8_t bitcode_sha1[SHA1_DIGEST_LENGTH];
Sha1Util::GetSHA1DigestFromBuffer(bitcode_sha1, pBitcode, pBitcodeSize);
//===--------------------------------------------------------------------===//
@@ -366,8 +371,6 @@ bool RSCompilerDriver::build(BCCContext &pContext,
llvm::sys::path::append(output_path, pResName);
llvm::sys::path::replace_extension(output_path, ".o");
- dep_info.push(std::make_pair(output_path.c_str(), bitcode_sha1));
-
//===--------------------------------------------------------------------===//
// Load the bitcode and create script.
//===--------------------------------------------------------------------===//
@@ -401,7 +404,7 @@ bool RSCompilerDriver::build(BCCContext &pContext,
//===--------------------------------------------------------------------===//
Compiler::ErrorCode status = compileScript(*script, pResName,
output_path.c_str(),
- pRuntimePath, dep_info, false,
+ pRuntimePath, bitcode_sha1, false,
pDumpIR);
// Script is no longer used. Free it to get more memory.
@@ -415,10 +418,10 @@ bool RSCompilerDriver::build(BCCContext &pContext,
}
-bool RSCompilerDriver::build(RSScript &pScript, const char *pOut,
- const char *pRuntimePath) {
- RSInfo::DependencyTableTy dep_info;
- RSInfo *info = RSInfo::ExtractFromSource(pScript.getSource(), dep_info);
+bool RSCompilerDriver::buildForCompatLib(RSScript &pScript, const char *pOut,
+ const char *pRuntimePath) {
+ uint8_t bitcode_sha1[SHA1_DIGEST_LENGTH];
+ RSInfo *info = RSInfo::ExtractFromSource(pScript.getSource(), bitcode_sha1);
if (info == NULL) {
return false;
}
@@ -429,7 +432,7 @@ bool RSCompilerDriver::build(RSScript &pScript, const char *pOut,
pScript.setEmbedInfo(true);
Compiler::ErrorCode status = compileScript(pScript, pOut, pOut, pRuntimePath,
- dep_info, true);
+ bitcode_sha1, true);
if (status != Compiler::kSuccess) {
return false;
}
diff --git a/lib/Renderscript/RSInfo.cpp b/lib/Renderscript/RSInfo.cpp
index 5937fe4..e8793e7 100644
--- a/lib/Renderscript/RSInfo.cpp
+++ b/lib/Renderscript/RSInfo.cpp
@@ -34,199 +34,35 @@
using namespace bcc;
-#ifdef __LP64__
-#define SYSLIBPATH "/system/lib64"
-#else
-#define SYSLIBPATH "/system/lib"
-#endif
-
-const char RSInfo::LibBCCPath[] = SYSLIBPATH"/libbcc.so";
-const char RSInfo::LibCompilerRTPath[] = SYSLIBPATH"/libcompiler_rt.so";
-const char RSInfo::LibRSPath[] = SYSLIBPATH"/libRS.so";
-const char RSInfo::LibCLCorePath[] = SYSLIBPATH"/libclcore.bc";
-const char RSInfo::LibCLCoreDebugPath[] = SYSLIBPATH"/libclcore_debug.bc";
-#if defined(__i386__) || defined(__x86_64__)
-const char RSInfo::LibCLCoreX86Path[] = SYSLIBPATH"/libclcore_x86.bc";
-#endif
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
-const char RSInfo::LibCLCoreNEONPath[] = SYSLIBPATH"/libclcore_neon.bc";
-#endif
-
-const uint8_t *RSInfo::LibBCCSHA1 = NULL;
-const uint8_t *RSInfo::LibCompilerRTSHA1 = NULL;
-const uint8_t *RSInfo::LibRSSHA1 = NULL;
-const uint8_t *RSInfo::LibCLCoreSHA1 = NULL;
-const uint8_t *RSInfo::LibCLCoreDebugSHA1 = NULL;
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
-const uint8_t *RSInfo::LibCLCoreNEONSHA1 = NULL;
-#endif
-
-bool RSInfo::LoadBuiltInSHA1Information() {
-#ifdef TARGET_BUILD
- if (LibBCCSHA1 != NULL) {
- // Loaded before.
- return true;
- }
-
- void *h = ::dlopen(SYSLIBPATH"/libbcc.sha1.so", RTLD_LAZY | RTLD_NOW);
- if (h == NULL) {
- ALOGE("Failed to load SHA-1 information from shared library '"
- "/system/lib64/libbcc.sha1.so'! (%s)", ::dlerror());
- return false;
- }
-
- LibBCCSHA1 = reinterpret_cast<const uint8_t *>(::dlsym(h, "libbcc_so_SHA1"));
- LibCompilerRTSHA1 =
- reinterpret_cast<const uint8_t *>(::dlsym(h, "libcompiler_rt_so_SHA1"));
- LibRSSHA1 = reinterpret_cast<const uint8_t *>(::dlsym(h, "libRS_so_SHA1"));
- LibCLCoreSHA1 =
- reinterpret_cast<const uint8_t *>(::dlsym(h, "libclcore_bc_SHA1"));
- LibCLCoreDebugSHA1 =
- reinterpret_cast<const uint8_t *>(::dlsym(h, "libclcore_debug_bc_SHA1"));
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
- LibCLCoreNEONSHA1 =
- reinterpret_cast<const uint8_t *>(::dlsym(h, "libclcore_neon_bc_SHA1"));
-#endif
-
- return true;
-#else // TARGET_BUILD
- return false;
-#endif // TARGET_BUILD
-}
-
android::String8 RSInfo::GetPath(const char *pFilename) {
android::String8 result(pFilename);
result.append(".info");
return result;
}
-#define PRINT_DEPENDENCY(PREFIX, N, X) \
- ALOGV("\t" PREFIX "Source name: %s, " \
- "SHA-1: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" \
+#define PRINT_DEPENDENCY(PREFIX, X) \
+ ALOGV("\t" PREFIX "SHA-1: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" \
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", \
- (N), (X)[ 0], (X)[ 1], (X)[ 2], (X)[ 3], (X)[ 4], (X)[ 5], \
+ (X)[ 0], (X)[ 1], (X)[ 2], (X)[ 3], (X)[ 4], (X)[ 5], \
(X)[ 6], (X)[ 7], (X)[ 8], (X)[ 9], (X)[10], (X)[11], \
(X)[12], (X)[13], (X)[14], (X)[15], (X)[16], (X)[17], \
(X)[18], (X)[19]);
-bool RSInfo::CheckDependency(const RSInfo &pInfo,
- const char *pInputFilename,
- const DependencyTableTy &pDeps) {
- // Built-in dependencies are libbcc.so, libRS.so and libclcore.bc plus
- // libclcore_neon.bc if NEON is available on the target device.
-#if !defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
- static const unsigned NumBuiltInDependencies = 5;
-#else
- static const unsigned NumBuiltInDependencies = 6;
-#endif
-
- LoadBuiltInSHA1Information();
-
- if (pInfo.mDependencyTable.size() != (pDeps.size() + NumBuiltInDependencies)) {
- ALOGD("Number of dependencies recorded mismatch (%lu v.s. %lu) in %s!",
- static_cast<unsigned long>(pInfo.mDependencyTable.size()),
- static_cast<unsigned long>(pDeps.size() + NumBuiltInDependencies), pInputFilename);
- return false;
- } else {
- // Built-in dependencies always go first.
- const std::pair<const char *, const uint8_t *> &cache_libbcc_dep =
- pInfo.mDependencyTable[0];
- const std::pair<const char *, const uint8_t *> &cache_libcompiler_rt_dep =
- pInfo.mDependencyTable[1];
- const std::pair<const char *, const uint8_t *> &cache_libRS_dep =
- pInfo.mDependencyTable[2];
- const std::pair<const char *, const uint8_t *> &cache_libclcore_dep =
- pInfo.mDependencyTable[3];
- const std::pair<const char *, const uint8_t *> &cache_libclcore_debug_dep =
- pInfo.mDependencyTable[4];
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
- const std::pair<const char *, const uint8_t *> &cache_libclcore_neon_dep =
- pInfo.mDependencyTable[5];
-#endif
-
- // Check libbcc.so.
- if (::memcmp(cache_libbcc_dep.second, LibBCCSHA1, SHA1_DIGEST_LENGTH) != 0) {
- ALOGD("Cache %s is dirty due to %s has been updated.", pInputFilename,
- LibBCCPath);
- PRINT_DEPENDENCY("current - ", LibBCCPath, LibBCCSHA1);
- PRINT_DEPENDENCY("cache - ", cache_libbcc_dep.first,
- cache_libbcc_dep.second);
- return false;
- }
-
- // Check libcompiler_rt.so.
- if (::memcmp(cache_libcompiler_rt_dep.second, LibCompilerRTSHA1,
- SHA1_DIGEST_LENGTH) != 0) {
- ALOGD("Cache %s is dirty due to %s has been updated.", pInputFilename,
- LibCompilerRTPath);
- PRINT_DEPENDENCY("current - ", LibCompilerRTPath, LibCompilerRTSHA1);
- PRINT_DEPENDENCY("cache - ", cache_libcompiler_rt_dep.first,
- cache_libcompiler_rt_dep.second);
+bool RSInfo::CheckDependency(const char* pInputFilename,
+ const DependencyHashTy& pExpectedSourceHash) {
+ if (::memcmp(mSourceHash, pExpectedSourceHash, SHA1_DIGEST_LENGTH) != 0) {
+ ALOGD("Cache %s is dirty due to the source it depends on has been changed:",
+ pInputFilename);
+ PRINT_DEPENDENCY("given - ", pExpectedSourceHash);
+ PRINT_DEPENDENCY("cache - ", mSourceHash);
return false;
}
+ // TODO Remove once done with cache fixes.
+ // ALOGD("Cache %s is not dirty, the source it depends on has not changed:", pInputFilename);
+ // PRINT_DEPENDENCY("given - ", pExpectedSourceHash);
+ // PRINT_DEPENDENCY("cache - ", mSourceHash);
- // Check libRS.so.
- if (::memcmp(cache_libRS_dep.second, LibRSSHA1, SHA1_DIGEST_LENGTH) != 0) {
- ALOGD("Cache %s is dirty due to %s has been updated.", pInputFilename,
- LibRSPath);
- PRINT_DEPENDENCY("current - ", LibRSPath, LibRSSHA1);
- PRINT_DEPENDENCY("cache - ", cache_libRS_dep.first,
- cache_libRS_dep.second);
- 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,
- LibCLCorePath);
- PRINT_DEPENDENCY("current - ", LibCLCorePath, LibCLCoreSHA1);
- PRINT_DEPENDENCY("cache - ", cache_libclcore_dep.first,
- cache_libclcore_dep.second);
- return false;
- }
-
- // Check libclcore_debug.bc.
- if (::memcmp(cache_libclcore_debug_dep.second, LibCLCoreDebugSHA1,
- SHA1_DIGEST_LENGTH) != 0) {
- ALOGD("Cache %s is dirty due to %s has been updated.", pInputFilename,
- LibCLCoreDebugPath);
- PRINT_DEPENDENCY("current - ", LibCLCoreDebugPath, LibCLCoreDebugSHA1);
- PRINT_DEPENDENCY("cache - ", cache_libclcore_debug_dep.first,
- cache_libclcore_debug_dep.second);
- return false;
- }
-
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
- // Check libclcore_neon.bc if NEON is available.
- if (::memcmp(cache_libclcore_neon_dep.second, LibCLCoreNEONSHA1,
- SHA1_DIGEST_LENGTH) != 0) {
- ALOGD("Cache %s is dirty due to %s has been updated.", pInputFilename,
- LibCLCoreNEONPath);
- PRINT_DEPENDENCY("current - ", LibCLCoreNEONPath, LibCLCoreNEONSHA1);
- PRINT_DEPENDENCY("cache - ", cache_libclcore_neon_dep.first,
- cache_libclcore_neon_dep.second);
- return false;
- }
-#endif
-
- for (unsigned i = 0; i < pDeps.size(); i++) {
- const std::pair<const char *, const uint8_t *> &cache_dep =
- pInfo.mDependencyTable[i + NumBuiltInDependencies];
-
- if ((::strcmp(pDeps[i].first, cache_dep.first) != 0) ||
- (::memcmp(pDeps[i].second, cache_dep.second,
- SHA1_DIGEST_LENGTH) != 0)) {
- ALOGD("Cache %s is dirty due to the source it dependends on has been "
- "changed:", pInputFilename);
- PRINT_DEPENDENCY("given - ", pDeps[i].first, pDeps[i].second);
- PRINT_DEPENDENCY("cache - ", cache_dep.first, cache_dep.second);
- return false;
- }
- }
- }
-
- return true;
+ return true;
}
RSInfo::RSInfo(size_t pStringPoolSize) : mStringPool(NULL) {
@@ -237,7 +73,6 @@ RSInfo::RSInfo(size_t pStringPoolSize) : mStringPool(NULL) {
mHeader.headerSize = sizeof(mHeader);
- mHeader.dependencyTable.itemSize = sizeof(rsinfo::DependencyTableItem);
mHeader.pragmaList.itemSize = sizeof(rsinfo::PragmaItem);
mHeader.objectSlotList.itemSize = sizeof(rsinfo::ObjectSlotItem);
mHeader.exportVarNameList.itemSize = sizeof(rsinfo::ExportVarNameItem);
@@ -253,6 +88,7 @@ RSInfo::RSInfo(size_t pStringPoolSize) : mStringPool(NULL) {
}
::memset(mStringPool, 0, mHeader.strPoolSize);
}
+ mSourceHash = NULL;
}
RSInfo::~RSInfo() {
@@ -260,15 +96,12 @@ RSInfo::~RSInfo() {
}
bool RSInfo::layout(off_t initial_offset) {
- mHeader.dependencyTable.offset = initial_offset +
- mHeader.headerSize +
- mHeader.strPoolSize;
- mHeader.dependencyTable.count = mDependencyTable.size();
-
-#define AFTER(_list) ((_list).offset + (_list).itemSize * (_list).count)
- mHeader.pragmaList.offset = AFTER(mHeader.dependencyTable);
+ mHeader.pragmaList.offset = initial_offset +
+ mHeader.headerSize +
+ mHeader.strPoolSize;
mHeader.pragmaList.count = mPragmas.size();
+#define AFTER(_list) ((_list).offset + (_list).itemSize * (_list).count)
mHeader.objectSlotList.offset = AFTER(mHeader.pragmaList);
mHeader.objectSlotList.count = mObjectSlots.size();
@@ -295,17 +128,18 @@ void RSInfo::dump() const {
ALOGV("\tHeader size: %u", mHeader.headerSize);
ALOGV("\tString pool size: %u", mHeader.strPoolSize);
+ if (mSourceHash == NULL) {
+ ALOGE("Source hash: NULL!");
+ } else {
+ PRINT_DEPENDENCY("Source hash: ", mSourceHash);
+ }
+
#define DUMP_LIST_HEADER(_name, _header) do { \
ALOGV(_name ":"); \
ALOGV("\toffset: %u", (_header).offset); \
ALOGV("\t# of item: %u", (_header).count); \
ALOGV("\tsize of each item: %u", (_header).itemSize); \
} while (false)
- DUMP_LIST_HEADER("Dependency table", mHeader.dependencyTable);
- for (DependencyTableTy::const_iterator dep_iter = mDependencyTable.begin(),
- dep_end = mDependencyTable.end(); dep_iter != dep_end; dep_iter++) {
- PRINT_DEPENDENCY("", dep_iter->first, dep_iter->second);
- }
DUMP_LIST_HEADER("Pragma list", mHeader.pragmaList);
for (PragmaListTy::const_iterator pragma_iter = mPragmas.begin(),
diff --git a/lib/Renderscript/RSInfoExtractor.cpp b/lib/Renderscript/RSInfoExtractor.cpp
index 338243b..1684ed4 100644
--- a/lib/Renderscript/RSInfoExtractor.cpp
+++ b/lib/Renderscript/RSInfoExtractor.cpp
@@ -105,28 +105,10 @@ const char *writeString(const llvm::StringRef &pString, char *pStringPool,
return pStringWriteStart;
}
-bool writeDependency(const std::string &pSourceName, const uint8_t *pSHA1,
- char *pStringPool, off_t *pWriteStart,
- RSInfo::DependencyTableTy &pDepTable) {
- const char *source_name = writeString(pSourceName, pStringPool, pWriteStart);
-
- uint8_t *sha1 = reinterpret_cast<uint8_t *>(pStringPool + *pWriteStart);
-
- // SHA-1 is special. It's size of SHA1_DIGEST_LENGTH (=20) bytes long without
- // null-terminator.
- ::memcpy(sha1, pSHA1, SHA1_DIGEST_LENGTH);
- // Record in the result RSInfo object.
- pDepTable.push(std::make_pair(source_name, sha1));
- // Update the string pool pointer.
- *pWriteStart += SHA1_DIGEST_LENGTH;
-
- return true;
-}
-
} // end anonymous namespace
RSInfo *RSInfo::ExtractFromSource(const Source &pSource,
- const DependencyTableTy &pDeps)
+ const DependencyHashTy &pSourceHashToEmbed)
{
const llvm::Module &module = pSource.getModule();
const char *module_name = module.getModuleIdentifier().c_str();
@@ -163,22 +145,8 @@ RSInfo *RSInfo::ExtractFromSource(const Source &pSource,
string_pool_size += getMetadataStringLength<1>(export_func);
string_pool_size += getMetadataStringLength<1>(export_foreach_name);
- // Don't forget to reserve the space for the dependency informationin string
- // pool.
- string_pool_size += ::strlen(LibBCCPath) + 1 + SHA1_DIGEST_LENGTH;
- string_pool_size += ::strlen(LibCompilerRTPath) + 1 + SHA1_DIGEST_LENGTH;
- string_pool_size += ::strlen(LibRSPath) + 1 + SHA1_DIGEST_LENGTH;
- string_pool_size += ::strlen(LibCLCorePath) + 1 + SHA1_DIGEST_LENGTH;
- string_pool_size += ::strlen(LibCLCoreDebugPath) + 1 + SHA1_DIGEST_LENGTH;
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
- string_pool_size += ::strlen(LibCLCoreNEONPath) + 1 + SHA1_DIGEST_LENGTH;
-#endif
- for (unsigned i = 0, e = pDeps.size(); i != e; i++) {
- // +1 for null-terminator
- string_pool_size += ::strlen(/* name */pDeps[i].first) + 1;
- // +SHA1_DIGEST_LENGTH for SHA-1 checksum
- string_pool_size += SHA1_DIGEST_LENGTH;
- }
+ // Reserve the space for the source hash.
+ string_pool_size += SHA1_DIGEST_LENGTH;
// Allocate result object
result = new (std::nothrow) RSInfo(string_pool_size);
@@ -362,58 +330,17 @@ RSInfo *RSInfo::ExtractFromSource(const Source &pSource,
}
#undef FOR_EACH_NODE_IN
- if (LoadBuiltInSHA1Information()) {
- //===------------------------------------------------------------------===//
- // Record built-in dependency information.
- //===------------------------------------------------------------------===//
- if (!writeDependency(LibBCCPath, LibBCCSHA1,
- result->mStringPool, &cur_string_pool_offset,
- result->mDependencyTable)) {
- goto bail;
- }
-
- if (!writeDependency(LibCompilerRTPath, LibCompilerRTSHA1,
- 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 (!writeDependency(LibCLCoreDebugPath, LibCLCoreDebugSHA1,
- result->mStringPool, &cur_string_pool_offset,
- result->mDependencyTable)) {
- goto bail;
- }
-
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_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;
- }
- }
+ //===------------------------------------------------------------------===//
+ // Record dependency information.
+ //===------------------------------------------------------------------===//
+ {
+ // Store the SHA-1 in the string pool but without a null-terminator.
+ result->mHeader.sourceSha1Idx = cur_string_pool_offset;
+ uint8_t* sha1 = reinterpret_cast<uint8_t*>(result->mStringPool + cur_string_pool_offset);
+ ::memcpy(sha1, pSourceHashToEmbed, SHA1_DIGEST_LENGTH);
+ // Update the string pool pointer.
+ cur_string_pool_offset += SHA1_DIGEST_LENGTH;
+ result->mSourceHash = sha1;
}
//===--------------------------------------------------------------------===//
diff --git a/lib/Renderscript/RSInfoReader.cpp b/lib/Renderscript/RSInfoReader.cpp
index ccf9b73..bf66b66 100644
--- a/lib/Renderscript/RSInfoReader.cpp
+++ b/lib/Renderscript/RSInfoReader.cpp
@@ -36,33 +36,6 @@ inline bool helper_read_list_item(const ItemType &pItem,
const RSInfo &pInfo,
ItemContainer &pResult);
-// Process DependencyTableItem in the file
-template<> inline bool
-helper_read_list_item<rsinfo::DependencyTableItem, RSInfo::DependencyTableTy>(
- const rsinfo::DependencyTableItem &pItem,
- const RSInfo &pInfo,
- RSInfo::DependencyTableTy &pResult)
-{
- const char *id = pInfo.getStringFromPool(pItem.id);
- const uint8_t *sha1 =
- reinterpret_cast<const uint8_t *>(pInfo.getStringFromPool(pItem.sha1));
-
- if (id == NULL) {
- ALOGE("Invalid string index %d for source id in RS dependenct table.",
- pItem.id);
- return false;
- }
-
- if (sha1 == NULL) {
- ALOGE("Invalid string index %d for SHA-1 checksum in RS dependenct table.",
- pItem.id);
- return false;
- }
-
- pResult.push(std::make_pair(id, sha1));
- return true;
-}
-
// Process PragmaItem in the file
template<> inline bool
helper_read_list_item<rsinfo::PragmaItem, RSInfo::PragmaListTy>(
@@ -173,7 +146,7 @@ inline bool helper_read_list(const uint8_t *pData,
} // end anonymous namespace
-RSInfo *RSInfo::ReadFromFile(InputFile &pInput, const DependencyTableTy &pDeps) {
+RSInfo *RSInfo::ReadFromFile(InputFile &pInput) {
android::FileMap *map = NULL;
RSInfo *result = NULL;
const uint8_t *data;
@@ -228,7 +201,6 @@ RSInfo *RSInfo::ReadFromFile(InputFile &pInput, const DependencyTableTy &pDeps)
// Check the size.
if ((header->headerSize != sizeof(rsinfo::Header)) ||
- (header->dependencyTable.itemSize != sizeof(rsinfo::DependencyTableItem)) ||
(header->pragmaList.itemSize != sizeof(rsinfo::PragmaItem)) ||
(header->objectSlotList.itemSize != sizeof(rsinfo::ObjectSlotItem)) ||
(header->exportVarNameList.itemSize != sizeof(rsinfo::ExportVarNameItem)) ||
@@ -242,7 +214,6 @@ RSInfo *RSInfo::ReadFromFile(InputFile &pInput, const DependencyTableTy &pDeps)
#define LIST_DATA_RANGE(_list_header) \
((_list_header).offset + (_list_header).count * (_list_header).itemSize)
if (((header->headerSize + header->strPoolSize) > filesize) ||
- (LIST_DATA_RANGE(header->dependencyTable) > filesize) ||
(LIST_DATA_RANGE(header->pragmaList) > filesize) ||
(LIST_DATA_RANGE(header->objectSlotList) > filesize) ||
(LIST_DATA_RANGE(header->exportVarNameList) > filesize) ||
@@ -279,9 +250,11 @@ RSInfo *RSInfo::ReadFromFile(InputFile &pInput, const DependencyTableTy &pDeps)
}
// Populate all the data to the result object.
- if (!helper_read_list<rsinfo::DependencyTableItem, DependencyTableTy>
- (data, *result, header->dependencyTable, result->mDependencyTable)) {
- goto bail;
+ result->mSourceHash =
+ reinterpret_cast<const uint8_t*>(result->getStringFromPool(header->sourceSha1Idx));
+ if (result->mSourceHash == NULL) {
+ ALOGE("Invalid string index %d for SHA-1 checksum of source.", header->sourceSha1Idx);
+ goto bail;
}
if (!helper_read_list<rsinfo::PragmaItem, PragmaListTy>
diff --git a/lib/Renderscript/RSInfoWriter.cpp b/lib/Renderscript/RSInfoWriter.cpp
index 0eee62c..f9e2e2f 100644
--- a/lib/Renderscript/RSInfoWriter.cpp
+++ b/lib/Renderscript/RSInfoWriter.cpp
@@ -31,29 +31,6 @@ template<typename ItemType, typename ItemContainer> inline bool
helper_adapt_list_item(ItemType &pResult, const RSInfo &pInfo,
const typename ItemContainer::const_iterator &pItem);
-template<> inline bool
-helper_adapt_list_item<rsinfo::DependencyTableItem, RSInfo::DependencyTableTy>(
- rsinfo::DependencyTableItem &pResult,
- const RSInfo &pInfo,
- const RSInfo::DependencyTableTy::const_iterator &pItem) {
- pResult.id = pInfo.getStringIdxInPool(pItem->first);
- pResult.sha1 =
- pInfo.getStringIdxInPool(reinterpret_cast<const char *>(pItem->second));
-
- if (pResult.id == rsinfo::gInvalidStringIndex) {
- ALOGE("RS dependency table contains invalid source id string '%s'.",
- pItem->first);
- return false;
- }
-
- if (pResult.sha1 == rsinfo::gInvalidStringIndex) {
- ALOGE("RS dependency table contains invalid SHA-1 checksum string in '%s'.",
- pItem->first);
- return false;
- }
-
- return true;
-}
template<> inline bool
helper_adapt_list_item<rsinfo::PragmaItem, RSInfo::PragmaListTy>(
@@ -194,12 +171,6 @@ bool RSInfo::write(OutputFile &pOutput) {
return false;
}
- // Write dependencyTable.
- if (!helper_write_list<rsinfo::DependencyTableItem, DependencyTableTy>
- (pOutput, *this, mHeader.dependencyTable, mDependencyTable)) {
- return false;
- }
-
// Write pragmaList.
if (!helper_write_list<rsinfo::PragmaItem, PragmaListTy>
(pOutput, *this, mHeader.pragmaList, mPragmas)) {
diff --git a/lib/Renderscript/RSScript.cpp b/lib/Renderscript/RSScript.cpp
index b7335ab..884de22 100644
--- a/lib/Renderscript/RSScript.cpp
+++ b/lib/Renderscript/RSScript.cpp
@@ -16,35 +16,18 @@
#include "bcc/Renderscript/RSScript.h"
+#include "bcc/Assert.h"
#include "bcc/Renderscript/RSInfo.h"
#include "bcc/Source.h"
#include "bcc/Support/Log.h"
using namespace bcc;
-bool RSScript::LinkRuntime(RSScript &pScript, const char *rt_path) {
+bool RSScript::LinkRuntime(RSScript &pScript, const char *core_lib) {
+ bccAssert(core_lib != NULL);
+
// Using the same context with the source in pScript.
BCCContext &context = pScript.getSource().getContext();
- const char* core_lib = RSInfo::LibCLCorePath;
-
- // x86 devices will use an optimized library.
-#if defined(__i386__) || defined(__x86_64__)
- core_lib = RSInfo::LibCLCoreX86Path;
-#endif
-
- // NEON-capable devices can use an accelerated math library for all
- // reduced precision scripts.
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
- const RSInfo* info = pScript.getInfo();
- if ((info != NULL) &&
- (info->getFloatPrecisionRequirement() != RSInfo::FP_Full)) {
- core_lib = RSInfo::LibCLCoreNEONPath;
- }
-#endif
-
- if (rt_path != NULL) {
- core_lib = rt_path;
- }
Source *libclcore_source = Source::CreateFromFile(context, core_lib);
if (libclcore_source == NULL) {
diff --git a/libbcc-gen-build-info.mk b/libbcc-gen-build-info.mk
deleted file mode 100644
index 3c9f06a..0000000
--- a/libbcc-gen-build-info.mk
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# NOTE: Following rules are extracted from base_rules.mk and binary.mk.
-# We must ensure that they are synchronized.
-
-LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE))
-ifdef LOCAL_IS_HOST_MODULE
- ifneq ($(LOCAL_IS_HOST_MODULE),true)
- $(error $(LOCAL_PATH): LOCAL_IS_HOST_MODULE must be "true" or empty, not "$(LOCAL_IS_HOST_MODULE)")
- endif
- my_prefix:=HOST_
-else
- my_prefix:=TARGET_
-endif
-
-so_suffix := $($(my_prefix)SHLIB_SUFFIX)
-a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
-
-# Extract Depended Libraries
-LOCAL_LIBBCC_LIB_DEPS := \
- $(foreach lib,$(LOCAL_STATIC_LIBRARIES), \
- $(call intermediates-dir-for, \
- STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(my_2nd_arch_prefix))/$(lib)$(a_suffix)) \
- $(foreach lib,$(LOCAL_WHOLE_STATIC_LIBRARIES), \
- $(call intermediates-dir-for, \
- STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(my_2nd_arch_prefix))/$(lib)$(a_suffix)) \
- $(addprefix $($(my_2nd_arch_prefix)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
- $(addsuffix $(so_suffix), $(LOCAL_SHARED_LIBRARIES))) \
-
-# Build Rules for Automatically Generated Build Information
-GEN := $(call local-intermediates-dir,,$(my_2nd_arch_prefix))/BuildInfo.cpp
-
-gen_build_info := $(LOCAL_PATH)/tools/build/gen-build-info.py
-
-$(GEN): PRIVATE_PATH := $(LOCAL_PATH)
-$(GEN): PRIVATE_DEPS := $(LOCAL_LIBBCC_LIB_DEPS)
-$(GEN): PRIVATE_CUSTOM_TOOL = $(gen_build_info) $(PRIVATE_PATH) \
- $(PRIVATE_DEPS) > $@
-$(GEN): $(gen_build_info) $(LOCAL_LIBBCC_LIB_DEPS) \
- $(wildcard $(LOCAL_PATH)/.git/COMMIT_EDITMSG)
- $(transform-generated-source)
-
-LOCAL_GENERATED_SOURCES_$($(my_prefix)$(my_2nd_arch_prefix)ARCH) += $(GEN)
diff --git a/tools/bcc/Main.cpp b/tools/bcc/Main.cpp
index 2ac3170..02860fe 100644
--- a/tools/bcc/Main.cpp
+++ b/tools/bcc/Main.cpp
@@ -33,7 +33,6 @@
#include <bcc/BCCContext.h>
#include <bcc/Compiler.h>
-#include <bcc/Config/BuildInfo.h>
#include <bcc/Config/Config.h>
#include <bcc/ExecutionEngine/CompilerRTSymbolResolver.h>
#include <bcc/ExecutionEngine/ObjectLoader.h>
@@ -109,14 +108,8 @@ OptOptLevel("O", llvm::cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
void BCCVersionPrinter() {
llvm::raw_ostream &os = llvm::outs();
os << "libbcc (The Android Open Source Project, http://www.android.com/):\n"
- << " Build time: " << BuildInfo::GetBuildTime() << "\n"
- << " Build revision: " << BuildInfo::GetBuildRev() << "\n"
- << " Build source blob: " << BuildInfo::GetBuildSourceBlob() << "\n"
- << " Default target: " << DEFAULT_TARGET_TRIPLE_STRING << "\n";
-
- os << "\n";
-
- os << "LLVM (http://llvm.org/):\n"
+ << " Default target: " << DEFAULT_TARGET_TRIPLE_STRING << "\n\n"
+ << "LLVM (http://llvm.org/):\n"
<< " Version: " << PACKAGE_VERSION << "\n";
return;
}
@@ -171,6 +164,11 @@ int main(int argc, char **argv) {
std::unique_ptr<llvm::MemoryBuffer> input_data;
+ if (OptBCLibFilename.empty()) {
+ ALOGE("Failed to compile bit code, -bclib was not specified");
+ return EXIT_FAILURE;
+ }
+
llvm::error_code ec =
llvm::MemoryBuffer::getFile(OptInputFilename.c_str(), input_data);
if (ec != llvm::error_code::success()) {
diff --git a/tools/bcc_compat/Main.cpp b/tools/bcc_compat/Main.cpp
index 401299c..a59b6d0 100644
--- a/tools/bcc_compat/Main.cpp
+++ b/tools/bcc_compat/Main.cpp
@@ -30,7 +30,6 @@
#include <bcc/BCCContext.h>
#include <bcc/Compiler.h>
-#include <bcc/Config/BuildInfo.h>
#include <bcc/Config/Config.h>
#include <bcc/ExecutionEngine/SymbolResolverProxy.h>
#include <bcc/ExecutionEngine/SymbolResolvers.h>
@@ -109,14 +108,8 @@ OptShared("shared", llvm::cl::desc("Create a shared library from input bitcode "
void BCCVersionPrinter() {
llvm::raw_ostream &os = llvm::outs();
os << "libbcc (The Android Open Source Project, http://www.android.com/):\n"
- << " Build time: " << BuildInfo::GetBuildTime() << "\n"
- << " Build revision: " << BuildInfo::GetBuildRev() << "\n"
- << " Build source blob: " << BuildInfo::GetBuildSourceBlob() << "\n"
- << " Default target: " << DEFAULT_TARGET_TRIPLE_STRING << "\n";
-
- os << "\n";
-
- os << "LLVM (http://llvm.org/):\n"
+ << " Default target: " << DEFAULT_TARGET_TRIPLE_STRING << "\n\n"
+ << "LLVM (http://llvm.org/):\n"
<< " Version: " << PACKAGE_VERSION << "\n";
return;
}
@@ -277,7 +270,7 @@ int main(int argc, char **argv) {
RSScript *s = NULL;
s = PrepareRSScript(context, OptInputFilenames);
- if (!rscd.build(*s, OutputFilename.c_str(), OptRuntimePath.c_str())) {
+ if (!rscd.buildForCompatLib(*s, OutputFilename.c_str(), OptRuntimePath.c_str())) {
fprintf(stderr, "Failed to compile script!");
return EXIT_FAILURE;
}
diff --git a/tools/build/gen-build-info.py b/tools/build/gen-build-info.py
deleted file mode 100755
index df3a0a3..0000000
--- a/tools/build/gen-build-info.py
+++ /dev/null
@@ -1,154 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2011-2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-import datetime
-import os
-import re
-import sys
-import subprocess
-
-try:
- import hashlib
- sha1 = hashlib.sha1
-except ImportError, e:
- import sha
- sha1 = sha.sha
-
-def get_repo_revision(repo_dir):
- if not os.path.exists(os.path.join(repo_dir, '.git')):
- return 'Unknown (not git)'
-
- # Get the HEAD revision
- proc = subprocess.Popen(['git', 'log', '-1', '--format=%H'],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- cwd=repo_dir)
- out, err = proc.communicate()
- proc.wait()
-
- rev_sha1 = out.strip()
-
- # Working Directory Modified
- proc = subprocess.Popen(['git', 'status'],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- cwd=repo_dir)
- out, err = proc.communicate()
- proc.wait()
-
- if out.find('(working directory clean)') == -1:
- mod = ' modified'
- else:
- mod = ''
-
- return rev_sha1 + mod + ' (git)'
-
-def compute_sha1(path, global_hasher = None):
- f = open(path, 'rb')
- hasher = sha1()
- while True:
- buf = f.read(512)
- hasher.update(buf)
- if global_hasher:
- global_hasher.update(buf)
- if len(buf) < 512:
- break
- f.close()
- return hasher.hexdigest()
-
-def compute_sha1_list(paths):
- hasher = sha1()
- sha1sums = []
- for path in paths:
- sha1sums.append(compute_sha1(path, hasher))
- return (hasher.hexdigest(), sha1sums)
-
-def quote_str(s):
- result = '"'
- for c in s:
- if c == '\\':
- result += '\\\\'
- elif c == '\r':
- result += '\\r'
- elif c == '\n':
- result += '\\n'
- elif c == '\t':
- result += '\\t'
- elif c == '\"':
- result += '\\"'
- elif c == '\'':
- result += '\\\''
- else:
- result += c
- result += '"'
- return result
-
-def main():
- # Check Argument
- if len(sys.argv) < 2:
- print >> sys.stderr, 'USAGE:', sys.argv[0], '[REPO] [LIBs]'
- sys.exit(1)
-
- # Record Build Time
- build_time = datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S')
-
- # Repository Directory (For build revision)
- repo_dir = sys.argv[1]
- build_rev = get_repo_revision(repo_dir)
-
- # Compute SHA1
- lib_list = list(set(sys.argv[2:]))
- lib_list.sort()
- build_sha1, sha1sum_list = compute_sha1_list(lib_list)
-
- # Build file list string
- lib_list_str = ''
- for i, path in enumerate(lib_list):
- lib_list_str += ' %s %s\n' % (sha1sum_list[i], path)
-
- # Print the automatically generated code
- print """/* Automatically generated file (DON'T MODIFY) */
-
-/* Repository directory: %s */
-
-/* File list:
-%s*/
-
-#include "bcc/Config/BuildInfo.h"
-
-using namespace bcc;
-
-const char* BuildInfo::GetBuildTime() {
- return %s;
-}
-
-const char *BuildInfo::GetBuildRev() {
- return %s;
-}
-
-const char *BuildInfo::GetBuildSourceBlob() {
- return %s;
-}
-
-""" % (os.path.abspath(repo_dir),
- lib_list_str,
- quote_str(build_time),
- quote_str(build_rev),
- quote_str(build_sha1))
-
-if __name__ == '__main__':
- main()
diff --git a/tools/build/gen-sha1-stamp.py b/tools/build/gen-sha1-stamp.py
deleted file mode 100755
index 012d522..0000000
--- a/tools/build/gen-sha1-stamp.py
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2011-2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-import os
-import sys
-
-try:
- import hashlib
- sha1 = hashlib.sha1
-except ImportError, e:
- import sha
- sha1 = sha.sha
-
-def compute_sha1(h, path):
- f = open(path, 'rb')
- while True:
- buf = f.read(1024)
- h.update(buf)
- if len(buf) < 1024:
- break
- f.close()
-
-"""The result is a list of pair of file path and its SHA-1 digest"""
-def compute_sha1_list(path_list):
- result = []
- for path in path_list:
- h = sha1()
- compute_sha1(h, path)
- result.append((path, h.digest()))
- return result
-
-"""For each path like /xxx/libfoo.so, generate a symbol named libfoo_so_SHA1"""
-def get_symbol_name(path):
- return os.path.basename(path).replace('.', '_') + '_SHA1';
-
-"""Print out header for assembly file."""
-def print_asm_header(symbols):
- sys.stdout.write("""
-/*\
- * The mid-2007 version of gcc that ships with Macs requires a\n\
- * comma on the .section line, but the rest of the world thinks\n\
- * that's a syntax error. It also wants globals to be explicitly\n\
- * prefixed with \"_\" as opposed to modern gccs that do the\n\
- * prefixing for you.\n\
- */\n\
-""")
- for sym in symbols:
- sys.stdout.write("""
-#ifdef __APPLE_CC__
-.globl _%s\n\
-#else\n\
-.globl %s\n\
-#endif\
-""" % (sym, sym))
- sys.stdout.write("""
-#ifdef __APPLE_CC__
- .section .rodata,\n\
-#else\n\
- .section .rodata\n\
-#endif\
-""" )
-
-def print_asm_data(data, size):
- col = 0
- for i in xrange(size):
- c = data[i]
- if col == 0:
- sys.stdout.write(".byte ")
- elif col % 4 == 0:
- sys.stdout.write(", ")
- else:
- sys.stdout.write(",")
- sys.stdout.write("0x%02x" % ord(c))
- col += 1
- if col == 8:
- sys.stdout.write("\n")
- col = 0
- if col != 0:
- sys.stdout.write("\n")
-
-def print_asm_symbol_data(sym, h):
- sys.stdout.write("""
-.align 8
-#ifdef __APPLE_CC__
-_%s:\n\
-#else\n\
-%s:\n\
-#endif\n\
-""" % (sym, sym))
- print_asm_data(h, 20)
-
-def print_asm(x):
- symbols = [get_symbol_name(item[0]) for item in x]
- print_asm_header(symbols)
- for (symbol, y) in zip(symbols, x):
- print_asm_symbol_data(symbol, y[1])
-
-def main():
- if len(sys.argv) < 2:
- print 'USAGE:', sys.argv[0], '[OUTPUT] [INPUTs]'
- sys.exit(1)
-
- result = compute_sha1_list(sys.argv[1:])
- print_asm(result)
-
-if __name__ == '__main__':
- main()