#!/bin/sh

# This crashes a SpacemiT K3 system running a kernel from Linus's tree (even
# when ran from a KVM guest). This however doesn't happen with the vendor
# kernel.
#
# The issue doesn't happen on a SpacemiT K1 system running the same kernel.
#
# It uses a glibc build from git as the following commit is required for the crash to happen:
# commit 512f99e71d57db800a0e2bc0c8f9f0600dea5ed7
# Author: Yao Zihong <zihong.plct@isrc.iscas.ac.cn>
# Date:   Thu Jun 4 19:34:33 2026 -0500
# 
#     riscv: Add RVV memchr for both multiarch and non-multiarch builds
#     
#     This patch adds an RVV-optimized implementation of memchr for RISC-V and
#     enables it for both multiarch (IFUNC) and non-multiarch builds.
#     
#     The implementation integrates Hau Hsu's 2023 RVV work under a unified
#     ifunc-based framework. A vectorized version (__memchr_vector) is added
#     alongside the generic fallback (__memchr_generic). The runtime resolver
#     selects the RVV variant when RISCV_HWPROBE_KEY_IMA_EXT_0 reports vector
#     support (RVV).
#     
#     Currently, the resolver still selects the RVV variant even when the RVV
#     extension is disabled via prctl(). As a consequence, any process that
#     has RVV disabled via prctl() will receive SIGILL when calling memchr().
#     
#     Co-authored-by: Hau Hsu <hau.hsu@sifive.com>
#     Co-authored-by: Jerry Shih <jerry.shih@sifive.com>
#     Signed-off-by: Yao Zihong <zihong.plct@isrc.iscas.ac.cn>
#     Reviewed-by: Peter Bergner <bergner@tenstorrent.com>

I18NPATH=. ./ld-linux-riscv64-lp64d.so.1 --library-path . ./localedef -c -f UTF-8 -i C ./C.utf8
