edward-jones added a comment.

In D68407#1732685 <https://reviews.llvm.org/D68407#1732685>, @lenary wrote:

> This patch is looking much better, thanks for updating it.
>
> Please may you clarify what RISC-V gcc does for `-lgcc`, `-lgcc_s`, 
> `-lgcc_eh`? Is it different to what gcc does on other targets? Being closer 
> to matching the linker arguments that gcc provides to ld seems like a good 
> idea, IMO.


The default behaviour on RISC-V GCC is just `-lgcc`, however for Clang if I 
call `tools::AddRunTimeLibs` then by default I get `-lgcc --as-needed -lgcc_s 
--no-as-needed` in the link step.

When libgcc is needed `tools::AddRunTimeLibs` unconditionally calls 
`AddUnwindLibrary`, which in turn calls `ToolChain::GetUnwindLibType` which 
always returns `ToolChain::UNW_Libgcc` for libgcc. The code in 
`AddUnwindLibrary` will then always add either `-lgcc_eh` (for a static 
libgcc), or `-lgcc_s` (for a shared libgcc) to the command line. I can override 
this by reimplementing `ToolChain::GetUnwindLibType` in the target and making 
it return `ToolChain::UNW_None`, but I'm not sure whether that's the desired 
behavior.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68407/new/

https://reviews.llvm.org/D68407



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to