]> granicus.if.org Git - clang/commitdiff
Driver/Darwin: Add deployment target after doing argument translation, so that
authorDaniel Dunbar <daniel@zuster.org>
Mon, 19 Jul 2010 17:11:36 +0000 (17:11 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 19 Jul 2010 17:11:36 +0000 (17:11 +0000)
-mmacosx-version-min works inside a -Xarch_ flag.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108712 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains.cpp
lib/Driver/ToolChains.h
test/Driver/darwin-cc.c
test/Driver/darwin-debug-flags.c
test/Driver/darwin-xarch.c [new file with mode: 0644]

index dddb1d93c6f502becfe336dbf6e2d4c33ab0c504..1957f248fe9a037e66bef2a461f8b8490b2d99e7 100644 (file)
@@ -415,8 +415,7 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
   }
 }
 
-void Darwin::AddDeploymentTarget(const DerivedArgList &Args,
-                                 DerivedArgList *DAL) const {
+void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
   const OptTable &Opts = getDriver().getOpts();
 
   Arg *OSXVersion = Args.getLastArg(options::OPT_mmacosx_version_min_EQ);
@@ -454,17 +453,17 @@ void Darwin::AddDeploymentTarget(const DerivedArgList &Args,
 
     if (OSXTarget) {
       const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
-      OSXVersion = DAL->MakeJoinedArg(0, O, OSXTarget);
-      DAL->append(OSXVersion);
+      OSXVersion = Args.MakeJoinedArg(0, O, OSXTarget);
+      Args.append(OSXVersion);
     } else if (iPhoneOSTarget) {
       const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ);
-      iPhoneVersion = DAL->MakeJoinedArg(0, O, iPhoneOSTarget);
-      DAL->append(iPhoneVersion);
+      iPhoneVersion = Args.MakeJoinedArg(0, O, iPhoneOSTarget);
+      Args.append(iPhoneVersion);
     } else {
       // Otherwise, assume we are targeting OS X.
       const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
-      OSXVersion = DAL->MakeJoinedArg(0, O, MacosxVersionMin);
-      DAL->append(OSXVersion);
+      OSXVersion = Args.MakeJoinedArg(0, O, MacosxVersionMin);
+      Args.append(OSXVersion);
     }
   }
 
@@ -500,7 +499,6 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args,
   // purpose of easily achieving feature parity & testability. Once we
   // have something that works, we should reevaluate each translation
   // and try to push it down into tool specific logic.
-  AddDeploymentTarget(Args, DAL);
 
   for (ArgList::const_iterator it = Args.begin(),
          ie = Args.end(); it != ie; ++it) {
@@ -679,6 +677,11 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args,
       llvm_unreachable("invalid Darwin arch");
   }
 
+  // Add an explicit version min argument for the deployment target. We do this
+  // after argument translation because -Xarch_ arguments may add a version min
+  // argument.
+  AddDeploymentTarget(*DAL);
+
   return DAL;
 }
 
