clangDriver GetTemporaryPath not correct in windows

hi,

In llvm/tools/clang/lib/Driver/Driver.cpp at line 1113, the statement
llvm::sys::Path P("/tmp/cc"); will create an invalid temporary path in
windows, and there is a "fix me" comment too :slight_smile:

So we just simply replace it by "llvm::sys::Path P =
llvm::sys::Path::GetTemporaryDirectory();", is that right? if so, here
is the patch:

--- C:\DOCUME~1\ether\LOCALS~1\Temp\Driver.cpp-revBASE.svn000.tmp.cpp
+++ F:\llvm\tools\clang\lib\Driver\Driver.cpp
@@ -1107,10 +1107,8 @@
}

std::string Driver::GetTemporaryPath(const char *Suffix) const {
- // FIXME: This is lame; sys::Path should provide this function (in
- // particular, it should know how to find the temporary files dir).
   std::string Error;
- llvm::sys::Path P("/tmp/cc");
+ llvm::sys::Path P = llvm::sys::Path::GetTemporaryDirectory();
   if (P.makeUnique(false, &Error)) {
     Diag(clang::diag::err_drv_unable_to_make_temp) << Error;
     return "";

by the way, there is another error occur while executing clang with
the message ": error: unable to execute command: program not
executable".

i will try to fix it.

Driver.diff (648 Bytes)

Hi Ether,

hi,

In llvm/tools/clang/lib/Driver/Driver.cpp at line 1113, the statement
llvm::sys::Path P("/tmp/cc"); will create an invalid temporary path in
windows, and there is a “fix me” comment too :slight_smile:

So we just simply replace it by “llvm::sys::Path P =
llvm::sys::Path::GetTemporaryDirectory();”, is that right? if so, here
is the patch:

Unfortunately, GetTemporaryDirectory does something rather different (it ends up creating a temporary directory, not just returning the place to put temporary files). The llvm::sys::Path interface needs some serious surgery in my opinion…

I committed a fix to at least use the TMPDIR environment variable. If I recall correctly, Windows uses something else (TEMP?) but may define this as well? Please let me know if:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20090420/015926.html
does or does not fix it for you.

by the way, there is another error occur while executing clang with
the message “: error: unable to execute command: program not
executable”.

This is probably because it isn’t finding the executable in your path, or its built in search locations. You can look at the output of “clang … other args … -###” to see the command it is trying to run, and the output of “clang -print-search-dirs” to see where it is looking for programs.

  • Daniel

Hi,

I committed a fix to at least use the TMPDIR environment variable. If I recall correctly, Windows uses something else (TEMP?) but may define this as well? Please let me know if:
  http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20090420/015926.html
does or does not fix it for you.

on my system (vista x64), two environments variable point to the temporary dir: TEMP and TMP but not TMPDIR

Thanks, I added TEMP as well:

http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20090420/015935.html

  • Daniel