When using MacPorts GCC on OS X and enlisting the Clang Integrated Assembler via -Wa,-q
, 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).
I found LLVM Commit r250349, Stop generating coal sections. Here's the code responsible, but its not clear to me how to disable the warning.
+ // Issue a warning if the target is not powerpc and Section is a *coal* section.
+ Triple TT = getParser().getContext().getObjectFileInfo()->getTargetTriple();
+ Triple::ArchType ArchTy = TT.getArch();
+
+ if (ArchTy != Triple::ppc && ArchTy != Triple::ppc64) {
+ StringRef NonCoalSection = StringSwitch<StringRef>(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));
+ }
+ }
+
I can't redirect 2 > /dev/null
because the configuration is a bit fragile at the moment, and it discards other warnings and errors.
How do I disable the Clang assembler warning on coal sections?
When the GCC compiler encounters -Wa,-q
, it uses /opt/local/bin/clang
as the assembler rather than /opt/local/bin/as
. Here are the relevant versions.
$ /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
Adding -Wno-deprecated
to CXXFLAGS
does not suppress the warning. I also tried -fno-tree-coalesce-vars
with no joy (which may hurt performance).
And the following sed
does not match on OS X using sed
or gsed
:
$ CXXFLAGS="-DNDEBUG -g2 -O2" make CXX=/opt/local/bin/g++-mp-6 2>&1 | \
gsed -e '/(__TEXT|__DATA)/,+2d'
/opt/local/bin/g++-mp-6 -DNDEBUG -g2 -O2 -fPIC -march=native -Wa,-q -pipe -c rijndael.cpp
<stdin>:3:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
<stdin>:3:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
...
/opt/local/bin/g++-mp-6 -DNDEBUG -g2 -O2 -fPIC -march=native -Wa,-q -DMACPORTS_GCC_COMPILER=1 -c cryptlib.cpp
<stdin>:3:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
<stdin>:3:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
<stdin>:2665:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
<stdin>:2665:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
<stdin>:3925:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
<stdin>:3925:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
<stdin>:3963:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
<stdin>:3963:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
[Hundred of these ommitted for each source file]
Here are the relevant GCC and LLVM bug reports:
To prevent changes in behavior when trimming applications, the .NET SDK provides static analysis of trim compatibility through "trim warnings." Trim warnings are produced by the trimmer when it finds code that may not be compatible with trimming.
SuppressMessage and #pragma directives are only present in source so they can't be used to silence warnings from the trimmer. Be very careful when suppressing trim warnings: it's possible that the call may be trim-compatible now, but as you change your code that may change, and you may forget to review all the suppressions.
Now the warning disappears, because the trimmer knows exactly which members to preserve and which types to preserve them on. In general, this is the best way to deal with DynamicallyAccessedMembers warnings: add annotations so the trimmer knows what to preserve.
UnconditionalSuppressMessage is like SuppressMessage but it can be seen by publish and other post-build tools. SuppressMessage and #pragma directives are only present in source so they can't be used to silence warnings from the trimmer.
At present, you cannot disable those warnings. You should probably file a bug report against FSF GCC to have them update their codegen to be more compliant.
You might also want to file a bug report with llvm.org to request that there be a way to silence these warnings or limit the number that are issued so as to not deluge the user.
Apparently there's no way to disable those warnings, but I like your idea of just filtering them out of the build output.
I find sed
to be too tricky to bother with for complicated (e.g. multi-line) match/replace patterns. Here's a simple Python program to filter such warning noise from stderr, without hiding stderr entirely.
#!/usr/bin/python
#
# filter-noisy-assembler-warnings.py
# Author: Stuart Berg
import sys
for line in sys.stdin:
# If line is a 'noisy' warning, don't print it or the following two lines.
if ('warning: section' in line and 'is deprecated' in line
or 'note: change section name to' in line):
next(sys.stdin)
next(sys.stdin)
else:
sys.stderr.write(line)
sys.stderr.flush()
A convenient way to use that program is via bash process substitution, applied only to stderr:
$ make 2> >(python filter-noisy-assembler-warnings.py)
Or with your build command, this ought to do the trick, I think:
$ CXXFLAGS="-DNDEBUG -g2 -O2" make CXX=/opt/local/bin/g++-mp-6 2> >(python filter-noisy-assembler-warnings.py)
That way, stdout
isn't redirected at all, and most of stderr
is written out verbatim, except for those particular annoying warnings.
I was able to fix these warnings by activating an older MacPorts build of cctools, version 895_7.
First, try the easy way: sudo port activate cctools
If you don't see cctools @895_7
in that list, you can check it out and build it:
git clone --single-branch https://github.com/macports/macports-ports.git /tmp/mp
cd /tmp/mp/devel/cctools
git checkout cc1b891e8d22e2ca7563c5e3031de41d4268ec8a
sudo port install +universal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With