]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
liblzma: Fix building with NVHPC (NVIDIA HPC SDK).
authorSergey Kosukhin <sergey.kosukhin@mpimet.mpg.de>
Wed, 13 Mar 2024 12:07:13 +0000 (13:07 +0100)
committerLasse Collin <lasse.collin@tukaani.org>
Fri, 15 Mar 2024 15:30:50 +0000 (17:30 +0200)
NVHPC compiler has several issues that make it impossible to
build liblzma:
  - the compiler cannot handle unions that contain pointers that
    are not the first members;
  - the compiler cannot handle the assembler code in range_decoder.h
    (LZMA_RANGE_DECODER_CONFIG has to be set to zero);
  - the compiler fails to produce valid code for delta_decode if the
    vectorization is enabled, which results in failed tests.

This introduces NVHPC-specific workarounds that address the issues.

src/liblzma/common/string_conversion.c
src/liblzma/delta/delta_decoder.c
src/liblzma/rangecoder/range_decoder.h

index 92d9032bdd189736f5931d14f7d2f1c47022a0c2..370857f01af2be9d029409ae672fc4ffb446f0e4 100644 (file)
@@ -217,12 +217,14 @@ typedef struct {
        uint16_t offset;
 
        union {
+// NVHPC has problems with unions that contain pointers that are not the first
+// members
+               const name_value_map *map;
+
                struct {
                        uint32_t min;
                        uint32_t max;
                } range;
-
-               const name_value_map *map;
        } u;
 } option_map;
 
index 10d53687894ed8c5a87a0ee80936dd59dcc28d9f..142fe6de88684e9cdbef22c5e66b63f8f5e74618 100644 (file)
@@ -25,6 +25,9 @@ decode_buffer(lzma_delta_coder *coder, uint8_t *buffer, size_t size)
 }
 
 
+#ifdef __NVCOMPILER
+#      pragma routine novector
+#endif
 static lzma_ret
 delta_decode(void *coder_ptr, const lzma_allocator *allocator,
                const uint8_t *restrict in, size_t *restrict in_pos,
index b6422247f3c3f07b13966dea35712b6a2d96611c..31a58d1ffbeda277496db79ee5c9581fec84bb76 100644 (file)
@@ -45,6 +45,7 @@
 //     and different processors. Overall 0x1F0 seems to be the best choice.
 #ifndef LZMA_RANGE_DECODER_CONFIG
 #      if defined(__x86_64__) && !defined(__ILP32__) \
+                       && !defined(__NVCOMPILER) \
                        && (defined(__GNUC__) || defined(__clang__))
 #              define LZMA_RANGE_DECODER_CONFIG 0x1F0
 #      else