From 6dcd3bb8ffe7fb9cf09895b6e76675279aad320f Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Thu, 11 Feb 2021 17:11:46 +0100 Subject: [PATCH] build system: support wrong target triples with LLVM clang/LLVM is a bit more finicky with what target triples it accepts compared to GCC. However, the GCC target triple is needed to properly locate the C libraries. In case a locally installed GCC toolchain uses a technically not fully correct target triple, it might be impossible to build with LLVM. The solution here is to allow specifying a TARGET_ARCH_LLVM target triple (which defaults to TARGET_ARCH), which is passed to clang. For locating the C lib, still TARGET_ARCH is used. --- makefiles/toolchain/llvm.inc.mk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/makefiles/toolchain/llvm.inc.mk b/makefiles/toolchain/llvm.inc.mk index 9898f10f86..001aa00e11 100644 --- a/makefiles/toolchain/llvm.inc.mk +++ b/makefiles/toolchain/llvm.inc.mk @@ -51,15 +51,16 @@ gcc_include_dirs = $(realpath \ ) ifneq (,$(TARGET_ARCH)) + TARGET_ARCH_LLVM ?= $(TARGET_ARCH) ifeq (,$(CFLAGS_CPU)) $(error CFLAGS_CPU must have been defined to use `llvm`.) endif # Tell clang to cross compile - CFLAGS += -target $(TARGET_ARCH) - CXXFLAGS += -target $(TARGET_ARCH) + CFLAGS += -target $(TARGET_ARCH_LLVM) + CXXFLAGS += -target $(TARGET_ARCH_LLVM) # We currently don't use LLVM for linking (see comment above). - # LINKFLAGS += -target $(TARGET_ARCH) + # LINKFLAGS += -target $(TARGET_ARCH_LLVM) # Clang on Linux uses GCC's C and C++ headers and libstdc++ (installed with GCC)