This is an archive of the discontinued LLVM Phabricator instance.

[Support] Add a new environment variable: LLVM_TEMP_DIR
AbandonedPublic

Authored by vsk on Sep 14 2015, 5:57 PM.

Details

Reviewers
steven_wu
Summary

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.

Diff Detail

Event Timeline

vsk updated this revision to Diff 34767.Sep 14 2015, 5:57 PM
vsk retitled this revision from to [Support] Add a new environment variable: LLVM_TEMP_DIR.
vsk updated this object.
vsk added a reviewer: steven_wu.
vsk added a subscriber: llvm-commits.
steven_wu edited edge metadata.Sep 14 2015, 6:17 PM

Can you just use one of the TEMP environmental variable instead? I don't see any difference between your "LLVM_TEMP_DIR" and the temp dir environmental variable defined for Unix or Windows. That is:

// For Unix
const char *EnvironmentVariables[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR"};
// For Windows
const char *EnvironmentVariables[] = {"TMP", "TEMP", "USERPROFILE"};
vsk abandoned this revision.Sep 14 2015, 6:46 PM

Hm, yeah this is a bit kludgy.

FYI, I have introduced $LIT_PRESERVES_TMP for it.

'LIT_PRESERVES_TMP': '1',
'TEMP':   WithProperties("%(workdir)s/tmp/TEMP"),
'TMP':    WithProperties("%(workdir)s/tmp/TMP"),
'TMPDIR': WithProperties("%(workdir)s/tmp/TMPDIR"),
factory.addStep(RemoveDirectory(
        dir=WithProperties("tmp"),
        flunkOnFailure=False))
factory.addStep(MakeDirectory(
        dir="tmp/TEMP",
        flunkOnFailure=False))
factory.addStep(MakeDirectory(
        dir="tmp/TMP",
        flunkOnFailure=False))
factory.addStep(MakeDirectory(
        dir="tmp/TMPDIR",
        flunkOnFailure=False))

My builders are capturing them in every build.

vsk added a comment.Sep 14 2015, 7:48 PM

That seems cleaner.

Steven brought up another objection off-list which I think is worth mentioning here: using an alternate directory for _all_ temp files could drastically slow down our builds, since we're interesting in storing build data on a network share.