Skip to content

Commit

Permalink
[CPP] Update GCC minversion check to 9 or newer (#120126) (#121419)
Browse files Browse the repository at this point in the history
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 #120020

Pull Request resolved: #120126
Approved by: https://github.com/Skylion007

(cherry picked from commit 3ad067f)

Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com>
  • Loading branch information
pytorchbot and malfet committed Mar 13, 2024
1 parent d37ef49 commit da3f590
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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.

Expand Down
8 changes: 4 additions & 4 deletions c10/util/C++17.h
Expand Up @@ -12,14 +12,14 @@
#include <utility>

#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)) || \
Expand Down

0 comments on commit da3f590

Please sign in to comment.