riscv-software-src / riscv-software-src/opensbi

u54 opensbi does not compile with -Os flag

Open
#194 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.5k
Forks
712
PR merge metrics
No merged PRs in 30d

Description

I've changed this line to:

platform-cflags-y = -Os

Then, when I try to compile for the u54 board, I get the following error:

riscv64-unknown-elf/bin/ld: build/opensbi/platform/sifive/fu540/lib/libplatsbi.a(riscv_asm.o): in function `misa_string':
lib/sbi/riscv_asm.c:55: undefined reference to `memcpy'
collect2: error: ld returned 1 exit status
make: *** [platform/sifive/fu540/firmware/fw_dynamic.elf] Error 1

Any idea what could be causing this? I'm compiling for 64-bit riscv and using gcc 10.2.0. Note that this works with the other standard o flags like -O1 and -O3.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with platform/sifive/fu540/config.mk at the linked platform-cflags-y setting and lib/sbi/riscv_asm.c:55, then reproduce the u54 64-bit build using GCC 10.2.0 with -Os. Trace why the -Os build references memcpy while -O1 and -O3 link successfully; done means the u54 build completes with -Os without the undefined reference.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.