Set up a CI build using clang cross-compiling for MSW (Issue #22972)

55 views
Skip to first unread message

VZ

unread,
Nov 16, 2022, 9:06:49 AM11/16/22
to wx-...@googlegroups.com, Subscribed

I've discovered a nice xwin tool which can be used to compile MSW-specific code using clang. I think it would be nice to set up a CI build doing this, as clang can find bugs in MSW code which are not detected neither by gcc (which also doesn't compile all of it) nor MSVC.

For the record, I had to use the following options to suppress warnings inside the SDK headers themselves (perhaps this could be integrated into wx headers, i.e. push/pop them before/after including windows.h):

  • -Wno-nonportable-include-path: due to windows.h vs Windows.h mismatch.
  • -Wno-ignored-pragma-intrinsic: plenty of those in um/winnt.h, maybe we do need to include intrin.h as the error message recommends.
  • -Wno-ignored-attributes: no_init_all is used for _CONTEXT structs in winnt.h.

The full command line is something like

clang++-14 -Wno-nonportable-include-path -Wno-ignored-pragma-intrinsic -Wno-ignored-attributes --target=x86_64-pc-windows-msvc -I /opt/windows-msvc/crt/include -I /opt/windows-msvc/sdk/include/ucrt -I /opt/windows-msvc/sdk/include/um -I /opt/windows-msvc/sdk/include/shared ...

where /opt/windows-msvc is the directory with the files downloaded by xwin.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22972@github.com>

Maarten

unread,
Nov 16, 2022, 12:28:09 PM11/16/22
to wx-...@googlegroups.com, Subscribed

Do you specifically want to cross-compile, or is building with clang on Windows also fine?
In that case it might be easier to use the msys2 github action, install mingw-w64-x86_64-clang, and build like
cmake -G "MinGW Makefiles" -DCMAKE_C_COMPILER=clang.exe -DCMAKE_CXX_COMPILER=clang++.exe -DCMAKE_BUILD_TYPE=Release.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22972/1317390204@github.com>

VZ

unread,
Nov 16, 2022, 1:50:11 PM11/16/22
to wx-...@googlegroups.com, Subscribed

I rather like cross-compiling from Linux (it's more convenient for me and often more flexible), but you're right, using clang under Windows could be an even simpler solution -- after all the main goal here is to fix any bugs that clang warnings could discover in MSW code. Thanks for the suggestion!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22972/1317510768@github.com>

VZ

unread,
Nov 24, 2022, 8:48:38 PM11/24/22
to wx-...@googlegroups.com, Subscribed

We're not going to do this now that Maarten has added a native clang build.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22972/1326940956@github.com>

VZ

unread,
Nov 24, 2022, 8:48:39 PM11/24/22
to wx-...@googlegroups.com, Subscribed

Closed #22972 as completed.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/22972/issue_event/7889414251@github.com>

Reply all
Reply to author
Forward
0 new messages