<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">This change breaks darwin fat binary support.<div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: 'Andale Mono'; color: rgb(56, 193, 255); background-color: rgb(0, 0, 0);" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #29f914" class="">> </span><span style="font-variant-ligatures: no-common-ligatures; color: #457bf9" class="">./bin/clang++</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">~</span>/dev/scratch/hello_world.cpp<span style="font-variant-ligatures: no-common-ligatures; color: #29f914" class=""> </span>-arch<span style="font-variant-ligatures: no-common-ligatures; color: #29f914" class=""> </span>armv7<span style="font-variant-ligatures: no-common-ligatures; color: #29f914" class=""> </span>-arch<span style="font-variant-ligatures: no-common-ligatures; color: #29f914" class=""> </span>armv7s<span style="font-variant-ligatures: no-common-ligatures; color: #29f914" class=""> </span>-isysroot<span style="font-variant-ligatures: no-common-ligatures; color: #29f914" class=""> </span>/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/</div><div style="margin: 0px; line-height: normal; color: rgb(41, 249, 20);" class="">fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: /var/folders/pb/95pc7qfx2xl9kr9kg0gg_9cc0000gn/T/hello_world-1b17ac.out and /var/folders/pb/95pc7qfx2xl9kr9kg0gg_9cc0000gn/T/hello_world-1b17ac.out have the same architectures (armv7) and can't be in the same fat output file</div><div style="margin: 0px; line-height: normal; color: rgb(41, 249, 20);" class="">clang-3.9: error: lipo command failed with exit code 1 (use -v to see invocation)</div></div><div class=""><br class=""></div><div class="">Can someone more familiar with this code please take a look?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">-Chris</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 14, 2016, at 1:41 PM, Justin Lebar via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Author: jlebar<br class="">Date: Thu Jan 14 15:41:21 2016<br class="">New Revision: 257808<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=257808&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=257808&view=rev</a><br class="">Log:<br class="">Don't build jobs for the same Action + ToolChain twice.<br class=""><br class="">Summary:<br class="">Right now if the Action graph is a DAG and we encounter an action twice,<br class="">we will run it twice.<br class=""><br class="">This patch is difficult to test as-is, but I have testcases for this as<br class="">used within CUDA compilation.<br class=""><br class="">Reviewers:<br class=""><br class="">Subscribers:<br class=""><br class="">Modified:<br class="">    cfe/trunk/include/clang/Driver/Driver.h<br class="">    cfe/trunk/lib/Driver/Driver.cpp<br class=""><br class="">Modified: cfe/trunk/include/clang/Driver/Driver.h<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=257808&r1=257807&r2=257808&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=257808&r1=257807&r2=257808&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/include/clang/Driver/Driver.h (original)<br class="">+++ cfe/trunk/include/clang/Driver/Driver.h Thu Jan 14 15:41:21 2016<br class="">@@ -21,6 +21,7 @@<br class=""> #include "llvm/Support/Path.h" // FIXME: Kill when CompilationInfo lands.<br class=""><br class=""> #include <list><br class="">+#include <map><br class=""> #include <memory><br class=""> #include <set><br class=""> #include <string><br class="">@@ -381,10 +382,13 @@ public:<br class=""><br class="">   /// BuildJobsForAction - Construct the jobs to perform for the<br class="">   /// action \p A and return an InputInfo for the result of running \p A.<br class="">+  /// Will only construct jobs for a given (Action, ToolChain) pair once.<br class="">   InputInfo BuildJobsForAction(Compilation &C, const Action *A,<br class="">                                const ToolChain *TC, const char *BoundArch,<br class="">                                bool AtTopLevel, bool MultipleArchs,<br class="">-                               const char *LinkingOutput) const;<br class="">+                               const char *LinkingOutput,<br class="">+                               std::map<std::pair<const Action *, std::string>,<br class="">+                                        InputInfo> &CachedResults) const;<br class=""><br class="">   /// Returns the default name for linked images (e.g., "a.out").<br class="">   const char *getDefaultImageName() const;<br class="">@@ -441,6 +445,16 @@ private:<br class="">   /// the driver mode.<br class="">   std::pair<unsigned, unsigned> getIncludeExcludeOptionFlagMasks() const;<br class=""><br class="">+  /// Helper used in BuildJobsForAction.  Doesn't use the cache when building<br class="">+  /// jobs specifically for the given action, but will use the cache when<br class="">+  /// building jobs for the Action's inputs.<br class="">+  InputInfo BuildJobsForActionNoCache(<br class="">+      Compilation &C, const Action *A, const ToolChain *TC,<br class="">+      const char *BoundArch, bool AtTopLevel, bool MultipleArchs,<br class="">+      const char *LinkingOutput,<br class="">+      std::map<std::pair<const Action *, std::string>, InputInfo><br class="">+          &CachedResults) const;<br class="">+<br class=""> public:<br class="">   /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and<br class="">   /// return the grouped values as integers. Numbers which are not<br class=""><br class="">Modified: cfe/trunk/lib/Driver/Driver.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=257808&r1=257807&r2=257808&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=257808&r1=257807&r2=257808&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Driver/Driver.cpp (original)<br class="">+++ cfe/trunk/lib/Driver/Driver.cpp Thu Jan 14 15:41:21 2016<br class="">@@ -1632,6 +1632,8 @@ void Driver::BuildJobs(Compilation &C) c<br class="">       if (A->getOption().matches(options::OPT_arch))<br class="">         ArchNames.insert(A->getValue());<br class=""><br class="">+  // Set of (Action, canonical ToolChain triple) pairs we've built jobs for.<br class="">+  std::map<std::pair<const Action *, std::string>, InputInfo> CachedResults;<br class="">   for (Action *A : C.getActions()) {<br class="">     // If we are linking an image for multiple archs then the linker wants<br class="">     // -arch_multiple and -final_output <final image name>. Unfortunately, this<br class="">@@ -1651,7 +1653,7 @@ void Driver::BuildJobs(Compilation &C) c<br class="">                        /*BoundArch*/ nullptr,<br class="">                        /*AtTopLevel*/ true,<br class="">                        /*MultipleArchs*/ ArchNames.size() > 1,<br class="">-                       /*LinkingOutput*/ LinkingOutput);<br class="">+                       /*LinkingOutput*/ LinkingOutput, CachedResults);<br class="">   }<br class=""><br class="">   // If the user passed -Qunused-arguments or there were errors, don't warn<br class="">@@ -1779,19 +1781,38 @@ static const Tool *selectToolForJob(Comp<br class="">   return ToolForJob;<br class=""> }<br class=""><br class="">-InputInfo Driver::BuildJobsForAction(Compilation &C, const Action *A,<br class="">-                                     const ToolChain *TC, const char *BoundArch,<br class="">-                                     bool AtTopLevel, bool MultipleArchs,<br class="">-                                     const char *LinkingOutput) const {<br class="">+InputInfo Driver::BuildJobsForAction(<br class="">+    Compilation &C, const Action *A, const ToolChain *TC, const char *BoundArch,<br class="">+    bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,<br class="">+    std::map<std::pair<const Action *, std::string>, InputInfo> &CachedResults)<br class="">+    const {<br class="">+  std::pair<const Action *, std::string> ActionTC = {<br class="">+      A, TC->getTriple().normalize()};<br class="">+  auto CachedResult = CachedResults.find(ActionTC);<br class="">+  if (CachedResult != CachedResults.end()) {<br class="">+    return CachedResult->second;<br class="">+  }<br class="">+  InputInfo Result =<br class="">+      BuildJobsForActionNoCache(C, A, TC, BoundArch, AtTopLevel, MultipleArchs,<br class="">+                                LinkingOutput, CachedResults);<br class="">+  CachedResults[ActionTC] = Result;<br class="">+  return Result;<br class="">+}<br class="">+<br class="">+InputInfo Driver::BuildJobsForActionNoCache(<br class="">+    Compilation &C, const Action *A, const ToolChain *TC, const char *BoundArch,<br class="">+    bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,<br class="">+    std::map<std::pair<const Action *, std::string>, InputInfo> &CachedResults)<br class="">+    const {<br class="">   llvm::PrettyStackTraceString CrashInfo("Building compilation jobs");<br class=""><br class="">   InputInfoList CudaDeviceInputInfos;<br class="">   if (const CudaHostAction *CHA = dyn_cast<CudaHostAction>(A)) {<br class="">     // Append outputs of device jobs to the input list.<br class="">     for (const Action *DA : CHA->getDeviceActions()) {<br class="">-      CudaDeviceInputInfos.push_back(<br class="">-          BuildJobsForAction(C, DA, TC, nullptr, AtTopLevel,<br class="">-                             /*MultipleArchs*/ false, LinkingOutput));<br class="">+      CudaDeviceInputInfos.push_back(BuildJobsForAction(<br class="">+          C, DA, TC, nullptr, AtTopLevel,<br class="">+          /*MultipleArchs*/ false, LinkingOutput, CachedResults));<br class="">     }<br class="">     // Override current action with a real host compile action and continue<br class="">     // processing it.<br class="">@@ -1822,7 +1843,7 @@ InputInfo Driver::BuildJobsForAction(Com<br class="">       TC = &C.getDefaultToolChain();<br class=""><br class="">     return BuildJobsForAction(C, *BAA->begin(), TC, ArchName, AtTopLevel,<br class="">-                              MultipleArchs, LinkingOutput);<br class="">+                              MultipleArchs, LinkingOutput, CachedResults);<br class="">   }<br class=""><br class="">   if (const CudaDeviceAction *CDA = dyn_cast<CudaDeviceAction>(A)) {<br class="">@@ -1831,7 +1852,8 @@ InputInfo Driver::BuildJobsForAction(Com<br class="">     assert(CDA->getGpuArchName() && "No GPU name in device action.");<br class="">     return BuildJobsForAction(C, *CDA->begin(), C.getCudaDeviceToolChain(),<br class="">                               CDA->getGpuArchName(), CDA->isAtTopLevel(),<br class="">-                              /*MultipleArchs*/ true, LinkingOutput);<br class="">+                              /*MultipleArchs*/ true, LinkingOutput,<br class="">+                              CachedResults);<br class="">   }<br class=""><br class="">   const ActionList *Inputs = &A->getInputs();<br class="">@@ -1847,9 +1869,9 @@ InputInfo Driver::BuildJobsForAction(Com<br class="">   // need to build jobs for device-side inputs it may have held.<br class="">   if (CollapsedCHA) {<br class="">     for (const Action *DA : CollapsedCHA->getDeviceActions()) {<br class="">-      CudaDeviceInputInfos.push_back(<br class="">-          BuildJobsForAction(C, DA, TC, "", AtTopLevel,<br class="">-                             /*MultipleArchs*/ false, LinkingOutput));<br class="">+      CudaDeviceInputInfos.push_back(BuildJobsForAction(<br class="">+          C, DA, TC, "", AtTopLevel,<br class="">+          /*MultipleArchs*/ false, LinkingOutput, CachedResults));<br class="">     }<br class="">   }<br class=""><br class="">@@ -1863,7 +1885,7 @@ InputInfo Driver::BuildJobsForAction(Com<br class="">         AtTopLevel && (isa<DsymutilJobAction>(A) || isa<VerifyJobAction>(A));<br class="">     InputInfos.push_back(BuildJobsForAction(C, Input, TC, BoundArch,<br class="">                                             SubJobAtTopLevel, MultipleArchs,<br class="">-                                            LinkingOutput));<br class="">+                                            LinkingOutput, CachedResults));<br class="">   }<br class=""><br class="">   // Always use the first input as the base input.<br class=""><br class=""><br class="">_______________________________________________<br class="">cfe-commits mailing list<br class=""><a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits<br class=""></div></div></blockquote></div><br class=""></div></div></body></html>