riscv-software-src / riscv-pk

RISC-V Proxy Kernel
Other
579 stars 306 forks source link

No explicit -lgcc #264

Closed ZenithalHourlyRate closed 2 years ago

ZenithalHourlyRate commented 2 years ago

For Clang/LLVM user with NO cross gcc installed, there is no libgcc available; At this time user can manually export LIBS=-lclang-rt.

For cross gcc user, -lgcc is usually added by the compiler thus there is no need to add this flag in config file. Only when -nostdlib/-nodefaultlibs is specified should we add -lgcc, which is not the case here.

This compiles on a machine with cross gcc installed and another machine with only clang. However, only rv64 is tested.

Note: ./configure not re-generated w.r.t #263

geekLucian commented 2 years ago

Check whether -lgcc exists via searching for function __ashlsi3.

It has been tested under rv32/64-gcc/clang and all can compile correctly.

aswaterman commented 2 years ago

Thanks!

aswaterman commented 2 years ago

Incidentally, none of my libgccs have __ashlsi3--which makes sense, since all RISC-V base ISAs have an instruction for left-shifting by 32 bits. So this doesn't work for me.

But all of my libgccs have __divdc3 (division of double _Complex), and ISA support for that operation is not forthcoming, so I'll use that.

aswaterman commented 2 years ago

Nevermind, that doesn't work for unrelated reasons. But I think searching for both __ashldi3 and __ashlti3 does work (the former suffices for RV32 and the latter for RV64).

aswaterman commented 2 years ago

Manually merged via c7e75bf944957e58f16531eb6b8d118a92069346