From da3f59012f88e5c7e6d31eef553c713c020b4d23 Mon Sep 17 00:00:00 2001 From: pytorchbot Date: Wed, 13 Mar 2024 16:23:04 -0700 Subject: [PATCH] [CPP] Update GCC minversion check to 9 or newer (#120126) (#121419) It's already a requirement for building PyTorch, but should be a requirement for linking extensions with it, as that can lead to runtime crashes, as `std::optional` template layout is incompatible between gcc-9 and older compilers. Also, update minimum supported clang version to 9.x(used to build Android), as clang-5 is clearly not C++17 compliant. Fixes https://github.com/pytorch/pytorch/issues/120020 Pull Request resolved: https://github.com/pytorch/pytorch/pull/120126 Approved by: https://github.com/Skylion007 (cherry picked from commit 3ad067fe2b969d17773e9ada918c67da829bb5cc) Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com> --- README.md | 2 +- c10/util/C++17.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f6023ceb6d1f..beb788af19ff 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ They require JetPack 4.2 and above, and [@dusty-nv](https://github.com/dusty-nv) #### Prerequisites If you are installing from source, you will need: - Python 3.8 or later (for Linux, Python 3.8.1+ is needed) -- A compiler that fully supports C++17, such as clang or gcc (especially for aarch64, gcc 9.4.0 or newer is required) +- A compiler that fully supports C++17, such as clang or gcc (gcc 9.4.0 or newer is required) We highly recommend installing an [Anaconda](https://www.anaconda.com/download) environment. You will get a high-quality BLAS library (MKL) and you get controlled dependency versions regardless of your Linux distro. diff --git a/c10/util/C++17.h b/c10/util/C++17.h index 0597544ffba9..6007360c6927 100644 --- a/c10/util/C++17.h +++ b/c10/util/C++17.h @@ -12,14 +12,14 @@ #include #if !defined(__clang__) && !defined(_MSC_VER) && defined(__GNUC__) && \ - __GNUC__ < 5 + __GNUC__ < 9 #error \ - "You're trying to build PyTorch with a too old version of GCC. We need GCC 5 or later." + "You're trying to build PyTorch with a too old version of GCC. We need GCC 9 or later." #endif -#if defined(__clang__) && __clang_major__ < 4 +#if defined(__clang__) && __clang_major__ < 9 #error \ - "You're trying to build PyTorch with a too old version of Clang. We need Clang 4 or later." + "You're trying to build PyTorch with a too old version of Clang. We need Clang 9 or later." #endif #if (defined(_MSC_VER) && (!defined(_MSVC_LANG) || _MSVC_LANG < 201703L)) || \