Skip to content

Commit

Permalink
Driver/Darwin: Honor --sysroot= when invoking the linker, on Darwin.
Browse files Browse the repository at this point in the history
llvm-svn: 130723
  • Loading branch information
ddunbar committed May 2, 2011
1 parent 969ed3d commit 8438464
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
17 changes: 11 additions & 6 deletions clang/lib/Driver/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2893,12 +2893,17 @@ void darwin::Link::AddLinkArgs(Compilation &C,
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);
Expand Down
18 changes: 18 additions & 0 deletions clang/test/Driver/sysroot.c
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 8438464

Please sign in to comment.