-
Notifications
You must be signed in to change notification settings - Fork 18
fail if LLVM not configured to target certain backend #209
Comments
While I think that we could add this to this repo, it is probably worth adding to the kernel source directly. Although all distros build clang with all of the backends enabled, more specialized versions like the one that tc-build creates won't. Something like Android's target check maybe? |
It's possible to just grep for specific architecture from
|
I don’t think that is any cleaner than just trying to run:
with a shell script like Android does. In fact, we could probably use this justification to upstream that Android patch. It would be easy to combine these two checks into one script. I’ll try to prototype something tonight. |
Hmmm, maybe not because I am sure upstream would want a different error message based on what is failing (target not being valid or target being an Android target) and I can't really think of a clean way to do that right now. I'll still draft up a patch for the original issue soon. |
Doubling back to low hanging fruit. This works: diff --git a/Makefile b/Makefile
index 16d8271192d1..84e75d856cd9 100644
--- a/Makefile
+++ b/Makefile
@@ -528,6 +528,9 @@ endif
ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
ifneq ($(CROSS_COMPILE),)
CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
+ifneq ($(shell $(srctree)/scripts/clang-target.sh $(CC) $(CLANG_FLAGS)),)
+$(error "$(CC) does not support $(CLANG_FLAGS), please make sure $(CC) has backend support for selected target")
+endif
GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)
GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
diff --git a/scripts/clang-target.sh b/scripts/clang-target.sh
new file mode 100755
index 000000000000..1a2590581339
--- /dev/null
+++ b/scripts/clang-target.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+echo | $@ -c -x c - -o /dev/null >/dev/null 2>&1 || echo n
Not sure if it is worth adding that to the build system or just making it a part of |
I usually build llvm with:
which makes testing mipsel locally with driver.sh error in non-sensical ways. It might be a slight improvement for an edge case to test that clang has been configured to target these. Probably don't need to check all of these tools (theoretically you could have some crazy combo of different clang and lld with differing target support).
Not a priority though.
The text was updated successfully, but these errors were encountered: