Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System gcc fixes #8

Merged
merged 2 commits into from
Nov 29, 2021
Merged

Conversation

shenki
Copy link

@shenki shenki commented Nov 29, 2021

This allows me to use the riscv toolchain and riscv picolibc shipped by Debian. I tested with the version in testing (1.7.4-1 for picolibc).

apt install picolibc-riscv64-unknown-elf gcc-riscv64-unknown-elf

This assumes the user has the picolibc package installed if the compiler is riscv64-unknown-elf. That may not be always true, so I am open to alternate suggestions.

Using a compiler with a spec file that conditionally includes it's own
linker script broke linking:

 /usr/lib/riscv64-unknown-elf/bin/ld:../../../../sw/ld/linker.ld:29: nonconstant expression for load base
 collect2: error: ld returned 1 exit status

It appears something in the generic riscv linker script that picolibc
ships (/usr/lib/picolibc/riscv64-unknown-elf/lib/picolibc.ld) is
conflicting with our customer linker script.

The link section of the spec file has this:

 %{!T:-Tpicolibc.ld}

So if we pass `-T` to GCC instead of `-Wl,--script`, the compiler will
use our linker script over the spec file.

Signed-off-by: Joel Stanley <joel@jms.id.au>
The riscv64-unknown-elf toolchain is (can be?) the system installed
riscv compiler. On Debian (and Ubuntu?) this does not default to a libc;
you must specify the spec file to use. Without doing this the build
fails:

 make: Entering directory '/home/joel/dev/fpgas/oc/foboot/hw/build/software/bios'
  CC       ../../../../sw/src/dfu.c	dfu.o
 ../../../../sw/src/dfu.c:25:10: fatal error: string.h: No such file or directory
 #include <string.h>
          ^~~~~~~~~~

As Debian ships a riscv picolibc package, use this.

Signed-off-by: Joel Stanley <joel@jms.id.au>
@shenki shenki changed the base branch from master to OrangeCrab November 29, 2021 08:54
@gregdavill gregdavill merged commit c0836b9 into gregdavill:OrangeCrab Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants