Skip to content

Commit 63404f0

Browse files
committed
Support for storing tmpfile someplace else
1 parent 8240512 commit 63404f0

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

clang/tools/nec-aurora-build/compiler.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int runSourceTransformation(const std::string &InputPath,
4040

4141
// We create an empty temp file
4242
std::string Content = "";
43-
std::string TmpFile = writeTmpFile(Content, InputFileNameWE, InputFileExt);
43+
std::string TmpFile = writeTmpFile(Content, InputFileNameWE + ".sotoc-transformed", InputFileExt);
4444
if (TmpFile == "")
4545
return -1;
4646

@@ -62,10 +62,15 @@ int runTargetCompiler(const std::string &InputPath, const std::string &Args) {
6262
CmdLine << getTargetCompiler() << " -c " << InputPath << " " << Args;
6363

6464
if (Verbose) {
65-
std::cout << " \"" << CmdLine.str() << std::endl;
65+
std::cout << " \"" << CmdLine.str() << "\"" << std::endl;
6666
}
6767

6868
int ret = system(CmdLine.str().c_str());
6969

70+
if (!KeepTransformedFilesDir) {
71+
std::cout << "Removing tmpfil" << std::endl;
72+
std::remove(InputPath.c_str());
73+
}
74+
7075
return ret;
7176
}

clang/tools/nec-aurora-build/necaurora-ofld-wrapper.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828
#include "necaurora-ofld-wrapper.h"
2929

3030
bool Verbose = false;
31+
const char *KeepTransformedFilesDir;
3132
bool SaveTemps = false;
3233

34+
3335
enum class ToolMode {
3436
Unknown,
3537
Compiler,
@@ -95,6 +97,7 @@ int parseCmdline(int argc, char **argv, ToolMode &Mode, std::string &SotocPath,
9597
if (StaticLinkerFlag) {
9698
Mode = ToolMode::StaticLinker;
9799
} else {
100+
Mode = ToolMode::Passthrough;
98101
if (SharedFlag) {
99102
ArgsStream << "-shared";
100103
}
@@ -129,6 +132,8 @@ int main(int argc, char **argv) {
129132
std::string Args;
130133
std::vector<const char *> ObjectFiles;
131134

135+
KeepTransformedFilesDir = std::getenv("NECAURORA_KEEP_FILES_DIR");
136+
132137
rc = parseCmdline(argc, argv, Mode, SotocPath, InputFile, Args, Verbose,
133138
SaveTemps, ObjectFiles);
134139
if (rc != 0) {
@@ -148,7 +153,6 @@ int main(int argc, char **argv) {
148153
}
149154

150155
rc = runTargetCompiler(SotocOutputPath, Args);
151-
std::remove(SotocOutputPath.c_str());
152156

153157
if (rc != 0) {
154158
std::cerr << "necaurora-ofld-wrapper: "

clang/tools/nec-aurora-build/necaurora-ofld-wrapper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
extern bool Verbose;
99

10+
extern const char *KeepTransformedFilesDir;
11+
1012
int runSourceTransformation(const std::string &InputPath,
1113
const std::string &SotocPath,
1214
std::string &OutputPath,

clang/tools/nec-aurora-build/utils.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ const char *getTargetCompiler() {
3636

3737
std::string writeTmpFile(const std::string &Content, const std::string &Prefix,
3838
const std::string &Extension) {
39-
std::string TmpPath = getTmpDir();
39+
std::string TmpPath;
40+
if (KeepTransformedFilesDir) {
41+
TmpPath = KeepTransformedFilesDir;
42+
} else {
43+
TmpPath = getTmpDir();
44+
}
4045

4146
// because mkstemp wants the last n chars to be 'X', we have to add the
4247
// extension laster

0 commit comments

Comments
 (0)