zlib-ng: %nvhpc: Fix build with %nvhpc (similar to zlib) (#43095)
Co-authored-by: Bernhard Kaindl <bernhardkaindl7@gmail.com>
This commit is contained in:
		| @@ -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 @@ def flag_handler(self, name, flags): | ||||
| 
 | ||||
| 
 | ||||
| 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 @@ def cmake_args(self): | ||||
|             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), | ||||
|         ] | ||||
|   | ||||
							
								
								
									
										31
									
								
								var/spack/repos/builtin/packages/zlib-ng/pr-1698.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								var/spack/repos/builtin/packages/zlib-ng/pr-1698.patch
									
									
									
									
									
										Normal file
									
								
							| @@ -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) | \ | ||||
		Reference in New Issue
	
	Block a user
	 Sergey Kosukhin
					Sergey Kosukhin