liblzma: Fix building with NVHPC (NVIDIA HPC SDK).

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 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.

(This commit was contributed under 0BSD but the author confirmed
that it is fine to backport it to the public domain branches. See
https://github.com/tukaani-project/xz/pull/90#issuecomment-2100185936
and the next two messages.)

(cherry picked from commit 096bc0e3f8)
This commit is contained in:
Sergey Kosukhin 2024-03-13 13:07:13 +01:00 committed by Lasse Collin
parent 78a015e753
commit 65ac20807c
2 changed files with 7 additions and 2 deletions

View File

@ -218,12 +218,14 @@ typedef struct {
uint16_t offset; uint16_t offset;
union { union {
// NVHPC has problems with unions that contain pointers that are not the first
// members
const name_value_map *map;
struct { struct {
uint32_t min; uint32_t min;
uint32_t max; uint32_t max;
} range; } range;
const name_value_map *map;
} u; } u;
} option_map; } option_map;

View File

@ -26,6 +26,9 @@ decode_buffer(lzma_delta_coder *coder, uint8_t *buffer, size_t size)
} }
#ifdef __NVCOMPILER
# pragma routine novector
#endif
static lzma_ret static lzma_ret
delta_decode(void *coder_ptr, const lzma_allocator *allocator, delta_decode(void *coder_ptr, const lzma_allocator *allocator,
const uint8_t *restrict in, size_t *restrict in_pos, const uint8_t *restrict in, size_t *restrict in_pos,