Skip to content

Default to C++20, pin embedded backends to C++17 - #20438

Closed
cyyever wants to merge 2 commits into
pytorch:mainfrom
cyyever:cxx20-default
Closed

cyyever wants to merge 2 commits into
pytorch:mainfrom
cyyever:cxx20-default

Conversation

@cyyever

@cyyever cyyever commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

PyTorch has moved to C++20 and ExecuTorch's PyTorch-facing targets (_portable_lib, util, wheel config) are already built as C++20. Raise the repo-wide default in the top-level CMakeLists and .buckconfig to match.

The embedded backends build the portable runtime without PyTorch, so their constraint is the cross-toolchain, not the standard the host uses. Pin cadence, cortex_m, arm, nxp, and mediatek to C++17 so they keep building on toolchains (e.g. Xtensa) that lack full C++20 support, regardless of the new default.

Test plan

No new test is required.

cc @mcremon-meta @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani @robert-kalmar @JakeStevens

@pytorch-bot

pytorch-bot Bot commented Jun 23, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20438

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 11 Awaiting Approval, 1 Unclassified Failure

As of commit 350ec6e with merge base a26420d (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:

  • Cadence Build & Test / Resolve CI docker image / resolve (gh) (this job did not run on the merge base, so DrCI cannot tell whether the failure is pre-existing)
    ##[error]Refusing to check out fork pull request code from a 'pull_request_target' workflow. This workflow runs with the base repository's GITHUB_TOKEN, secrets, default-branch cache scope, and runner access. Fetching and executing a fork's code in that trusted context commonly leads to "pwn request" vulnerabilities. To opt in, review the risks at https://gh.io/securely-using-pull_request_target and set 'allow-unsafe-pr-checkout: true' on the actions/checkout step.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 23, 2026
@github-actions github-actions Bot added ciflow/trunk module: arm Issues related to arm backend labels Jun 23, 2026
@pytorch-bot

pytorch-bot Bot commented Jun 23, 2026 •

Copy link
Copy Markdown

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/trunk

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

@cyyever

cyyever commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "release notes: none"

@pytorch-bot pytorch-bot Bot added the release notes: none Do not include this in the release notes label Jun 23, 2026
@rascani
rascani self-requested a review June 23, 2026 15:13
@rascani

rascani commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

I think we'd rather keep one C++ standard level. I've opened #20468 to discuss raising the standard to C++20.

@cyyever

cyyever commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

@rascani We can not move all code to cpp 20 due to device environment limits.

@rascani

rascani commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

@rascani We can not move all code to cpp 20 due to device environment limits.

The problem here is that the embedded toolchains don't just build their backends, but they also build the core runtime and portable kernel libraries. Since this PR changes the core runtime and portable kernel libraries to C++20, those embedded toolchains would need to support C++20 anyways.

We could keep the default at C++17 and opt into C++20 for specific platforms and/or extension libraries (those unlikely to be used on embedded), but that probably just creates more divergence for minimal value.

@cyyever

cyyever commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

@rascani There is no better way than mixing C++20 core code and C++17 device code compilation, since more upstream code is migrating to newer standards. It is theoretically possible by maintaining a C++17 compatible core API. As a first step, we could monitor CI failures.

@rascani

rascani commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@rascani There is no better way than mixing C++20 core code and C++17 device code compilation, since more upstream code is migrating to newer standards. It is theoretically possible by maintaining a C++17 compatible core API. As a first step, we could monitor CI failures.

The shared code from upstream pytorch is fairly minimal and @JacobSzwejbka added checks upstream to ensure it remains C++17 compatible (pytorch/pytorch#168204).

I don't see any value in pinning the embedded backends to C++17. If the embedded toolchains do not support C++20, we cannot move the executorch core runtime to C++20. If the embedded toolchains do support C++20, then both the executorch core runtime and the backends can move to C++20. We can certainly try out the latter in CI.

cyyever added 2 commits July 14, 2026 08:12
PyTorch has moved to C++20 and ExecuTorch's PyTorch-facing targets
(_portable_lib, util, wheel config) are already built as C++20. Raise the
repo-wide default in the top-level CMakeLists and .buckconfig to match.

The embedded backends build the portable runtime without PyTorch, so their
constraint is the cross-toolchain, not the standard the host uses. Pin
cadence, cortex_m, arm, nxp, and mediatek to C++17 so they keep building on
toolchains (e.g. Xtensa) that lack full C++20 support, regardless of the new
default.
@nil-is-all nil-is-all added module: cadence Issues related to the Cadence/Xtensa backend module: mediatek Delegate to MediaTek backend module: nxp Issues related to NXP Neutron NPU delegation and code under backends/nxp/ labels Jul 14, 2026
@github-actions

Copy link
Copy Markdown

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
If you want the bot to never mark this PR stale again, add the no-stale label.
Stale pull requests will automatically be closed after 30 days of inactivity.

@github-actions github-actions Bot added the Stale PRs inactive for over 60 days label Sep 14, 2026
@executorch-triage executorch-triage Bot added the community: contribution PRs coming from community (excluding hardware partners) label Sep 22, 2026
@github-actions github-actions Bot closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. community: contribution PRs coming from community (excluding hardware partners) module: arm Issues related to arm backend module: cadence Issues related to the Cadence/Xtensa backend module: mediatek Delegate to MediaTek backend module: nxp Issues related to NXP Neutron NPU delegation and code under backends/nxp/ release notes: none Do not include this in the release notes Stale PRs inactive for over 60 days

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants