From 22aec4de9f9ecb7a5e1b2a663d74692cdb4cf61a Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Sun, 18 Mar 2018 03:42:57 +0000 Subject: [PATCH] lib(private)zstd: Fix riscv build Link __bswap[ds]i2() intrinsics in to libzstd for riscv, where the C runtime apparently lacks such intrinsics. Broken in r330894. Reported by: asomers Sponsored by: Dell EMC Isilon --- lib/libzstd/Makefile | 7 +++++++ sys/contrib/zstd/lib/freebsd/zstd_kfreebsd.c | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/lib/libzstd/Makefile b/lib/libzstd/Makefile index 304b71ca84d..ca56bcb0c82 100644 --- a/lib/libzstd/Makefile +++ b/lib/libzstd/Makefile @@ -43,4 +43,11 @@ ZSTDDIR= ${SRCTOP}/sys/contrib/zstd CFLAGS.zstd_compress.c+= -O0 .endif +# Work around lack of __bswap[sd]i2() intrinsics on riscv. Probably should be +# added to one of the runtime C libraries instead. +.if ${MACHINE_CPUARCH} == "riscv" +.PATH: ${ZSTDDIR}/lib/freebsd +SRCS+= zstd_kfreebsd.c +.endif + .include diff --git a/sys/contrib/zstd/lib/freebsd/zstd_kfreebsd.c b/sys/contrib/zstd/lib/freebsd/zstd_kfreebsd.c index 61c2fcbe417..22895b56631 100644 --- a/sys/contrib/zstd/lib/freebsd/zstd_kfreebsd.c +++ b/sys/contrib/zstd/lib/freebsd/zstd_kfreebsd.c @@ -27,8 +27,13 @@ */ #include "zstd_kfreebsd.h" +#include #include +#ifndef _KERNEL +#include +#endif + /* * The kernel as a standalone target does not link against libgcc or * libcompiler-rt. On platforms (e.g., MIPS and RISCV) that do not have a