[cfe-commits] r167054 - in /cfe/trunk: lib/Driver/Tools.cpp test/Driver/cpath.c test/Driver/linker-opts.c
Chad Rosier
mcrosier at apple.com
Tue Oct 30 14:42:10 PDT 2012
Author: mcrosier
Date: Tue Oct 30 16:42:09 2012
New Revision: 167054
URL: http://llvm.org/viewvc/llvm-project?rev=167054&view=rev
Log:
[driver] Older versions of ld expect '-L<dir>' not '-L <dir>'. In Xcode4 and
later, '-L <dir>' is allowed, but rewrite these in the driver as '-L<dir>' to
maintain backward compatibility. The same is true for the -I option.
rdar://12366753
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cpath.c
cfe/trunk/test/Driver/linker-opts.c
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=167054&r1=167053&r2=167054&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Oct 30 16:42:09 2012
@@ -93,9 +93,15 @@
const char *ArgName,
const char *EnvVar) {
const char *DirList = ::getenv(EnvVar);
+ bool CombinedArg = false;
+
if (!DirList)
return; // Nothing to do.
+ StringRef Name(ArgName);
+ if (Name.equals("-I") || Name.equals("-L"))
+ CombinedArg = true;
+
StringRef Dirs(DirList);
if (Dirs.empty()) // Empty string should not add '.'.
return;
@@ -103,21 +109,37 @@
StringRef::size_type Delim;
while ((Delim = Dirs.find(llvm::sys::PathSeparator)) != StringRef::npos) {
if (Delim == 0) { // Leading colon.
- CmdArgs.push_back(ArgName);
- CmdArgs.push_back(".");
+ if (CombinedArg) {
+ CmdArgs.push_back(Args.MakeArgString(std::string(ArgName) + "."));
+ } else {
+ CmdArgs.push_back(ArgName);
+ CmdArgs.push_back(".");
+ }
} else {
- CmdArgs.push_back(ArgName);
- CmdArgs.push_back(Args.MakeArgString(Dirs.substr(0, Delim)));
+ if (CombinedArg) {
+ CmdArgs.push_back(Args.MakeArgString(std::string(ArgName) + Dirs.substr(0, Delim)));
+ } else {
+ CmdArgs.push_back(ArgName);
+ CmdArgs.push_back(Args.MakeArgString(Dirs.substr(0, Delim)));
+ }
}
Dirs = Dirs.substr(Delim + 1);
}
if (Dirs.empty()) { // Trailing colon.
- CmdArgs.push_back(ArgName);
- CmdArgs.push_back(".");
+ if (CombinedArg) {
+ CmdArgs.push_back(Args.MakeArgString(std::string(ArgName) + "."));
+ } else {
+ CmdArgs.push_back(ArgName);
+ CmdArgs.push_back(".");
+ }
} else { // Add the last path.
- CmdArgs.push_back(ArgName);
- CmdArgs.push_back(Args.MakeArgString(Dirs));
+ if (CombinedArg) {
+ CmdArgs.push_back(Args.MakeArgString(std::string(ArgName) + Dirs));
+ } else {
+ CmdArgs.push_back(ArgName);
+ CmdArgs.push_back(Args.MakeArgString(Dirs));
+ }
}
}
Modified: cfe/trunk/test/Driver/cpath.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cpath.c?rev=167054&r1=167053&r2=167054&view=diff
==============================================================================
--- cfe/trunk/test/Driver/cpath.c (original)
+++ cfe/trunk/test/Driver/cpath.c Tue Oct 30 16:42:09 2012
@@ -1,8 +1,8 @@
// RUN: mkdir -p %T/test1 %T/test2 %T/test3
// RUN: env "CPATH=%T/test1%{pathsep}%T/test2" %clang -x c -E -v %s 2>&1 | FileCheck %s -check-prefix=CPATH
-// CPATH: -I {{.*}}/test1
-// CPATH: -I {{.*}}/test2
+// CPATH: -I{{.*}}/test1
+// CPATH: -I{{.*}}/test2
// CPATH: search starts here
// CPATH: test1
// CPATH: test2
Modified: cfe/trunk/test/Driver/linker-opts.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linker-opts.c?rev=167054&r1=167053&r2=167054&view=diff
==============================================================================
--- cfe/trunk/test/Driver/linker-opts.c (original)
+++ cfe/trunk/test/Driver/linker-opts.c Tue Oct 30 16:42:09 2012
@@ -1,5 +1,5 @@
// RUN: env LIBRARY_PATH=%T/test1 %clang -x c %s -### 2>&1 | FileCheck %s
-// CHECK: "-L" "{{.*}}/test1"
+// CHECK: "-L{{.*}}/test1"
// GCC driver is used as linker on cygming. It should be aware of LIBRARY_PATH.
// XFAIL: cygwin,mingw32,win32
More information about the cfe-commits
mailing list