diff options
author | Sergey Kosukhin <sergey.kosukhin@mpimet.mpg.de> | 2024-03-28 11:41:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-28 10:41:10 +0100 |
commit | f29cb7f9539da4466ff4185a923595c11313d7ea (patch) | |
tree | 2cc54f9a280c7bbf533360e090bf3b448289d1c3 | |
parent | 826b8f25c52d1619e9fb7b899103d53d74ae3efa (diff) | |
download | spack-f29cb7f9539da4466ff4185a923595c11313d7ea.tar.gz spack-f29cb7f9539da4466ff4185a923595c11313d7ea.tar.bz2 spack-f29cb7f9539da4466ff4185a923595c11313d7ea.tar.xz spack-f29cb7f9539da4466ff4185a923595c11313d7ea.zip |
zlib-ng: %nvhpc: Fix build with %nvhpc (similar to zlib) (#43095)
Co-authored-by: Bernhard Kaindl <bernhardkaindl7@gmail.com>
-rw-r--r-- | var/spack/repos/builtin/packages/zlib-ng/package.py | 15 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/zlib-ng/pr-1698.patch | 31 |
2 files changed, 46 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/zlib-ng/package.py b/var/spack/repos/builtin/packages/zlib-ng/package.py index 2a5675ab15..6322d97696 100644 --- a/var/spack/repos/builtin/packages/zlib-ng/package.py +++ b/var/spack/repos/builtin/packages/zlib-ng/package.py @@ -56,10 +56,16 @@ class ZlibNg(AutotoolsPackage, CMakePackage): patch("pr-1561.patch", when="build_system=autotools") # drop bash dependency patch("pr-1562.patch") # improve intrinsics detection + # fix building with NVHPC, see https://github.com/zlib-ng/zlib-ng/pull/1698 + # (@2.1.0:2.1.3 need the same changes but in a different file) + patch("pr-1698.patch", when="@2.1.4:%nvhpc+opt") + with when("build_system=cmake"): depends_on("cmake@3.5.1:", type="build") depends_on("cmake@3.14.0:", type="build", when="@2.1.0:") + conflicts("%nvhpc@:20", msg="the compiler is too old and too broken") + @property def libs(self): name = "libz" if self.spec.satisfies("+compat") else "libz-ng" @@ -74,6 +80,14 @@ class ZlibNg(AutotoolsPackage, CMakePackage): class AutotoolsBuilder(autotools.AutotoolsBuilder): + + @run_before("configure") + def pretend_gcc(self): + # All nice things (PIC flags, symbol versioning) that happen to the compilers that are + # recognized as gcc (%gcc, %clang, %intel, %oneapi) we want for some other compilers too: + if self.spec.compiler.name in ["nvhpc"]: + filter_file(r"^gcc=0$", "gcc=1", join_path(self.configure_directory, "configure")) + def configure_args(self): args = [] if self.spec.satisfies("+compat"): @@ -95,4 +109,5 @@ class CMakeBuilder(cmake.CMakeBuilder): self.define("BUILD_SHARED_LIBS", self.spec.satisfies("+shared")), self.define_from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"), self.define_from_variant("WITH_NEW_STRATEGIES", "new_strategies"), + self.define("ZLIB_ENABLE_TESTS", self.pkg.run_tests), ] diff --git a/var/spack/repos/builtin/packages/zlib-ng/pr-1698.patch b/var/spack/repos/builtin/packages/zlib-ng/pr-1698.patch new file mode 100644 index 0000000000..7bea02d0ca --- /dev/null +++ b/var/spack/repos/builtin/packages/zlib-ng/pr-1698.patch @@ -0,0 +1,31 @@ +From fb504432aae51c45397f3e563c659c11d68a10e2 Mon Sep 17 00:00:00 2001 +From: Sergey Kosukhin <sergey.kosukhin@mpimet.mpg.de> +Date: Tue, 12 Mar 2024 15:46:52 +0100 +Subject: [PATCH] Fix building with NVHPC + +--- + arch/x86/x86_intrins.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/arch/x86/x86_intrins.h b/arch/x86/x86_intrins.h +index 52e1085d66..0e596d18a1 100644 +--- a/arch/x86/x86_intrins.h ++++ b/arch/x86/x86_intrins.h +@@ -7,7 +7,7 @@ + #ifdef __AVX2__ + #include <immintrin.h> + +-#if (!defined(__clang__) && defined(__GNUC__) && __GNUC__ < 10) \ ++#if (!defined(__clang__) && !defined(__NVCOMPILER) && defined(__GNUC__) && __GNUC__ < 10) \ + || (defined(__apple_build_version__) && __apple_build_version__ < 9020039) + static inline __m256i _mm256_zextsi128_si256(__m128i a) { + __m128i r; +@@ -29,7 +29,7 @@ static inline __m512i _mm512_zextsi128_si512(__m128i a) { + /* GCC <9 is missing some AVX512 intrinsics. + */ + #ifdef __AVX512F__ +-#if (!defined(__clang__) && defined(__GNUC__) && __GNUC__ < 9) ++#if (!defined(__clang__) && !defined(__NVCOMPILER) && defined(__GNUC__) && __GNUC__ < 9) + #include <immintrin.h> + + #define PACK(c0, c1, c2, c3) (((int)(unsigned char)(c0) << 24) | ((int)(unsigned char)(c1) << 16) | \ |