riscv: Set MACHINE_ARCH correctly

MACHINE_ARCH sets the hw.machine_arch sysctl in the kernel. In userspace
it sets MACHINE_ARCH in bmake, which bsd.cpu.mk uses to configure the
target ABI for ports.

For riscv64sf builds (i.e. soft-float) that needs to be riscv64sf, but
the sysctl didn't reflect that. It is static.

Set the define from the riscv makefile so that we correctly reflect our
actual build (i.e. riscv64 or riscv64sf), depending on what TARGET_ARCH
we were built with.

That still doesn't satisfy userspace builds (e.g. bmake), so check if
we're building with a software-floating point toolchain there. That
check doesn't work in the kernel, because it never uses floating point.

Reviewed by:	philip (previous version), mhorne
Sponsored by:	Axiado
Differential Revision:	https://reviews.freebsd.org/D23741
This commit is contained in:
Kristof Provost 2020-02-22 13:23:27 +00:00
parent 5a79fd8574
commit 6ebb17dfa7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=358247
2 changed files with 6 additions and 0 deletions

View File

@ -46,6 +46,8 @@ SYSTEM_LD= @${LD} -N -m ${LD_EMULATION} -Bdynamic -T ${LDSCRIPT} ${_LDFLAGS} \
CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
.endif
CFLAGS += -DMACHINE_ARCH=\"${TARGET_ARCH}\"
# hack because genassym.c includes sys/bus.h which includes these.
genassym.o: bus_if.h device_if.h

View File

@ -46,8 +46,12 @@
#define MACHINE "riscv"
#endif
#ifndef MACHINE_ARCH
#ifdef __riscv_float_abi_soft
#define MACHINE_ARCH "riscv64sf"
#else
#define MACHINE_ARCH "riscv64"
#endif
#endif
#ifdef SMP
#ifndef MAXCPU