Unable to compile Uboot using Sifive toolchain

Hi I tried compiling uboot using Sifive toolchain, and got the following error ( I can compile using other 3rd party toolchain like xpack) don’t know why Sifive toolchain is giving an error)

CC lib/vsprintf.o
AS lib/efi_loader/efi_crt0.o
CC lib/efi_loader/efi_reloc.o
CC lib/strto.o
CC lib/efi_loader/efi_freestanding.o
CC lib/date.o
LD lib/efi_loader/helloworld_efi.so
riscv64-unknown-elf-ld.bfd: warning: -z nocombreloc ignored
riscv64-unknown-elf-ld.bfd: -shared not supported
scripts/Makefile.lib:394: recipe for target ‘lib/efi_loader/helloworld_efi.so’ failed
make[2]: *** [lib/efi_loader/helloworld_efi.so] Error 1
make[2]: *** Waiting for unfinished jobs…
scripts/Makefile.build:432: recipe for target ‘lib/efi_loader’ failed
make[1]: *** [lib/efi_loader] Error 2
make[1]: *** Waiting for unfinished jobs…
LD lib/libfdt/built-in.o
Makefile:1698: recipe for target ‘lib’ failed
make: *** [lib] Error 2

Procedure:
I set up the build variables as follows:

export ARCH=riscv
export PATH=“$PATH:/home/fahad/Documents/sorted/risc_v/FreedomStudio-2019-08-1-lin64/SiFive/riscv64-unknown-elf-gcc-8.3.0-2019.08.0/bin”
export CROSS_COMPILE=riscv64-unknown-elf-

Used the following commands to compile uboot:

  1. make sifive_fu540_defconfig
  1. make

However using another toolchain it works, seems to me either I am missing something or this may be a bug that -shared flag is not supported

Thanks,
Fahad

The embedded elf toolchain doesn’t have shared library support, as no one has written the necessary RISC-V newlib support for shared libraries yet. Maybe you need to use a linux toolchain to compile uboot? It looks like our makefiles use a linux toolchain for uboot builds.

I think that these are different things, the toolchain should be able to produce shared libraries, regardless of the capabilities of newlib. The xPack GNU RISC-V Embedded GCC does this, as his sibling, the xPack GNU Arm Embedded GCC, does.

Loading shared libraries is another story, and in embedded environments this is application specific, since you can load them from different locations, like an external file system, but also from flash, directly or even from a simple r/o flash file system.

Thanks @jimw. As a workaround I switched to xpack toolchain for compiling uboot, and that worked as it has PIE support, I guess same will be true for other Linux based tool-chains.