index a933553f46b56eb6f8d7ee4c67d18e7353b4c5ac..2be88f10bf019d5d6b37dff07dfe9b7bca067829 100644 (file)
@@ -62,8 +62,7 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public ToolChain {
   std::string MacosxVersionMin;
 
 private:
-  void AddDeploymentTarget(const DerivedArgList &Args,
-                           DerivedArgList *DAL) const;
+  void AddDeploymentTarget(DerivedArgList &Args) const;
 
 public:
   Darwin(const HostInfo &Host, const llvm::Triple& Triple,
index 3cb9df6ceac6bea1c9fe0999b0ef967d52c5e455..b068bb4e3fd4954a9967acefffdca524edaa6f53 100644 (file)
@@ -1,5 +1,5 @@
 // RUN: %clang -ccc-no-clang -ccc-host-triple i386-apple-darwin10 -m32 -### -MD -g -fast -Q -dA -mkernel -ansi -aFOO -S -o /tmp/OUTPUTNAME -g0 -gfull -O2 -Werror -pedantic -Wmost -w -std=c99 -trigraphs -v -pg -fFOO -undef -Qn --param a=b -fmudflap -coverage -save-temps -nostdinc -I ARG0 -F ARG1 -I ARG2 -P -MF ARG3 -MG -MP -remap -g3 -H -D ARG4 -U ARG5 -A ARG6 -D ARG7 -U ARG8 -A ARG9 -include ARG10 -pthread %s 2> %t.log
-// RUN: grep ' ".*cc1" "-E" "-nostdinc" "-v" "-I" "ARG0" "-FARG1" "-I" "ARG2" "-P" "-MD" "/tmp/OUTPUTNAME.d" "-MF" "ARG3" "-MG" "-MP" "-MQ" "/tmp/OUTPUTNAME" "-remap" "-dD" "-H" "-D__STATIC__" "-D_REENTRANT" "-D" "ARG4" "-U" "ARG5" "-A" "ARG6" "-D" "ARG7" "-U" "ARG8" "-A" "ARG9" "-include" "ARG10" ".*darwin-cc.c" "-D_MUDFLAP" "-include" "mf-runtime.h" "-mmacosx-version-min=10.6.0" "-m32" "-mkernel" "-mtune=core2" "-ansi" "-std=c99" "-trigraphs" "-Werror" "-pedantic" "-Wmost" "-w" "-fast" "-fno-eliminate-unused-debug-symbols" "-fFOO" "-fmudflap" "-O2" "-undef" "-fpch-preprocess" "-o" ".*darwin-cc.i"' %t.log
-// RUN: grep ' ".*cc1" "-fpreprocessed" ".*darwin-cc.i" "-O3" "-dumpbase" ".*darwin-cc.c" "-dA" "-mmacosx-version-min=10.6.0" "-m32" "-mkernel" "-mtune=core2" "-ansi" "-aFOO" "-auxbase-strip" "/tmp/OUTPUTNAME" "-g" "-g0" "-g" "-g3" "-O2" "-Werror" "-pedantic" "-Wmost" "-w" "-ansi" "-std=c99" "-trigraphs" "-version" "-p" "-fast" "-fno-eliminate-unused-debug-symbols" "-fFOO" "-fmudflap" "-undef" "-fno-ident" "-o" "/tmp/OUTPUTNAME" "--param" "a=b" "-fno-builtin" "-fno-merge-constants" "-fprofile-arcs" "-ftest-coverage"' %t.log
+// RUN: grep ' ".*cc1" "-E" "-nostdinc" "-v" "-I" "ARG0" "-FARG1" "-I" "ARG2" "-P" "-MD" "/tmp/OUTPUTNAME.d" "-MF" "ARG3" "-MG" "-MP" "-MQ" "/tmp/OUTPUTNAME" "-remap" "-dD" "-H" "-D__STATIC__" "-D_REENTRANT" "-D" "ARG4" "-U" "ARG5" "-A" "ARG6" "-D" "ARG7" "-U" "ARG8" "-A" "ARG9" "-include" "ARG10" ".*darwin-cc.c" "-D_MUDFLAP" "-include" "mf-runtime.h" "-m32" "-mkernel" "-mtune=core2" "-mmacosx-version-min=10.6.0" "-ansi" "-std=c99" "-trigraphs" "-Werror" "-pedantic" "-Wmost" "-w" "-fast" "-fno-eliminate-unused-debug-symbols" "-fFOO" "-fmudflap" "-O2" "-undef" "-fpch-preprocess" "-o" ".*darwin-cc.i"' %t.log
+// RUN: grep ' ".*cc1" "-fpreprocessed" ".*darwin-cc.i" "-O3" "-dumpbase" ".*darwin-cc.c" "-dA" "-m32" "-mkernel" "-mtune=core2" "-mmacosx-version-min=10.6.0" "-ansi" "-aFOO" "-auxbase-strip" "/tmp/OUTPUTNAME" "-g" "-g0" "-g" "-g3" "-O2" "-Werror" "-pedantic" "-Wmost" "-w" "-ansi" "-std=c99" "-trigraphs" "-version" "-p" "-fast" "-fno-eliminate-unused-debug-symbols" "-fFOO" "-fmudflap" "-undef" "-fno-ident" "-o" "/tmp/OUTPUTNAME" "--param" "a=b" "-fno-builtin" "-fno-merge-constants" "-fprofile-arcs" "-ftest-coverage"' %t.log
 
 
index 6f245271d582563d4dc997f47a4053071d6b65da..3394e4e8079cfcbe195b8cfb1779b535ac89a67d 100644 (file)
@@ -2,8 +2,8 @@
 // <rdar://problem/7256886>
 
 // CHECK: !1 = metadata !{
-// CHECK: -mmacosx-version-min=10.5.0
 // CHECK: -g -Os
+// CHECK: -mmacosx-version-min=10.5.0
 // CHECK: [ DW_TAG_compile_unit ]
 
 int x;
diff --git a/test/Driver/darwin-xarch.c b/test/Driver/darwin-xarch.c
new file mode 100644 (file)
index 0000000..cee8ce5
--- /dev/null
@@ -0,0 +1,8 @@
+// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### \
+// RUN:   -arch i386 -Xarch_i386 -mmacosx-version-min=10.4 \
+// RUN:   -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 \
+// RUN:   -c %s 2> %t
+// RUN: FileCheck < %t %s
+//
+// CHECK: clang" "-cc1" "-triple" "i386-apple-darwin8.0.0" 
+// CHECK: clang" "-cc1" "-triple" "x86_64-apple-darwin9.0.0"