title: Disable assembler warning ".section __TEXT,__textcoal_nt,coalesced,pure_instructions"
body: <p>When using MacPorts GCC on OS X and enlisting the Clang Integrated Assembler via <code>-Wa,-q</code>, the assembler produces a stream of warnings for each file. A sampling of the warnings is shown below (so many of them, the Stack Overflow editor would not allow me to paste the entire stream).</p>
  
  <p>I found <a href="http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151012/305992.html" rel="noreferrer">LLVM Commit r250349, Stop generating <em>coal</em> sections</a>. Here's the code responsible, but its not clear to me how to disable the warning.</p>
  
  
  
  <pre><code>+  // Issue a warning if the target is not powerpc and Section is a *coal* section.
  +  Triple TT = getParser().getContext().getObjectFileInfo()-&gt;getTargetTriple();
  +  Triple::ArchType ArchTy = TT.getArch();
  +
  +  if (ArchTy != Triple::ppc &amp;&amp; ArchTy != Triple::ppc64) {
  +    StringRef NonCoalSection = StringSwitch&lt;StringRef&gt;(Section)
  +                                   .Case("__textcoal_nt", "__text")
  +                                   .Case("__const_coal", "__const")
  +                                   .Case("__datacoal_nt", "__data")
  +                                   .Default(Section);
  +
  +    if (!Section.equals(NonCoalSection)) {
  +      StringRef SectionVal(Loc.getPointer());
  +      size_t B = SectionVal.find(',') + 1, E = SectionVal.find(',', B);
  +      SMLoc BLoc = SMLoc::getFromPointer(SectionVal.data() + B);
  +      SMLoc ELoc = SMLoc::getFromPointer(SectionVal.data() + E);
  +      getParser().Warning(Loc, "section \"" + Section + "\" is deprecated",
  +                          SMRange(BLoc, ELoc));
  +      getParser().Note(Loc, "change section name to \"" + NonCoalSection +
  +                       "\"", SMRange(BLoc, ELoc));
  +    }
  +  }
  +
  </code></pre>
  
  <p>I can't redirect <code>2 &gt; /dev/null</code> because the configuration is a bit fragile at the moment, and it discards other warnings and errors.</p>
  
  <p>How do I disable the Clang assembler warning on <em>coal sections</em>?</p>
  
  <hr>
  
  <p>When the GCC compiler encounters <code>-Wa,-q</code>, it uses <code>/opt/local/bin/clang</code> as the assembler rather than <code>/opt/local/bin/as</code>. Here are the relevant versions.</p>
  
  
  
  <pre><code>$ /opt/local/bin/g++-mp-6 --version
  g++-mp-6 (MacPorts gcc6 6.1.0_0) 6.1.0
  Copyright (C) 2016 Free Software Foundation, Inc.
  
  $ /opt/local/bin/clang --version
  clang version 3.8.0 (branches/release_38 262722)
  Target: x86_64-apple-darwin12.6.0
  
  $ /opt/local/bin/as -version
  Apple Inc version cctools-877.8, GNU assembler version 1.38
  </code></pre>
  
  <hr>
  
  <p>Adding <code>-Wno-deprecated</code> to <code>CXXFLAGS</code> does not suppress the warning. I also tried <code>-fno-tree-coalesce-vars</code> with no joy (which may hurt performance).</p>
  
  <p>And the following <code>sed</code> does not match on OS X using <code>sed</code> or <code>gsed</code>:</p>
  
  
  
  <pre><code>$ CXXFLAGS="-DNDEBUG -g2 -O2" make CXX=/opt/local/bin/g++-mp-6 2&gt;&amp;1 | \
    gsed -e '/(__TEXT|__DATA)/,+2d'
  /opt/local/bin/g++-mp-6 -DNDEBUG -g2 -O2 -fPIC -march=native -Wa,-q -pipe -c rijndael.cpp
  &lt;stdin&gt;:3:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  &lt;stdin&gt;:3:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  ...
  </code></pre>
  
  <hr>
  
  
  
  <pre><code>/opt/local/bin/g++-mp-6 -DNDEBUG -g2 -O2 -fPIC -march=native -Wa,-q -DMACPORTS_GCC_COMPILER=1 -c cryptlib.cpp
  &lt;stdin&gt;:3:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  &lt;stdin&gt;:3:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  &lt;stdin&gt;:2665:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  &lt;stdin&gt;:2665:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  &lt;stdin&gt;:3925:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  &lt;stdin&gt;:3925:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  &lt;stdin&gt;:3963:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  &lt;stdin&gt;:3963:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  
  [Hundred of these ommitted for each source file]
  </code></pre>
  
  <hr>
  
  <p>Here are the relevant GCC and LLVM bug reports:</p>
  
  <ul>
  <li><a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=71767" rel="noreferrer">GCC Issue 71767 - Endless stream of warnings when using GCC with -Wa,-q and Clang Integrated Assembler</a></li>
  <li><a href="http://llvm.org/bugs/show_bug.cgi?id=28427" rel="noreferrer">LLVM Issue 28427 - Endless stream of warnings when using GCC with -Wa,-q and Clang Integrated Assembler</a></li>
  </ul>