diff --git a/benchmarks/Makefile b/benchmarks/Makefile index fb0d2977d..cd3c975bd 100644 --- a/benchmarks/Makefile +++ b/benchmarks/Makefile @@ -38,8 +38,8 @@ bmarks = \ RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf- RISCV_GCC ?= $(RISCV_PREFIX)gcc RISCV_GCC_OPTS ?= -DPREALLOCATE=1 -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf -RISCV_LINK ?= $(RISCV_GCC) -T $(src_dir)/common/test.ld $(incs) -RISCV_LINK_OPTS ?= -static -nostdlib -nostartfiles -lm -lgcc -T $(src_dir)/common/test.ld +RISCV_LINK ?= $(RISCV_GCC) -Wl,-T,$(src_dir)/common/test.ld $(incs) +RISCV_LINK_OPTS ?= -static -nostdlib -nostartfiles -lm -lgcc -Wl,-T,$(src_dir)/common/test.ld RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data RISCV_SIM ?= spike --isa=rv$(XLEN)gc diff --git a/benchmarks/common/syscalls.c b/benchmarks/common/syscalls.c index 39547b3d0..cc43c9081 100644 --- a/benchmarks/common/syscalls.c +++ b/benchmarks/common/syscalls.c @@ -93,9 +93,11 @@ int __attribute__((weak)) main(int argc, char** argv) return -1; } +// Must be global for compatibility with Clang +register void* thread_pointer asm("tp"); + static void init_tls() { - register void* thread_pointer asm("tp"); extern char _tdata_begin, _tdata_end, _tbss_end; size_t tdata_size = &_tdata_end - &_tdata_begin; memcpy(thread_pointer, &_tdata_begin, tdata_size); @@ -356,19 +358,19 @@ int printf(const char* fmt, ...) return 0; // incorrect return value, but who cares, anyway? } +static void sprintf_putch(int ch, void** data) +{ + char** pstr = (char**)data; + **pstr = ch; + (*pstr)++; +} + int sprintf(char* str, const char* fmt, ...) { va_list ap; char* str0 = str; va_start(ap, fmt); - void sprintf_putch(int ch, void** data) - { - char** pstr = (char**)data; - **pstr = ch; - (*pstr)++; - } - vprintfmt(sprintf_putch, (void**)&str, fmt, ap); *str = 0;