From 30153b106428597b713c548d427ed7a35e776c5c Mon Sep 17 00:00:00 2001 From: Scott McMillan Date: Thu, 8 Apr 2021 03:57:05 -0500 Subject: tar: make it build with nvhpc (#22853) Co-authored-by: Scott McMillan --- .../repos/builtin/packages/tar/nvhpc-1.30.patch | 34 +++++++++++++++++++++ .../repos/builtin/packages/tar/nvhpc-1.34.patch | 35 ++++++++++++++++++++++ .../builtin/packages/tar/nvhpc-long-width.patch | 17 +++++++++++ var/spack/repos/builtin/packages/tar/nvhpc.patch | 34 --------------------- var/spack/repos/builtin/packages/tar/package.py | 7 ++++- 5 files changed, 92 insertions(+), 35 deletions(-) create mode 100644 var/spack/repos/builtin/packages/tar/nvhpc-1.30.patch create mode 100644 var/spack/repos/builtin/packages/tar/nvhpc-1.34.patch create mode 100644 var/spack/repos/builtin/packages/tar/nvhpc-long-width.patch delete mode 100644 var/spack/repos/builtin/packages/tar/nvhpc.patch diff --git a/var/spack/repos/builtin/packages/tar/nvhpc-1.30.patch b/var/spack/repos/builtin/packages/tar/nvhpc-1.30.patch new file mode 100644 index 0000000000..ecd56b72e1 --- /dev/null +++ b/var/spack/repos/builtin/packages/tar/nvhpc-1.30.patch @@ -0,0 +1,34 @@ +--- a/gnu/xalloc-oversized.h 2020-08-21 06:38:16.472440800 -0700 ++++ b/gnu/xalloc-oversized.h 2020-08-21 06:39:22.717691266 -0700 +@@ -41,10 +41,10 @@ + positive and N must be nonnegative. This is a macro, not a + function, so that it works correctly even when SIZE_MAX < N. */ + +-#if 7 <= __GNUC__ ++#if 7 <= __GNUC__ && !defined __NVCOMPILER + # define xalloc_oversized(n, s) \ + __builtin_mul_overflow_p (n, s, (__xalloc_count_type) 1) +-#elif 5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__ ++#elif 5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__ && !defined __NVCOMPILER + # define xalloc_oversized(n, s) \ + (__builtin_constant_p (n) && __builtin_constant_p (s) \ + ? __xalloc_oversized (n, s) \ +--- a/gnu/intprops.h 2020-08-21 06:37:03.301158640 -0700 ++++ b/gnu/intprops.h 2020-08-21 06:38:01.807384249 -0700 +@@ -219,14 +219,14 @@ + : (max) >> (b) < (a)) + + /* True if __builtin_add_overflow (A, B, P) works when P is non-null. */ +-#if 5 <= __GNUC__ && !defined __ICC ++#if 5 <= __GNUC__ && !defined __ICC && !defined __NVCOMPILER + # define _GL_HAS_BUILTIN_OVERFLOW 1 + #else + # define _GL_HAS_BUILTIN_OVERFLOW 0 + #endif + + /* True if __builtin_add_overflow_p (A, B, C) works. */ +-#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__) ++#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__ && !defined __NVCOMPILER) + + /* The _GL*_OVERFLOW macros have the same restrictions as the + *_RANGE_OVERFLOW macros, except that they do not assume that operands diff --git a/var/spack/repos/builtin/packages/tar/nvhpc-1.34.patch b/var/spack/repos/builtin/packages/tar/nvhpc-1.34.patch new file mode 100644 index 0000000000..9f8d037d3c --- /dev/null +++ b/var/spack/repos/builtin/packages/tar/nvhpc-1.34.patch @@ -0,0 +1,35 @@ +--- a/gnu/xalloc-oversized.h ++++ b/gnu/xalloc-oversized.h +@@ -41,10 +41,10 @@ + positive and N must be nonnegative. This is a macro, not a + function, so that it works correctly even when SIZE_MAX < N. */ + +-#if 7 <= __GNUC__ && !defined __clang__ ++#if 7 <= __GNUC__ && !defined __clang__ && !defined __NVCOMPILER + # define xalloc_oversized(n, s) \ + __builtin_mul_overflow_p (n, s, (__xalloc_count_type) 1) +-#elif 5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__ ++#elif 5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__ && !defined __NVCOMPILER + # define xalloc_oversized(n, s) \ + (__builtin_constant_p (n) && __builtin_constant_p (s) \ + ? __xalloc_oversized (n, s) \ +--- a/gnu/intprops.h ++++ b/gnu/intprops.h +@@ -228,7 +228,7 @@ + (A, B, P) work when P is non-null. */ + /* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x, + see . */ +-#if 7 <= __GNUC__ && !defined __ICC ++#if 7 <= __GNUC__ && !defined __ICC && !defined __NVCOMPILER + # define _GL_HAS_BUILTIN_ADD_OVERFLOW 1 + #elif defined __has_builtin + # define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow) +@@ -246,7 +246,7 @@ + + /* True if __builtin_add_overflow_p (A, B, C) works, and similarly for + __builtin_sub_overflow_p and __builtin_mul_overflow_p. */ +-#if defined __clang__ || defined __ICC ++#if defined __clang__ || defined __ICC || defined __NVCOMPILER + /* Clang 11 lacks __builtin_mul_overflow_p, and even if it did it + would presumably run afoul of Clang bug 16404. ICC 2021.1's + __builtin_add_overflow_p etc. are not treated as integral constant diff --git a/var/spack/repos/builtin/packages/tar/nvhpc-long-width.patch b/var/spack/repos/builtin/packages/tar/nvhpc-long-width.patch new file mode 100644 index 0000000000..9e7378a2f4 --- /dev/null +++ b/var/spack/repos/builtin/packages/tar/nvhpc-long-width.patch @@ -0,0 +1,17 @@ +--- a/gnu/regex_internal.h 2020-08-21 09:14:20.039942370 -0700 ++++ b/gnu/regex_internal.h 2020-08-21 10:06:57.840331452 -0700 +@@ -35,6 +35,14 @@ + #include + #include + ++#ifndef __LONG_WIDTH__ ++#if LONG_WIDTH ++#define __LONG_WIDTH__ LONG_WIDTH ++#else ++#define __LONG_WIDTH__ __WORDSIZE ++#endif ++#endif ++ + #if defined DEBUG && DEBUG != 0 + # include + # define DEBUG_ASSERT(x) assert (x) diff --git a/var/spack/repos/builtin/packages/tar/nvhpc.patch b/var/spack/repos/builtin/packages/tar/nvhpc.patch deleted file mode 100644 index ecd56b72e1..0000000000 --- a/var/spack/repos/builtin/packages/tar/nvhpc.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- a/gnu/xalloc-oversized.h 2020-08-21 06:38:16.472440800 -0700 -+++ b/gnu/xalloc-oversized.h 2020-08-21 06:39:22.717691266 -0700 -@@ -41,10 +41,10 @@ - positive and N must be nonnegative. This is a macro, not a - function, so that it works correctly even when SIZE_MAX < N. */ - --#if 7 <= __GNUC__ -+#if 7 <= __GNUC__ && !defined __NVCOMPILER - # define xalloc_oversized(n, s) \ - __builtin_mul_overflow_p (n, s, (__xalloc_count_type) 1) --#elif 5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__ -+#elif 5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__ && !defined __NVCOMPILER - # define xalloc_oversized(n, s) \ - (__builtin_constant_p (n) && __builtin_constant_p (s) \ - ? __xalloc_oversized (n, s) \ ---- a/gnu/intprops.h 2020-08-21 06:37:03.301158640 -0700 -+++ b/gnu/intprops.h 2020-08-21 06:38:01.807384249 -0700 -@@ -219,14 +219,14 @@ - : (max) >> (b) < (a)) - - /* True if __builtin_add_overflow (A, B, P) works when P is non-null. */ --#if 5 <= __GNUC__ && !defined __ICC -+#if 5 <= __GNUC__ && !defined __ICC && !defined __NVCOMPILER - # define _GL_HAS_BUILTIN_OVERFLOW 1 - #else - # define _GL_HAS_BUILTIN_OVERFLOW 0 - #endif - - /* True if __builtin_add_overflow_p (A, B, C) works. */ --#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__) -+#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__ && !defined __NVCOMPILER) - - /* The _GL*_OVERFLOW macros have the same restrictions as the - *_RANGE_OVERFLOW macros, except that they do not assume that operands diff --git a/var/spack/repos/builtin/packages/tar/package.py b/var/spack/repos/builtin/packages/tar/package.py index b665031f29..58e4de1877 100644 --- a/var/spack/repos/builtin/packages/tar/package.py +++ b/var/spack/repos/builtin/packages/tar/package.py @@ -31,7 +31,12 @@ class Tar(AutotoolsPackage, GNUMirrorPackage): patch('se-selinux.patch', when='@:1.29') patch('argp-pgi.patch', when='@:1.29') patch('gnutar-configure-xattrs.patch', when='@1.28') - patch('nvhpc.patch', when='%nvhpc') + # The NVIDIA compilers do not currently support some GNU builtins. + # Detect this case and use the fallback path. + patch('nvhpc-1.30.patch', when='@1.30:1.32 %nvhpc') + patch('nvhpc-1.34.patch', when='@1.34 %nvhpc') + # Workaround bug where __LONG_WIDTH__ is not defined + patch('nvhpc-long-width.patch', when='@1.34 %nvhpc') @classmethod def determine_version(cls, exe): -- cgit v1.2.3-70-g09d2