sifive / freedom-u540-c000-bootloader

Freedom U540-C000 Bootloader Code
Other
85 stars 39 forks source link

Compile without a C library #26

Open esmil opened 4 years ago

esmil commented 4 years ago

This repo already contain implementations of memset, memcy, strcmp and strlen, so we just need our own copy of string.h to be able to use -ffreestanding.

This also means we can compile with a riscv64-linux-gnu toolchain which just an apt-get/dnf install/etc. away on most Linux distros.

I've tested this built with both riscv64-unknown-elf and riscv64-linux-gnu toolchains and my HFU still boots.

wgrant commented 4 years ago

I also needed CFLAGS += -fno-pic and LDFLAGS += -static to build on Ubuntu's riscv64 port.

esmil commented 4 years ago

Interesting. I just tried without on Bionic and it seems to build fine for me. But I don't mind adding it if it fixes stuff in your end and you've verified the output still works.

xnox commented 3 years ago

Interesting. I just tried without on Bionic and it seems to build fine for me. But I don't mind adding it if it fixes stuff in your end and you've verified the output still works.

yes please add -fno-pic many Linux distributions default toolchain to use PIE by default. The toolchains should be turning that off when freestanding specified, but sometimes that is buggy. Irrespective of what the toolchain/distro defaults are, building with -fno-pic is the right choice here, hence it is best to be explicit about it irrespective of what the toolchain defaults are.