LoginSignup
1
1

More than 5 years have passed since last update.

lxn/walk を使っている場合に go build -race のエラー回避

Last updated at Posted at 2017-08-27

lxn/walk を使って Windows で GUI なアラームアプリを作り初めた。
race condition が発生したので、 go build -race を実行してみたところビルドに失敗。

$ go build -race
# github.com/hokorobi/MultiGoAlarm
C:\path\to\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
D:/path/to/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: i386 architecture of input file `C:\Users\hokorobi\AppData\Local\Temp\go-link-505336639\000000.o' is incompatible with i386:x86-64 output
collect2.exe: error: ld returned 1 exit status

exit status 2
  • lxn/walk や外部ライブラリを使わないコードだとエラーにはならない。
  • lxn/walk/example でもエラーになる

という状況だったので、lxn/walk で使用する rsrc.syso が原因ではないかと目星をつけた。

rsrc.syso の生成に使用する akavel/rsrc を見に行くと -arch="386": architecture of output file - one of: 386, [EXPERIMENTAL: amd64] という記載を見つけた。
rsrc を更新して -arch="amd64" をつけて rsrc.syso を生成。
再度の go build -race でエラー発生なし。
akavel/rsrc に EXPERIMENTAL とあるので、Race Detector がちゃんと機能するかは不明。

rsrc.syso でなく manifest ファイルを置く場合は問題ないのだと思う(未検証)

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1