[cfe-commits] r130723 - in /cfe/trunk: lib/Driver/Tools.cpp test/Driver/sysroot.c
Daniel Dunbar
daniel at zuster.org
Mon May 2 14:03:47 PDT 2011
Author: ddunbar
Date: Mon May 2 16:03:47 2011
New Revision: 130723
URL: http://llvm.org/viewvc/llvm-project?rev=130723&view=rev
Log:
Driver/Darwin: Honor --sysroot= when invoking the linker, on Darwin.
Added:
cfe/trunk/test/Driver/sysroot.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=130723&r1=130722&r2=130723&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon May 2 16:03:47 2011
@@ -2893,12 +2893,17 @@
Args.AddAllArgs(CmdArgs, options::OPT_sub__library);
Args.AddAllArgs(CmdArgs, options::OPT_sub__umbrella);
- Args.AddAllArgsTranslated(CmdArgs, options::OPT_isysroot, "-syslibroot");
- if (getDarwinToolChain().isTargetIPhoneOS()) {
- if (!Args.hasArg(options::OPT_isysroot)) {
- CmdArgs.push_back("-syslibroot");
- CmdArgs.push_back("/Developer/SDKs/Extra");
- }
+ // Give --sysroot= preference, over the Apple specific behavior to also use
+ // --isysroot as the syslibroot.
+ if (const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ)) {
+ CmdArgs.push_back("-syslibroot");
+ CmdArgs.push_back(A->getValue(Args));
+ } else if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
+ CmdArgs.push_back("-syslibroot");
+ CmdArgs.push_back(A->getValue(Args));
+ } else if (getDarwinToolChain().isTargetIPhoneOS()) {
+ CmdArgs.push_back("-syslibroot");
+ CmdArgs.push_back("/Developer/SDKs/Extra");
}
Args.AddLastArg(CmdArgs, options::OPT_twolevel__namespace);
Added: cfe/trunk/test/Driver/sysroot.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sysroot.c?rev=130723&view=auto
==============================================================================
--- cfe/trunk/test/Driver/sysroot.c (added)
+++ cfe/trunk/test/Driver/sysroot.c Mon May 2 16:03:47 2011
@@ -0,0 +1,18 @@
+// Check that --sysroot= also applies to header search paths.
+// RUN: %clang -ccc-host-triple unknown --sysroot=/FOO -### -E %s 2> %t1
+// RUN: FileCheck --check-prefix=CHECK-SYSROOTEQ < %t1 %s
+// CHECK-SYSROOTEQ: "-cc1"{{.*}} "-isysroot" "/FOO"
+
+// Apple Darwin uses -isysroot as the syslib root, too.
+// RUN: touch %t2.o
+// RUN: %clang -ccc-host-triple i386-apple-darwin10 \
+// RUN: -isysroot /FOO -### %t2.o 2> %t2
+// RUN: FileCheck --check-prefix=CHECK-APPLE-ISYSROOT < %t2 %s
+// CHECK-APPLE-ISYSROOT: "-arch" "i386"{{.*}} "-syslibroot" "/FOO"
+
+// Check that honor --sysroot= over -isysroot, for Apple Darwin.
+// RUN: touch %t3.o
+// RUN: %clang -ccc-host-triple i386-apple-darwin10 \
+// RUN: -isysroot /FOO --sysroot=/BAR -### %t3.o 2> %t3
+// RUN: FileCheck --check-prefix=CHECK-APPLE-SYSROOT < %t3 %s
+// CHECK-APPLE-SYSROOT: "-arch" "i386"{{.*}} "-syslibroot" "/BAR"
More information about the cfe-commits
mailing list