KazApps / YaneuraOu

YaneuraOu is the World's Strongest Shogi engine(AI player) , WCSC29 1st winner , educational and USI compliant engine.
GNU General Public License v3.0
0 stars 0 forks source link

WSL上でIntelコンパイラを用いてやねうら王のWindows用バイナリの生成する方法 #2

Open mrt-tsk opened 3 days ago

mrt-tsk commented 3 days ago

先日はありがとうございました。Intelコンパイラも導入してみました。 IntelコンパイラでAOCCコンパイラと同様の手順でビルドを行ったところ、前回のissueの冒頭で言われた通り、Unsupported PE target というエラーが出ました。解決策をご教授いただけないでしょうか。よろしくお願いします。

mrt-tsk commented 14 hours ago

ちなみに実行環境についてですが Intelコンパイラの導入方法については、https://qiita.com/tlasu/items/0f49c893e22fa646699dを参考にしました。 インストールしたのはintel-basekitのみです。 /opt/intel/oneapi/compiler/2024.2/bin/compiler/clang++ --versionコマンドで Intel(R) oneAPI DPC++/C++ Compiler 2024.2.1 (2024.2.1.20240711) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /opt/intel/oneapi/compiler/2024.2/bin/compilerのような出力です。

クロスコンパイルに必要なファイルは、/opt/intel/oneapi/compiler/2024.2/lib/clang/19/lib/windowsのようにコピーしました。 あとは、AOCCコンパイラの時と同様にまずは最低限の条件でビルドしてみました。 make clean tournament COMPILER=/opt/intel/oneapi/compiler/2024.2/bin/compiler/clang++ EXTRA_CPPFLAGS="-stdlib=libc++ -target x86_64-w64-mingw32 -I/usr/include/mingw-w64 -static -pthread " EXTRA_LDFLAGS="-rtlib=compiler-rt -unwindlib=libunwind -L/usr/lib -L/mnt/c/msys64/mingw64/lib " -j 8

実行結果は Unsupported PE target clang++: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: [Makefile:659: YaneuraOu-by-gcc] Error 1 make[1]: Leaving directory '/home/mrttsk/YaneuraOu/source' make: [Makefile:693: tournament] Error 2 という感じです。

KazApps commented 13 hours ago

気付くのが遅くなってしまい申し訳ありません。 それに関してはIntel Compilerに付属しているリンカではWindows用のバイナリは吐けないので、(あまり良いことではありませんが)msysの方のリンカを使うしかないです。 具体的には、

make clean tournament COMPILER=/opt/intel/oneapi/compiler/latest/bin/compiler/clang++ EXTRA_CPPFLAGS="-stdlib=libc++ -target x86_64-w64-mingw32 -I/usr/include/mingw-w64 -static -pthread" EXTRA_LDFLAGS="-rtlib=compiler-rt -unwindlib=libunwind -L/usr/lib -L/mnt/c/msys64/mingw64/lib" -j 8

のようなコマンドでコンパイルし、リンクエラーが出ると思いますが無視して、msysの方で

# WSL上でビルドしようとしているYaneuraOu/sourceに移動。WSLのUbuntu上のパスの場合、cd //wsl.localhost/Ubuntu-24.04/home/username/YaneuraOu/source のような感じで移動できる。
cd YaneuraOu/source
make tournament COMPILER=clang++ EXTRA_CPPFLAGS="-stdlib=libc++" EXTRA_LDFLAGS="-rtlib=compiler-rt -unwindlib=libunwind"

のような感じでビルドできます。重要なのは、make clean tournamentではなく、make tournamentを使うことで、Intel Compilerでコンパイルしたファイルをリンクしてくれるようになります。 コンパイルオプション(CPUのアーキテクチャの指定)によっては、以下のようなリンカの警告が出ることもありますが、リンク自体は正しくできているようです(速度が落ちるかどうかとかは知りません)。

'-msrlist' is not a recognized feature for this target (ignoring feature)
'-pbndkb' is not a recognized feature for this target (ignoring feature)
'-wrmsrns' is not a recognized feature for this target (ignoring feature)
'-msrlist' is not a recognized feature for this target (ignoring feature)
'-pbndkb' is not a recognized feature for this target (ignoring feature)
'-wrmsrns' is not a recognized feature for this target (ignoring feature)
'-msrlist' is not a recognized feature for this target (ignoring feature)
'-pbndkb' is not a recognized feature for this target (ignoring feature)
'-wrmsrns' is not a recognized feature for this target (ignoring feature)
'-msrlist' is not a recognized feature for this target (ignoring feature)
'-pbndkb' is not a recognized feature for this target (ignoring feature)
'-wrmsrns' is not a recognized feature for this target (ignoring feature)
'-msrlist' is not a recognized feature for this target (ignoring feature)
'-pbndkb' is not a recognized feature for this target (ignoring feature)
'-wrmsrns' is not a recognized feature for this target (ignoring feature)
'-msrlist' is not a recognized feature for this target (ignoring feature)
'-pbndkb' is not a recognized feature for this target (ignoring feature)
'-wrmsrns' is not a recognized feature for this target (ignoring feature)
'-msrlist' is not a recognized feature for this target (ignoring feature)
'-pbndkb' is not a recognized feature for this target (ignoring feature)
'-wrmsrns' is not a recognized feature for this target (ignoring feature)
'-msrlist' is not a recognized feature for this target (ignoring feature)
'-pbndkb' is not a recognized feature for this target (ignoring feature)
'-wrmsrns' is not a recognized feature for this target (ignoring feature)