zstd icon indicating copy to clipboard operation
zstd copied to clipboard

Build error after #4328

Open nidhijaju opened this issue 9 months ago • 4 comments

After https://github.com/facebook/zstd/pull/4328 landed, Chromium is experiencing a build failure due to the changes in lib/decompress/zstd_decompress_block.c.

../../third_party/zstd/src/lib/decompress/zstd_decompress_block.c(1729,29): error: ISO C does not allow indirection on operand of type 'const void *' [-Werror,-Wvoid-ptr-dereference]
 1729 |         PREFETCH_L1(match); PREFETCH_L1(ZSTD_wrappedPtrAdd(match, CACHELINE_SIZE));   /* note : it's safe to invoke PREFETCH() on any memory address, including invalid ones */
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../third_party/zstd/src/lib/decompress\../common/compiler.h(148,84): note: expanded from macro 'PREFETCH_L1'
  148 | #    define PREFETCH_L1(ptr)  do { __asm__ __volatile__("prfm pldl1keep, %0" ::"Q"(*(ptr))); } while (0)
      |                                                                                    ^~~~~~
1 error generated.

It seems like using ZSTD_wrappedPtrAdd returns a const void*, whereas previously it was a const BYTE*. I'd prefer not to disable the -Wvoid-ptr-dereference warning for all of zstd if possible, can we either fix the type or disable the warning on this line after confirming that it is in fact safe?

nidhijaju avatar Mar 25 '25 04:03 nidhijaju

cc @terrelln (from #4328)

Cyan4973 avatar Mar 25 '25 04:03 Cyan4973

Looks like we would need to add -Wvoid-ptr-dereference to our CI to avoid breaking that warning in the future.

terrelln avatar Mar 25 '25 17:03 terrelln

How generic is this compilation flag ? Is it gcc only ?

Cyan4973 avatar Mar 25 '25 20:03 Cyan4973

It appears to be present in Clang, but not sure it's present in GCC.

nidhijaju avatar Apr 28 '25 03:04 nidhijaju