Makefile: Support building with Clang and LLVM binutils
authorJessica Clarke <jrtc27@jrtc27.com>
Sun, 11 Jul 2021 02:28:23 +0000 (03:28 +0100)
committerAnup Patel <anup@brainfault.org>
Sun, 11 Jul 2021 14:52:55 +0000 (20:22 +0530)
commit2942777425516f7b31181fbaecc5485263dfcb01
treea10f1590a8893b676af64b3f0f4d20560e67f646
parent09ad811ec4661b99a67b87f28c93177367ae911e
Makefile: Support building with Clang and LLVM binutils

This is intended to mirror the Linux kernel. Building with CC=clang will
use Clang as the compiler but default to using the existing binutils.
Building with LLVM=1 will default to using Clang and LLVM binutils.

Whilst GCC will accept the -N linker option and forward it on to the
linker, Clang will not, and so in order to support both compilers we
must use -Wl, to forward it to the linker as is required for most other
linker options.

Note that there is currently a bug when using Clang as the compiler and
riscv64-linux-gnu-ld as the linker for FW_PIC=y. At first glance this
appears to be a bug in GNU binutils, but this could also be Clang or
OpenSBI at fault in some subtle way. Thus, for now, advise that this
combination be avoided.

Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Tested-by: Anup Patel <anup.patel@wdc.com>
Makefile
README.md