# This resolves the LTO issue when compiling a static library from C code in a Cargo crate
# Ref: https://gitlab.archlinux.org/archlinux/packaging/packages/pacman/-/issues/20
abinfo "Appending -ffat-lto-objects to workaround linkage failure ..."
CFLAGS="${CFLAGS} -ffat-lto-objects"

if ab_match_arch riscv64; then
	abinfo "Adding libatomic for riscv64 ..."
	export RUSTFLAGS="${RUSTFLAGS} -Clink-arg=-latomic"
fi

if ab_match_arch arm64; then
	abinfo "Set jemalloc page size for arm64 ..."
	export JEMALLOC_SYS_WITH_LG_PAGE=16
	export JEMALLOC_SYS_WITH_LG_HUGEPAGE=25
fi
