Skip to content

Enable C++20 standard#1285

Open
OldDev78 wants to merge 2 commits into
Redot-Engine:masterfrom
OldDev78:cpp20
Open

Enable C++20 standard#1285
OldDev78 wants to merge 2 commits into
Redot-Engine:masterfrom
OldDev78:cpp20

Conversation

@OldDev78

@OldDev78 OldDev78 commented Jun 27, 2026

Copy link
Copy Markdown

Enables C++20 standard, and bumps up: minimum gcc/g++ version to 12, minimum VS to 2022, and clang to 16.

Summary by CodeRabbit

  • Chores
    • Updated build/toolchain requirements to require C++20 support, including refreshed compiler/standard validation and messaging for GCC, Clang, and MSVC.
    • Updated Linux CI to install and use GCC/G++ 12 during builds.
  • Bug Fixes
    • Improved SVG rendering consistency by correctly handling identity clip transforms.
    • Fixed gradient transform detection to more reliably distinguish identity vs. transformed matrices for linear and radial gradients.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Raises the required C++ standard from C++17 to C++20 in SConstruct, updates the Linux workflow to use GCC 12, and qualifies three ThorVG identity() calls with the tvg:: namespace.

Changes

C++20 Build Gating and ThorVG Namespace Qualification

Layer / File(s) Summary
Compiler gates updated for C++20
SConstruct
GCC, Clang, and MSVC minimum version checks and error messages are updated to require C++20 support, and the MSVC check is reduced to a single major-version threshold.
C++20 standard flags set
SConstruct
The post-configure standard selection now keeps CFLAGS at -std=gnu17 while setting non-MSVC CXXFLAGS to -std=gnu++20 and MSVC CXXFLAGS to /std:c++20.
ThorVG identity calls qualified
thirdparty/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp, thirdparty/thorvg/src/renderer/sw_engine/tvgSwFill.cpp
Unqualified identity() calls are replaced with tvg::identity() in the SVG clip builder and software gradient preparation paths.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly captures the main change: enabling C++20 support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
SConstruct (1)

696-697: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove stale VS2017/VS2019 messaging after requiring VS2022.

The MSVC gate now exits for cc_version_major < 17, so the VS2017/VS2019 comment is outdated and the cc_version_major < 16 warning is unreachable.

Proposed cleanup
 elif env.msvc:
-    # Ensure latest minor builds of Visual Studio 2017/2019.
-    # https://github.com/godotengine/godot/pull/94995#issuecomment-2336464574
+    # Require Visual Studio 2022 or newer for C++20 support.
     if cc_version_major < 17:
         print_error(
             "Detected Visual Studio version older than VS2022, which has bugs "
 else:
-    # MSVC started offering C standard support with Visual Studio 2019 16.8
     env.Prepend(CXXFLAGS=["/std:c++20"])
-    if cc_version_major < 16:
-        print_warning("Visual Studio 2017 or older cannot specify a C-Standard.")

Also applies to: 820-823

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@SConstruct` around lines 696 - 697, Update the MSVC version gating comments
and warning text in SConstruct to match the current VS2022-only requirement. The
stale “latest minor builds of Visual Studio 2017/2019” note and the
`cc_version_major < 16` warning are no longer reachable once the
`cc_version_major < 17` check is in place, so remove or rewrite those messages
in the relevant MSVC setup block to reflect the VS2022 gate and keep the logic
consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@SConstruct`:
- Around line 663-665: The GCC version check in SConstruct is now gated at 12,
but the error text in the print_error path still refers to supported versions
starting at 9. Update the diagnostic message in the same GCC-version validation
block to match the new minimum supported GCC 12, keeping it consistent with the
version check and any related wording in the version-gate logic.

---

Nitpick comments:
In `@SConstruct`:
- Around line 696-697: Update the MSVC version gating comments and warning text
in SConstruct to match the current VS2022-only requirement. The stale “latest
minor builds of Visual Studio 2017/2019” note and the `cc_version_major < 16`
warning are no longer reachable once the `cc_version_major < 17` check is in
place, so remove or rewrite those messages in the relevant MSVC setup block to
reflect the VS2022 gate and keep the logic consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 216ca75a-7c32-46f8-97fd-503ac4814cf1

📥 Commits

Reviewing files that changed from the base of the PR and between f7c88fc and cc95cbb.

📒 Files selected for processing (3)
  • SConstruct
  • thirdparty/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp
  • thirdparty/thorvg/src/renderer/sw_engine/tvgSwFill.cpp

Comment thread SConstruct Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/linux_builds.yml:
- Around line 150-152: The GCC 12 toolchain override is only applied to the main
Compilation step, so the redot-cpp build can still use the default compiler.
Update the workflow job for the build steps so `CC` and `CXX` are available to
both Compilation and Compilation (redot-cpp), either by moving the env settings
to the job level or duplicating them on the redot-cpp step; use the existing
Compilation and Compilation (redot-cpp) step definitions as the anchors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 37d3f9d6-fdb0-43de-a96e-55c8373d5d38

📥 Commits

Reviewing files that changed from the base of the PR and between 4eec037 and 80b7482.

📒 Files selected for processing (1)
  • .github/workflows/linux_builds.yml

Comment thread .github/workflows/linux_builds.yml Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/linux_builds.yml (1)

158-167: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Remove the unsupported type: keys from .github/actions/redot-cpp-build/action.yml
Composite-action inputs are strings only, so type: is ignored here and should be dropped to avoid confusion.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/linux_builds.yml around lines 158 - 167, Remove the
unsupported type declarations from the redot-cpp composite action inputs in the
action.yml used by the Compilation (redot-cpp) workflow step, since
composite-action inputs are string-only. Update the inputs definition in
redot-cpp-build/action.yml to keep only the input names and defaults, and ensure
the workflow step that uses redot-cpp-build still passes the same values via
with: without relying on type annotations.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/linux_builds.yml:
- Line 91: The workflow is hard-coding GCC 12 for every Compilation matrix job,
which breaks the LLVM/TSAN row that should validate the Clang path. Update the
compiler setup in the linux_builds workflow to be matrix-driven using the
existing job fields like use_llvm and linker: keep gcc-12/g++-12 only for
non-LLVM rows, and for the TSAN/LLVM row install and export clang-16/clang++-16
instead. Make the same conditional selection wherever CC/CXX are assigned so the
LLVM row continues to exercise the correct toolchain.

---

Nitpick comments:
In @.github/workflows/linux_builds.yml:
- Around line 158-167: Remove the unsupported type declarations from the
redot-cpp composite action inputs in the action.yml used by the Compilation
(redot-cpp) workflow step, since composite-action inputs are string-only. Update
the inputs definition in redot-cpp-build/action.yml to keep only the input names
and defaults, and ensure the workflow step that uses redot-cpp-build still
passes the same values via with: without relying on type annotations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c9475094-e7c4-4e26-9a51-8d7de396b765

📥 Commits

Reviewing files that changed from the base of the PR and between 80b7482 and c60e1cb.

📒 Files selected for processing (1)
  • .github/workflows/linux_builds.yml

Comment thread .github/workflows/linux_builds.yml Outdated
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

Successfully merging this pull request may close these issues.

1 participant