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

Enable C++20 for Windows build #769

Closed
yukawa opened this issue Jul 15, 2023 · 0 comments
Closed

Enable C++20 for Windows build #769

yukawa opened this issue Jul 15, 2023 · 0 comments

Comments

@yukawa
Copy link
Collaborator

yukawa commented Jul 15, 2023

Description

This keeps track of effort to enable C++20 for Windows build.

While what we want to do is just replacing the following line with /std:c++20, there are several blockers before doing so.

'/std:c++17',

[Resolved] Make sure that our code can be compiled with /permissive-

In Visual Studio 2022, /permissive- option will be automatically set when /std:c++20 is specified. While we can still opt out this behavior by explicitly set /permissive, it'd be a good opportunity for us to clean up non-conformant code from our code base, and we have actually completed this task with the following commits.

[Resolved] Check if Qt DLLs also need to be built with /std:c++20 or not

While we use the same compiler toolset to build both Mozc binaries and Qt binaries, it does not automatically mean that those binaries are compatible when different compiler options are set.

Luckily, Visual C++ team guarantees that /std:c++14, /std:c++17, and /std:c++20 are ABI compatible in Visual Studio 2022, and Microsoft STL also have the same guarantee. Thus, we do not need to modify src/build_tools/build_qt.py right now.

How about -c++std c++2a Qt configure option?

One may wonder if it'd be a good idea for us to specify -c++std c++2a to Qt 5.15.9's configure.bat. It turns out that qmake interprets it as /std:latest rather than /std:c++20. This is quite problematic because /std:latest is not ABI compatible with /std:c++20. We should not specify -c++std c++2a when building Qt unless https://codereview.qt-project.org/c/qt/qtbase/+/394904 gets backported to Qt 5.x.

[Unresolved] Hit GitHub Actions' disk quota when /std:c++20 is specified

The last blocker is specific to GitHub Actions. The build always fails when specifying /std:c++20 as of 0cf3e92, and the message indicates that there is no disk space in the build environment.

It turns out that Visual Studio 2022 will generate much bigger objectfiles and debug symbols when /std:c++20 is specified. The total disk usage increases by roughly 3.5 GB just by switching from /std:c++17 to /std:c++20.

We need to come up with a way to reduce the peak disk usage while building Mozc for Windows.

Version or commit-id

0cf3e92

Environment

  • OS: Windows
hiroyuki-komatsu pushed a commit that referenced this issue Jul 22, 2023
This is a preparation to enable C++20 for Windows (#769)

With this commit, Qt source code will be checked out into

  src/third_party/qt_src

by updade_deps.py then build_qt.py will install Qt binaries (and debug
symbols) into

  src/third_party/qt.

This way we can later delete src/third_party/qt_src to free up disk
space by 2GB or so, which is enough for us to compensate the increase
of disk usage in *.lib and *.obj when /std:c++20 is specified.

There must be no user observable behavior change.

PiperOrigin-RevId: 548523226
hiroyuki-komatsu pushed a commit that referenced this issue Jul 26, 2023
Without this option '__cplusplus' preprocessor macro remains to be
199711L even when '/std:c++20' is specified.

  https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus

To enable libraries to take full advantage of C++20, let's also specify
this option.

Qt6 also requires this compiler option (#775).

PiperOrigin-RevId: 550135462
hiroyuki-komatsu pushed a commit that referenced this issue Aug 7, 2023
Unlike Qt 5.15.9, which uses '/std:latest' that has ABI compatibility
risk when specifying '-c++std c++2a' as seen in #769, Qt 6 simply uses
'/std:c++20' when '-c++std c++20' is set.

Let's enable C++20 only for Qt6 as part of C++ migration (#769) and Qt6
migration (#775). This should allow Qt6 code to rely on optional code
optimizations that are available only in C++20 without introducing ABI
compatibility risk.

There must be no user observable behavior change anyway.

PiperOrigin-RevId: 554343071
hiroyuki-komatsu pushed a commit that referenced this issue Aug 8, 2023
As discussed in #769, storage limit is somewhat critical for GitHub
Action runners. As for Qt source code, we already skip extracting
several files that are not necessary to build Qt binaries used by Mozc.
With this commit, more unnecessary test files are skipped when
extracting Qt source code.

Here are net size changes of extracted source code.

  Qt 5.15.10: 262 MB -> 136 MB
  Qt 6.5.2  : 211 MB -> 119 MB

This is just an optimization of build process. There must be no user
observable behavior change.

PiperOrigin-RevId: 554704573
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

1 participant