Skip to content

[WIP] C++20 is now the minimum required version#5265

Open
WeiqunZhang wants to merge 5 commits intoAMReX-Codes:developmentfrom
WeiqunZhang:cxx20
Open

[WIP] C++20 is now the minimum required version#5265
WeiqunZhang wants to merge 5 commits intoAMReX-Codes:developmentfrom
WeiqunZhang:cxx20

Conversation

@WeiqunZhang
Copy link
Copy Markdown
Member

@WeiqunZhang WeiqunZhang commented Apr 1, 2026

Supported compilers are:

  • GCC 11 or newer (for both host builds and CUDA host compilers).
  • LLVM Clang 14 or newer, including AppleClang 14 on macOS.
  • Microsoft Visual Studio 2022 (MSVC 19.34 / 17.4) or newer.
  • NVIDIA CUDA Toolkit 12.2 or newer.
  • AMD ROCm/HIP 6.0 or newer.
  • Intel oneAPI DPC++ 2025.2 or newer. (Aurora has two version only, 2025.2 and 2025.3.)

Supported compilers are:
- GCC 11 or newer (for both host builds and CUDA host compilers).
- LLVM Clang 14 or newer, including AppleClang 14 on macOS.
- Microsoft Visual Studio 2022 (MSVC 19.34 / 17.4) or newer.
- NVIDIA CUDA Toolkit 12.2 or newer.
- AMD ROCm/HIP 6.0 or newer.
- Intel oneAPI DPC++ 2025.3 or newer.
@WeiqunZhang
Copy link
Copy Markdown
Member Author

The supported compilers were suggested by ChatGPT. We need to verify it.

@WeiqunZhang WeiqunZhang requested review from atmyers and ax3l April 1, 2026 20:56
@BenWibking
Copy link
Copy Markdown
Contributor

There may be some GCC issues with the standard library with GCC 11. Some standard library features are not implemented until GCC 12 or 13: https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2020

@zingale
Copy link
Copy Markdown
Member

zingale commented Apr 1, 2026

We require GCC 13 for Castro now. I don't think GCC 11 will be enough.

@WeiqunZhang
Copy link
Copy Markdown
Member Author

What features you guys have used require gcc 12 or 13? Right now, we are not using any in AMReX yet.

@zingale
Copy link
Copy Markdown
Member

zingale commented Apr 1, 2026

std::numbers
std::format
some range library stuff
and concepts (see https://github.com/AMReX-Astro/Microphysics/blob/1ffc24e3c10dc0ede4d88d257deade627c28f28b/interfaces/eos_type.H#L168)

@BenWibking
Copy link
Copy Markdown
Contributor

BenWibking commented Apr 1, 2026

<concepts> does not compile without gcc 13. We use that in Quokka.

@zingale
Copy link
Copy Markdown
Member

zingale commented Apr 1, 2026

once you turn on std=c++20, clang-tidy will start recommending lots of new modernizations.

@WeiqunZhang
Copy link
Copy Markdown
Member Author

We have explicitly disabled them.

# We will try to modernize this after switching to C++20
# -modernize-use-constraints
# -modernize-use-designated-initializers
# -modernize-use-std-numbers
# -modernize-use-ranges
# -modernize-use-integer-sign-comparison
# -modernize-use-starts-ends-with
# -readability-container-contains

@zingale
Copy link
Copy Markdown
Member

zingale commented Apr 1, 2026

the modernize-use-std-numbers is a pain -- if there is a constant that is even close to pi or sqrt(2), it will suggest replacing the entire constant. Messes up with tabulated rate data.

@WeiqunZhang
Copy link
Copy Markdown
Member Author

Since setting a lower minimum in amrex will not prevent application codes from using new features, we might want to start with a lower version, and see that what features we really want to use in amrex that are not supported by old compilers.

@zingale
Copy link
Copy Markdown
Member

zingale commented Apr 1, 2026

yeah, that's a good approach. GCC 11 is getting old, but 12 is probably still around a lot. 16 comes out in a few weeks.

@WeiqunZhang
Copy link
Copy Markdown
Member Author

WeiqunZhang commented Apr 1, 2026

• - GCC 11 – First stable release (11.1) landed on 27 April 2021, kicking off the GCC 11 series. (gnu.org (https://www.gnu.org/software/gcc/releases.html?utm_source=openai))
- Where it’s default today:
- Ubuntu 22.04 LTS “Jammy Jellyfish” ships GCC 11 as the gcc default (the gcc-defaults package in Jammy tracks version 11). (documentation.ubuntu.com
(https://documentation.ubuntu.com/ubuntu-for-developers/reference/availability/gcc/?utm_source=openai))
- Red Hat Enterprise Linux 9 also uses GCC 11 as the system compiler that builds the distribution and is supported for the full RHEL 9 lifecycle. (docs.redhat.com
(https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html-single/developing_c_and_cpp_applications_in_rhel_9/index?utm_source=openai))
- Implication: if you target GCC 11 you automatically cover the mainstream enterprise RHEL9 base and the still-supported Ubuntu 22.04 LTS line, which together account for a large
slice of HPC/server installs.

  • GCC 12 – First stable release (12.1) arrived on 6 May 2022, and 12.2 followed on 19 Aug 2022; 12.x has been in maintenance since. (gnu.org
    (https://www.gnu.org/software/gcc/releases.html?utm_source=openai))
    • Where it’s default today:
    • Implication: GCC 12 support is effectively guaranteed on the latest Debian stable and on modern Fedora-based environments, so treating GCC 12 as the “new baseline” aligns you with
      developers on Bookworm, Fedora, and downstream derivatives (e.g., Rocky/Alma betas tracking RHEL 10).

Practical takeaway: Document GCC 11 support when you need to cover RHEL 9 / Ubuntu 22.04-era systems, but for “current” distros expect GCC 12 as the default toolchain—especially
wherever Debian 12 or Fedora 36+ is in play.

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.

3 participants