<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">For the record, this commit has caused the gdb.base/fullname.exp test to unexpectedly pass two of the xfailed tests.<div>The xfail was removed in r180640.<div> <br><div><div>On Apr 26, 2013, at 1:49 PM, Chad Rosier <<a href="mailto:mcrosier@apple.com">mcrosier@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Author: mcrosier<br>Date: Fri Apr 26 15:49:50 2013<br>New Revision: 180628<br><br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=180628&view=rev">http://llvm.org/viewvc/llvm-project?rev=180628&view=rev</a><br>Log:<br>[driver] Implement the -fdebug-compilation-dir in a way that is compatible with<br>gcc.  No test case included as I'm having problems finding a test case where<br>the inode/dev don't match.<br><br>Modified:<br>   cfe/trunk/lib/Driver/Tools.cpp<br>   cfe/trunk/test/Driver/debug-comp-dir.S<br>   cfe/trunk/test/Driver/debug.c<br><br>Modified: cfe/trunk/lib/Driver/Tools.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=180628&r1=180627&r2=180628&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=180628&r1=180627&r2=180628&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/Driver/Tools.cpp (original)<br>+++ cfe/trunk/lib/Driver/Tools.cpp Fri Apr 26 15:49:50 2013<br>@@ -7,6 +7,9 @@<br>//<br>//===----------------------------------------------------------------------===//<br><br>+#include <sys/param.h><br>+#include <sys/stat.h><br>+#include <unistd.h><br>#include "Tools.h"<br>#include "InputInfo.h"<br>#include "SanitizerArgs.h"<br>@@ -1776,14 +1779,24 @@ static bool shouldUseLeafFramePointer(co<br>/// If the PWD environment variable is set, add a CC1 option to specify the<br>/// debug compilation directory.<br>static void addDebugCompDirArg(const ArgList &Args, ArgStringList &CmdArgs) {<br>-  if (const char *pwd = ::getenv("PWD")) {<br>-    // GCC also verifies that stat(pwd) and stat(".") have the same inode<br>-    // number. Not doing those because stats are slow, but we could.<br>-    if (llvm::sys::path::is_absolute(pwd)) {<br>-      std::string CompDir = pwd;<br>-      CmdArgs.push_back("-fdebug-compilation-dir");<br>-      CmdArgs.push_back(Args.MakeArgString(CompDir));<br>-    }<br>+  struct stat StatPWDBuf, StatDotBuf;<br>+<br>+  const char *pwd;<br>+  if ((pwd = ::getenv("PWD")) != 0 &&<br>+      llvm::sys::path::is_absolute(pwd) &&<br>+      stat(pwd, &StatPWDBuf) == 0 &&<br>+      stat(".", &StatDotBuf) == 0 &&<br>+      StatPWDBuf.st_ino == StatDotBuf.st_ino &&<br>+      StatPWDBuf.st_dev == StatDotBuf.st_dev) {<br>+    CmdArgs.push_back("-fdebug-compilation-dir");<br>+    CmdArgs.push_back(Args.MakeArgString(pwd));<br>+    return;<br>+  }<br>+  // Fall back to using getcwd.<br>+  char cwd[MAXPATHLEN];<br>+  if (pwd && ::getcwd(cwd, MAXPATHLEN)) {<br>+    CmdArgs.push_back("-fdebug-compilation-dir");<br>+    CmdArgs.push_back(Args.MakeArgString(cwd));<br>  }<br>}<br><br><br>Modified: cfe/trunk/test/Driver/debug-comp-dir.S<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-comp-dir.S?rev=180628&r1=180627&r2=180628&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-comp-dir.S?rev=180628&r1=180627&r2=180628&view=diff</a><br>==============================================================================<br>--- cfe/trunk/test/Driver/debug-comp-dir.S (original)<br>+++ cfe/trunk/test/Driver/debug-comp-dir.S Fri Apr 26 15:49:50 2013<br>@@ -1,9 +1,6 @@<br>// RUN: cd %S && %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-PWD %s<br>// CHECK-PWD: {{"-fdebug-compilation-dir" ".*Driver.*"}}<br><br>-// RUN: env PWD=/foo %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-FOO %s<br>-// CHECK-FOO: {{"-fdebug-compilation-dir" ".*foo"}}<br>-<br>// "PWD=/foo gcc" wouldn't necessarily work. You would need to pick a different<br>// path to the same directory (try a symlink).<br><br><br>Modified: cfe/trunk/test/Driver/debug.c<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug.c?rev=180628&r1=180627&r2=180628&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug.c?rev=180628&r1=180627&r2=180628&view=diff</a><br>==============================================================================<br>--- cfe/trunk/test/Driver/debug.c (original)<br>+++ cfe/trunk/test/Driver/debug.c Fri Apr 26 15:49:50 2013<br>@@ -1,9 +1,6 @@<br>// RUN: cd %S && %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-PWD %s<br>// CHECK-PWD: {{"-fdebug-compilation-dir" ".*Driver.*"}}<br><br>-// RUN: env PWD=/foo %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-FOO %s<br>-// CHECK-FOO: {{"-fdebug-compilation-dir" ".*foo"}}<br>-<br>// "PWD=/foo gcc" wouldn't necessarily work. You would need to pick a different<br>// path to the same directory (try a symlink).<br><br><br><br>_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a></div></blockquote></div><br></div></div></body></html>