2016-07-04 10 views
7

MacPorts GCCをOS Xで使用し、-Wa,-q経由でClang統合アセンブラを登録すると、アセンブラは各ファイルの警告ストリームを生成します。下に警告のサンプルが表示されています(そのため、Stack Overflowエディタでストリーム全体を貼り付けることはできません)。アセンブラ警告を無効にする ".section __TEXT、__ textcoal_nt、coalesced、pure_instructions"

LLVM Commit r250349, Stop generating coal sectionsが見つかりました。責任コードはありますが、その警告を無効にする方法がわかりません。

+ // 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)); 
+ } 
+ } 
+ 

構成は、現時点では少し脆弱であり、それは他の警告やエラーを廃棄するので、私は2 > /dev/nullをリダイレクトすることができません。

石炭セクションのでClangアセンブラの警告を無効にするにはどうすればよいですか?


GCCコンパイラは-Wa,-qに遭遇すると、それはアセンブラではなく/opt/local/bin/asとして/opt/local/bin/clang使用しています。関連するバージョンがあります。

$ /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 

CXXFLAGS-Wno-deprecatedを追加すると、警告を抑制しません。私も喜んで(パフォーマンスを傷つけるかもしれない)-fno-tree-coalesce-varsを試しました。

そして次sedsedまたはgsedを使用してOS X上で一致していません。ここで

$ 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] 

は、関連するGCCやLLVMバグレポートは以下のとおりです。

現在

答えて

8

、あなたはそれらの警告を無効にすることはできません。おそらくFSF GCCに対してバグレポートを提出して、コードジェンをより遵守するように更新するべきです。

また、llvm.orgにバグレポートを提出して、これらの警告を消す方法や、ユーザーに洪水を与えないように番号を制限する方法があるようにすることもできます。

+1

答えは私が聞きたかったが、とにかくありがとう。 – jww

+1

ありがとうジェレミー。バグレポートが質問に追加されました。また、 '-g2 -O2'を省略すると、問題はなくなります。しかし、記号なしで最適化されていないプログラムを持つことはあまり役に立ちません。 – jww

2

どうやらこれらの警告を無効にする方法はありませんが、ビルド出力からフィルタリングするというあなたの考えが好きです。

複雑な(たとえば複数行の)マッチ/置換パターンでは、あまりにも扱いにくいと感じます。ここでは、stderrを完全に隠すことなく、stderrからそのような警告ノイズをフィルタリングする簡単なPythonプログラムを紹介します。そのプログラムを使用する

#!/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() 

便利な方法は、bashのプロセスを置換経由で、stderrにのみ適用:

$ make 2> >(python filter-noisy-assembler-warnings.py) 

またはあなたのビルドコマンドで、これはトリックを行うべきだと思います:

$ CXXFLAGS="-DNDEBUG -g2 -O2" make CXX=/opt/local/bin/g++-mp-6 2> >(python filter-noisy-assembler-warnings.py) 

その方法、stdoutはまったくリダイレ​​クトされていない、とstderrのほとんどは、これらの特定の迷惑な警告を除き、そのまま書き出されます。

関連する問題