You seem to be invoking the native (x86_64 I presume) GCC instead of the RISC-V cross compiler.
Note at the top of the picture a bunch of messages that say “checking for riscv64-unknown-elf-XXX… no”. At least one of these checks must succeed, preferably the gcc one and perhaps also the g++ one as I think the code is C++. Because all failed, configure then tried to use the native x86_64-linux compiler, and the RISC-V gcc option -mcmodel=medany isn’t valid for the x86_64-linux compiler. You said you installed a riscv elf compiler. It probably has a slightly different name. If it is a compatible compiler to what spike needs, then making some links should work. If not compatible, then you may need to build your own riscv64-unknown-elf-gcc from scratch.