facebook / zstd

Zstandard - Fast real-time compression algorithm
http://www.zstd.net
Other
23.42k stars 2.08k forks source link

Enable weak symbol support for Risc-V? #4069

Open guoyuqi020 opened 3 months ago

guoyuqi020 commented 3 months ago

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
adenilsoncavalcanti commented 3 months ago

I can help with this one, I got access to RVV 1.0 compliant RISC-V boards to test.