From: Bob Wilson Date: Tue, 15 May 2012 18:57:39 +0000 (+0000) Subject: Do not link with Objective-C libraries with -nostdlib or -nodefaultlibs. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63d9f3cddee40a3f3e5579e9004b31ec8663b5d9;p=clang Do not link with Objective-C libraries with -nostdlib or -nodefaultlibs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156841 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index e3966694ae..bed29abd82 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -4224,7 +4224,9 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA, // This is more complicated in gcc... CmdArgs.push_back("-lgomp"); - if (isObjCRuntimeLinked(Args)) { + if (isObjCRuntimeLinked(Args) && + !Args.hasArg(options::OPT_nostdlib) && + !Args.hasArg(options::OPT_nodefaultlibs)) { // Avoid linking compatibility stubs on i386 mac. if (!getDarwinToolChain().isTargetMacOS() || getDarwinToolChain().getArchName() != "i386") { diff --git a/test/Driver/arclite-link.c b/test/Driver/arclite-link.c index 8a334976f0..ebb0f1afab 100644 --- a/test/Driver/arclite-link.c +++ b/test/Driver/arclite-link.c @@ -2,9 +2,11 @@ // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.8 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s // RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s +// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -nostdlib %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB %s // CHECK-ARCLITE-OSX: libarclite_macosx.a // CHECK-ARCLITE-OSX: -framework // CHECK-ARCLITE-OSX: Foundation // CHECK-ARCLITE-OSX: -lobjc // CHECK-NOARCLITE-NOT: libarclite +// CHECK-NOSTDLIB-NOT: -lobjc