[PATCH] D12869: [Support] Add a new environment variable: LLVM_TEMP_DIR
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 14 17:57:38 PDT 2015
vsk created this revision.
vsk added a reviewer: steven_wu.
vsk added a subscriber: llvm-commits.
The compiler creates unique, temporary files when storing diagnostic
information (e.g when a crash occurs). If an absolute path is not
specified, prefer LLVM_TEMP_DIR for the location of these files.
For example:
$ LLVM_TEMP_DIR=/BuildData clang-borked /tmp/x.c -o /tmp/x
Here, the compiler spits out diagnostic files into /BuildData.
Motivation: This would make it easier for our build infrastructure to extract diagnostic files from crashing bots.
http://reviews.llvm.org/D12869
Files:
docs/TestingGuide.rst
lib/Support/Path.cpp
Index: lib/Support/Path.cpp
===================================================================
--- lib/Support/Path.cpp
+++ lib/Support/Path.cpp
@@ -157,6 +157,20 @@
FS_Name
};
+template<unsigned N>
+static void getTempDirectory(bool ErasedOnReboot, SmallString<N> &TDir) {
+ Optional<std::string> TempDir = sys::Process::GetEnv("LLVM_TEMP_DIR");
+ if (TempDir.hasValue()) {
+ std::string &Dir = TempDir.getValue();
+ if (sys::fs::is_directory(Dir)) {
+ TDir.assign(Dir.begin(), Dir.end());
+ return;
+ }
+ }
+
+ sys::path::system_temp_directory(ErasedOnReboot, TDir);
+}
+
static std::error_code createUniqueEntity(const Twine &Model, int &ResultFD,
SmallVectorImpl<char> &ResultPath,
bool MakeAbsolute, unsigned Mode,
@@ -168,7 +182,7 @@
// Make model absolute by prepending a temp directory if it's not already.
if (!sys::path::is_absolute(Twine(ModelStorage))) {
SmallString<128> TDir;
- sys::path::system_temp_directory(true, TDir);
+ getTempDirectory(true, TDir);
sys::path::append(TDir, Twine(ModelStorage));
ModelStorage.swap(TDir);
}
Index: docs/TestingGuide.rst
===================================================================
--- docs/TestingGuide.rst
+++ docs/TestingGuide.rst
@@ -598,3 +598,10 @@
For more information on the ``test-suite`` Makefile setup, please see
the :doc:`Test Suite Makefile Guide <TestSuiteMakefileGuide>`.
+
+Capturing Diagnostic Information
+--------------------------------
+
+The compiler may crash while running a test. In this situation, it may emit
+useful diagnostic information in the system temp directory. To specify an
+alternate temp directory, set the ``LLVM_TEMP_DIR`` environment variable.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12869.34767.patch
Type: text/x-patch
Size: 1812 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150915/749da0d0/attachment.bin>
More information about the llvm-commits
mailing list