Skip to content

Commit 1410510

Browse files
committed
Revert "Fix temporary directory computation on linux (pr25147)"
I actually did not want to commit this without review, but I mistyped. :/ llvm-svn: 250412
1 parent 668af71 commit 1410510

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

lldb/source/Host/android/HostInfoAndroid.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,11 @@ HostInfoAndroid::ResolveLibraryPath(const std::string& module_path, const ArchSp
9191
bool
9292
HostInfoAndroid::ComputeTempFileBaseDirectory(FileSpec &file_spec)
9393
{
94-
bool success = HostInfoLinux::ComputeTempFileBaseDirectory(file_spec);
94+
if (HostInfoLinux::ComputeTempFileBaseDirectory(file_spec))
95+
return true;
9596

96-
// On Android, there is no path which is guaranteed to be writable. If the user has not
97-
// provided a path via an environment variable, the generic algorithm will deduce /tmp, which
98-
// is plain wrong. In that case we have an invalid directory, we substitute the path with
99-
// /data/local/tmp, which is correct at least in some cases (i.e., when running as shell user).
100-
if (!success || !file_spec.Exists())
101-
file_spec = FileSpec("/data/local/tmp", false);
102-
103-
return file_spec.Exists();
97+
// If the default mechanism for computing the temp directory failed then
98+
// fall back to /data/local/tmp
99+
file_spec = FileSpec("/data/local/tmp", false);
100+
return true;
104101
}

lldb/source/Host/common/HostInfoBase.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "llvm/ADT/Triple.h"
2121
#include "llvm/ADT/StringExtras.h"
2222
#include "llvm/Support/Host.h"
23-
#include "llvm/Support/Path.h"
2423
#include "llvm/Support/raw_ostream.h"
2524

2625
#include <thread>
@@ -345,9 +344,19 @@ HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec)
345344
bool
346345
HostInfoBase::ComputeTempFileBaseDirectory(FileSpec &file_spec)
347346
{
348-
llvm::SmallVector<char, 16> tmpdir;
349-
llvm::sys::path::system_temp_directory(/*ErasedOnReboot*/ true, tmpdir);
350-
file_spec = FileSpec(std::string(tmpdir.data(), tmpdir.size()), true);
347+
file_spec.Clear();
348+
349+
const char *tmpdir_cstr = getenv("TMPDIR");
350+
if (tmpdir_cstr == nullptr)
351+
{
352+
tmpdir_cstr = getenv("TMP");
353+
if (tmpdir_cstr == nullptr)
354+
tmpdir_cstr = getenv("TEMP");
355+
}
356+
if (!tmpdir_cstr)
357+
return false;
358+
359+
file_spec = FileSpec(tmpdir_cstr, false);
351360
return true;
352361
}
353362

0 commit comments

Comments
 (0)