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

Linker failure when running 'make BOARD=blackice-ii' #17

Open
philtomson opened this issue Dec 13, 2020 · 1 comment
Open

Linker failure when running 'make BOARD=blackice-ii' #17

philtomson opened this issue Dec 13, 2020 · 1 comment

Comments

@philtomson
Copy link
Contributor

$ make BOARD=blackice-ii
riscv64-unknown-elf-gcc -march=rv32i -mabi=ilp32 -Wall -Wextra -pedantic -DFREQ=48000000 -Os -ffreestanding -nostartfiles -g -Iprograms/hello -c -o programs/hello/main.o programs/hello/main.c
cp start-ram.s start.s
riscv64-unknown-elf-as -march=rv32i -mabi=ilp32 -o start.o start.s
cp arch/ice40-ram.lds progmem.lds
riscv64-unknown-elf-gcc -march=rv32i -mabi=ilp32 -Wall -Wextra -pedantic -DFREQ=48000000 -Os -ffreestanding -nostartfiles -g -Iprograms/hello -Wl,-Tprogmem.lds -o progmem programs/hello/main.o start.o
start.o: In function .L0 ': (.text+0x4): relocation truncated to fit: R_RISCV_PCREL_LO12_I against .L0 '
collect2: error: ld returned 1 exit status
Makefile:48: recipe for target 'progmem' failed
make: *** [progmem] Error 1

@philtomson
Copy link
Contributor Author

philtomson commented Dec 18, 2020

First problem was that I was using a riscv-gnu-toolchain built in 2018 (I think that was causing the linking problem for some reason).

Then the problem was that I had built riscv-gnu-toolchain wrong using the default params to the configure script. I built it using the following configure params and things worked fine (after removing all of the previously built toolchain - I ended up doing 'rm -rf /opt/riscv' to make sure.

When building the riscv-gnu-toolchain you should configure with:
$ ./configure --prefix=/opt/riscv --with-arch=rv32i --with-abi=ilp32

(might be good to add a note in the README.md at the part about needing to build the riscv-gnu-toolchain)

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

No branches or pull requests

1 participant