zstd icon indicating copy to clipboard operation
zstd copied to clipboard

Enable weak symbol support for Risc-V?

Open guoyuqi020 opened this issue 1 year ago • 1 comments

I am using zstd on Risc-V machines. I noticed that zstd_trace is disabled on Risc-V. After some investigating, I found this was because the zstd's weak symbol support was conservatively disabled on Risc-V.

However, as far as I know, Risc-V supports weak symbols, and the weak attribute can be used on Risc-V’s GCC.

So, will you consider enabling weak symbol support for Risc-V?

I guess adding a defined (__riscv) in the following code will make it work.

// lib/common/zstd_trace.h

/* weak symbol support
 * For now, enable conservatively:
 * - Only GNUC
 * - Only ELF
 * - Only x86-64, i386 and aarch64
 * Also, explicitly disable on platforms known not to work so they aren't
 * forgotten in the future.
 */
#if !defined(ZSTD_HAVE_WEAK_SYMBOLS) && \
    defined(__GNUC__) && defined(__ELF__) && \
    (defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) || defined(__aarch64__)) && \
    !defined(__APPLE__) && !defined(_WIN32) && !defined(__MINGW32__) && \
    !defined(__CYGWIN__) && !defined(_AIX)
#  define ZSTD_HAVE_WEAK_SYMBOLS 1
#else
#  define ZSTD_HAVE_WEAK_SYMBOLS 0
#endif
#if ZSTD_HAVE_WEAK_SYMBOLS
#  define ZSTD_WEAK_ATTR __attribute__((__weak__))
#else
#  define ZSTD_WEAK_ATTR
#endif

guoyuqi020 avatar Jun 06 '24 08:06 guoyuqi020