summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler_llvm/compilation_unit.cc21
-rw-r--r--src/utils.cc6
-rw-r--r--src/utils.h2
3 files changed, 19 insertions, 10 deletions
diff --git a/src/compiler_llvm/compilation_unit.cc b/src/compiler_llvm/compilation_unit.cc
index a1d66f13b6..b1ca33358e 100644
--- a/src/compiler_llvm/compilation_unit.cc
+++ b/src/compiler_llvm/compilation_unit.cc
@@ -205,13 +205,22 @@ class ScopedTempFile {
};
bool CompilationUnit::Materialize() {
- std::string tmp_file = GetArtCacheOrDie();
- tmp_file += "/art-llvm-XXXXXX";
+ const char* android_data = getenv("ANDROID_DATA");
+ if (android_data == NULL) {
+ if (OS::DirectoryExists("/data")) {
+ android_data = "/data";
+ } else {
+ android_data = "/tmp";
+ }
+ }
+
+ std::string art_cache = GetArtCacheOrDie(android_data);
+ art_cache += "/art-llvm-XXXXXX";
// Prepare the input
- ScopedTempFile input(tmp_file);
+ ScopedTempFile input(art_cache);
if (input.GetFd() < 0) {
- PLOG(ERROR) << "Failed to save the module to the file " << tmp_file;
+ PLOG(ERROR) << "Failed to save the module to the file " << art_cache;
return false;
}
@@ -221,9 +230,9 @@ bool CompilationUnit::Materialize() {
}
// Prepare the output
- ScopedTempFile output(tmp_file);
+ ScopedTempFile output(art_cache);
if (output.GetFd() < 0) {
- PLOG(ERROR) << "Failed to prepare the output file " << tmp_file;
+ PLOG(ERROR) << "Failed to prepare the output file " << art_cache;
return false;
}
diff --git a/src/utils.cc b/src/utils.cc
index dc1ebffa2f..67fda67e7d 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -906,8 +906,8 @@ const char* GetAndroidData() {
return android_data;
}
-std::string GetArtCacheOrDie() {
- std::string art_cache(StringPrintf("%s/art-cache", GetAndroidData()));
+std::string GetArtCacheOrDie(const char* android_data) {
+ std::string art_cache(StringPrintf("%s/art-cache", android_data));
if (!OS::DirectoryExists(art_cache.c_str())) {
if (StartsWith(art_cache, "/tmp/")) {
@@ -925,7 +925,7 @@ std::string GetArtCacheOrDie() {
}
std::string GetArtCacheFilenameOrDie(const std::string& location) {
- std::string art_cache(GetArtCacheOrDie());
+ std::string art_cache(GetArtCacheOrDie(GetAndroidData()));
CHECK_EQ(location[0], '/') << location;
std::string cache_file(location, 1); // skip leading slash
std::replace(cache_file.begin(), cache_file.end(), '/', '@');
diff --git a/src/utils.h b/src/utils.h
index f94c05ec97..994e9bc431 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -283,7 +283,7 @@ const char* GetAndroidRoot();
const char* GetAndroidData();
// Returns the art-cache location, or dies trying.
-std::string GetArtCacheOrDie();
+std::string GetArtCacheOrDie(const char* android_data);
// Returns the art-cache location for a DexFile or OatFile, or dies trying.
std::string GetArtCacheFilenameOrDie(const std::string& location);