RISC-V Embedded GCC issue with dhrystone

449 views
Skip to first unread message

Antti Lukats

unread,
Oct 17, 2018, 3:27:56 PM10/17/18
to RISC-V SW Dev
Hi,

when using the precompiled embedded GCC from here


then I do get errors when selecting RV32I and compiling dhrystone from riscv, this seems like the "multilib" issue, any hints what to-do? supply own 

__umoddi3

functions?
or is it really requried that recompile the GCC from sources? I hoped that the toolchain is compiled properly..

br
Antti Lukats


Tommy Murphy

unread,
Oct 17, 2018, 4:17:25 PM10/17/18
to Antti Lukats, RISC-V SW Dev
You'll probably need to show how you're compiling.
In particular the -march and -mabi options used.
It could be that you're using an arch/abi tuple not supported by the multilibs included with that build of the tools.



Jim Wilson

unread,
Oct 17, 2018, 4:27:09 PM10/17/18
to antti....@gmail.com, RISC-V SW Dev
On Wed, Oct 17, 2018 at 12:27 PM Antti Lukats <antti....@gmail.com> wrote:
> when using the precompiled embedded GCC from here
> https://gnu-mcu-eclipse.github.io/toolchain/riscv/
> then I do get errors when selecting RV32I and compiling dhrystone from riscv, this seems like the "multilib" issue, any hints what to-do? supply own
> __umoddi3
> functions?

__umoddi3 should come from libgcc. GCC will add a -lgcc by default,
but if you are linking by hand you might have forgotten to include it.
umoddi3 is the unsigned 64-bit integer modulus (%) operation. A
64-bit toolchain will use an instruction. A 32-bit toolchain will
call the __umoddi3 function from libgcc. So a 64-bit target may link
without -lgcc, but a 32-bit target will not.

Jim

Antti Lukats

unread,
Oct 18, 2018, 4:04:19 AM10/18/18
to RISC-V SW Dev, antti....@gmail.com
I am trying to compile dhrystone for the sole purpose of RISCV softCore contest rules compliance/benchmark
I do use the smallest possible configuration of the cpu, and strart the official toolchain by

..\bin\riscv-none-embed-gcc.exe -march=rv32i -mabi=ilp32 -DPREALLOCATE=1 -mcmodel=medany -static -nostdlib --std=gnu99 -O3 -ffast-math -fno-common -fno-builtin-printf -Wl,-static,-nostdlib,-nostartfiles,-lm,-lgcc,-T test.ld crt.S syscalls.c dhrystone.c dhrystone_main.c

as you can see 
-lgcc 
is there

when selecting rv32im the number offer goes smaller but one error type still comes.

CRT.S and syscalls are from riscv benchmarking

br
Antti

Liviu Ionescu

unread,
Oct 18, 2018, 5:16:32 AM10/18/18
to Antti Lukats, RISC-V SW Dev


> On 18 Oct 2018, at 11:04, Antti Lukats <antti....@gmail.com> wrote:
>
> I am trying to compile dhrystone for the sole purpose of RISCV softCore contest rules compliance/benchmark
> I do use the smallest possible configuration of the cpu, and strart the official toolchain by
>
> ..\bin\riscv-none-embed-gcc.exe -march=rv32i -mabi=ilp32 -DPREALLOCATE=1 -mcmodel=medany -static -nostdlib --std=gnu99 -O3 -ffast-math -fno-common -fno-builtin-printf -Wl,-static,-nostdlib,-nostartfiles,-lm,-lgcc,-T test.ld crt.S syscalls.c dhrystone.c dhrystone_main.c

to diagnose this, I would split the build into separate compile and link steps, and add a -v to the link step, to see exactly what it is done.


regards,

Liviu

Nelson Ribeiro

unread,
Oct 18, 2018, 5:27:21 AM10/18/18
to Liviu Ionescu, antti....@gmail.com, RISC-V SW Dev
Hi.

For other cpu targets, in the past, when I used the switches "-nostdlib,-nostartfiles" I had to supply my own arithmetic functions like "__umodxxx".

Is "-nostdlib" compatible with "-lgcc"?

Nelson Ribeiro

--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/0AC9D46A-C8FE-41D3-B0E8-6EB6E745CD68%40livius.net.

Antti Lukats

unread,
Oct 18, 2018, 6:13:51 AM10/18/18
to RISC-V SW Dev, i...@livius.net, antti....@gmail.com

On Thursday, 18 October 2018 11:27:21 UTC+2, ngrr.ribeiro wrote:
Hi.

For other cpu targets, in the past, when I used the switches "-nostdlib,-nostartfiles" I had to supply my own arithmetic functions like "__umodxxx".

Is "-nostdlib" compatible with "-lgcc"?


those folks compile with such options at least, hm but maybe they also fail in RV32I ?

Antti 

Antti Lukats

unread,
Oct 18, 2018, 6:46:40 AM10/18/18
to RISC-V SW Dev, i...@livius.net, antti....@gmail.com
it seems there issue is all around, there are many reports about the same issue, easy solution is

to include 
muldi.S
div.S

this gets a bit further, still some unexplained not found symbol but that comes from syscalls and not from dhrystone code itself

br
Antti

Jim Wilson

unread,
Oct 18, 2018, 11:06:10 AM10/18/18
to Antti Lukats, RISC-V SW Dev
On Thu, Oct 18, 2018 at 1:04 AM Antti Lukats <antti....@gmail.com> wrote:
> ..\bin\riscv-none-embed-gcc.exe -march=rv32i -mabi=ilp32 -DPREALLOCATE=1 -mcmodel=medany -static -nostdlib --std=gnu99 -O3 -ffast-math -fno-common -fno-builtin-printf -Wl,-static,-nostdlib,-nostartfiles,-lm,-lgcc,-T test.ld crt.S syscalls.c dhrystone.c dhrystone_main.c

The -lm -lgcc must be at the end of the compiler command line. Unix
style libraries are only used to satisfy undefined symbol references.
If you put a library first on the link line, there will be no
undefined references at the time that the linker looks at the library,
and hence no symbols will be pulled from the library.

"-Wl,-T test.ld" isn't a valid option combination. This is only
working by accident. This should either be "-Wl,-T,test.ld" or else
just "-T test.ld" because the compiler driver does know about the
linker -T option and will handle it correctly.

You used -static twice. You only need to pass it to the compiler, and
the compiler will then pass it to the linker.

You are passing -nostartfiles to the linker, but it is a compiler
option not a linker option.

Jim

Antti Lukats

unread,
Oct 18, 2018, 12:22:40 PM10/18/18
to RISC-V SW Dev, antti....@gmail.com
thank you and sorry -

I did not think of something so simple and stupid - all errors gone.

br
Antt
Reply all
Reply to author
Forward
0 new messages