]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
kbuild: Add clang detection
authorTom Rini <trini@konsulko.com>
Wed, 20 Jan 2016 01:39:01 +0000 (20:39 -0500)
committerTom Rini <trini@konsulko.com>
Mon, 25 Jan 2016 15:39:44 +0000 (10:39 -0500)
Adapted from:

>From 5631d9c429857194bd55d7bcd8fa5bdd1a9899a3 Mon Sep 17 00:00:00 2001
From: Michal Marek <mmarek@suse.com>
Date: Wed, 19 Aug 2015 17:36:41 +0200
Subject: [PATCH 1/1] kbuild: Fix clang detection

We cannot detect clang before including the arch Makefile, because that
can set the default cross compiler. We also cannot detect clang after
including the arch Makefile, because powerpc wants to know about clang.
Solve this by using an deferred variable. This costs us a few shell
invocations, but this is only a constant number.

Reported-by: Behan Webster <behanw@converseincode.com>
Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Michal Marek <mmarek@suse.com>
in the Linux kernel.

This will allow us to make better decisions about when to run tests
later on for gcc features.

Signed-off-by: Tom Rini <trini@konsulko.com>
scripts/Kbuild.include

index 98e09ce5fbf16f03fff204d2aa11aff0e36bd463..30e6e316ac1b2565f13436f2d81a2230e1fe5bfc 100644 (file)
@@ -130,6 +130,10 @@ cc-option-align = $(subst -functions=0,,\
 cc-disable-warning = $(call try-run,\
        $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
 
+# cc-name
+# Expands to either gcc or clang
+cc-name = $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc)
+
 # cc-version
 cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))