Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vs2017が変な警告(D9025)を出してる件について語る #24

Open
berryzplus opened this issue Aug 5, 2018 · 3 comments
Open

Comments

@berryzplus
Copy link

issueの目的

vs2017が変な警告を出すようになった。
このまま見て見ぬふりをするか、対策を考えるか・・・。

実はすでに考えているんですけど、
どうも visual studio(というかMSBuildのCPPTask)のバグっぽくて、
ひとりで考えてても仕方ないかな~というわけで、
問題の内容、原因、調べたことを共有することにしました。

問題の内容

sakura-editorのビルド時に変な警告が出ます。

cl : Command line warning D9025: overriding '/FAs' with '/FAu'

D9025は、同時に指定できないオプションを指定した時に出る警告のようです。
https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/command-line-warning-d9025

警告が出始めたのはアセンブラ出力をutf-8にする対応のあとです。
sakura-editor/sakura#286 (comment)

おまえのせいかいっ!ってツッコミは後にしてください 😢

問題の原因

アセンブラ出力のオプションには色んなものがあります。
https://msdn.microsoft.com/en-us/library/367y26c6.aspx

オプション 意味
/FAc アセンブラをマシン語(HEX)で出力します。
/FAs アセンブラをマシン語で出力します。
/FAu アセンブラをutf-8で出力します。

これらのオプションは組み合わせが可能です。
たとえば、 /FAsu だとマシン語をutf8で出力します。

今回の場合、/FAs と /FAu の2つのオプションが生成されているっぽいです。
オプション指定を結合して /FAsu を生成してくれていたら問題にならないはずだから。

調べたこと

visual studio のビルドシステムは、裏側では MSBuild というもので構成されています。
MSBuild は ant や maven に近いもので、C++だけでなくC#のビルドにも使われます。

C:\Program Files (x86)\MSBuild に実体があるので、
この配下を調べたいキーワードでGrepすると大抵のビルドトラブルは解決することが多いです。

今回調べて分かったことは・・・

□検索条件  "UseUnicodeForAssemblerListing"
検索対象   *
フォルダ   C:\Program Files (x86)\MSBuild
    (サブフォルダも検索)
    (単語単位で探す)
    (英大文字小文字を区別しない)
    (文字コードセットの自動判別)
    (一致した行を出力)
    (ファイル毎最初のみ検索)


C:\Program Files (x86)\MSBuild\14.0\Bin\amd64\MSBuild\Microsoft.Build.Commontypes.xsd(240,31)  [UTF-8]:             <xs:element name="UseUnicodeForAssemblerListing" />
C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild\Microsoft.Build.Commontypes.xsd(240,31)  [UTF-8]:             <xs:element name="UseUnicodeForAssemblerListing" />
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(224,10)  [UTF-8]:         <UseUnicodeForAssemblerListing Condition="'%(ClCompile.AssemblerOutput)' == 'NoListing' or '%(ClCompile.AssemblerOutput)' == ''"></UseUnicodeForAssemblerListing>
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\1041\cl.xml(265,23)  [UTF-8]:   <BoolProperty Name="UseUnicodeForAssemblerListing" DisplayName="アセンブラー リストに Unicode を使用する" Description="出力ファイルが UTF-8 形式で作成されます。" Category="Output Files" Switch="FAu" F1Keyword="VC.Project.VCCLCompilerTool.UseUnicodeForAssemblerListing">
4 個が検索されました。
  1. UseUnicodeForAssemblerListingBoolPropertyである
  2. UseUnicodeForAssemblerListingには固定のSwitch FAu が割り当てられている
  3. 宣言以外に一致がないことから、このプロパティはDLLの中で使われる

さらっとググった感じ、まったく同じ現象で困ってる人が結構前からいたらしいことも分かっています。
http://xanthelasma3.rssing.com/chan-3507589/all_p548.html

まとめ

処理的にこんな感じだと思うんですが、違う実装になってそうなんです。
この部分を実装してあるのは MSBuildのCPPTasks.dllなはずなので、
つまりはそこのバグっぽい気がしています。

  var optSelection = 'AssemblyAndSourceCode';
  var optFAu = true;
  var optFA = '';
  var optFAs = {
     "AssemblyCode": "FA",
     "AssemblyAndMachineCode": "FAc",
     "AssemblyAndSourceCode": "FAs",
     "All": "FAcs",
  };
  if (optSelection) {
    optFA = optFAs[optSelection] + optFAu ? 'u' : '';
  }

途中からjavascriptで書き始めたの後悔したっていうアレですね・・・。
(定義をJSONで書きたかっただけなの。)

で、どうするのが一番現実的か、というところに戻ってくるわけですが、
とりあえずは「見なかったことにする」というのが得策なのかなと思っています。

@m-tmatma
Copy link
Member

m-tmatma commented Aug 8, 2018

答え見つけました。

https://docs.microsoft.com/en-us/cpp/build/reference/fa-fa-listing-file

Note that setting both Assembler Output and Use Unicode For Assembler Listing properties can cause Command-Line Warning D9025. To combine these options in the IDE, use the Additional Options field in the Command Line property page instead.

@m-tmatma
Copy link
Member

m-tmatma commented Aug 8, 2018

答え見つけました。

https://docs.microsoft.com/en-us/cpp/build/reference/fa-fa-listing-file

Note that setting both Assembler Output and Use Unicode For Assembler Listing properties can cause Command-Line Warning D9025. To combine these options in the IDE, use the Additional Options field in the Command Line property page instead.

と思ったけど駄目でした。

@berryzplus
Copy link
Author

ですよねw

additional opptions に /FAsu /Fa$(IntDir) を設定すれば、問題を回避できることは分かっているのですが、それをやるとvs2017の設定画面上はアセンブラ出力をしてないように見えるわけで、なんか違う対応な気がしているのです。D9025は矛盾するオプション指定で起きることのが多そうなので、バグリポートしてもスルーされる可能性が高めです。

/Wall適用する準備を始めるころまで放置でいいかな、と。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants