From patchwork Sat Sep 6 00:21:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 4856641 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9A4239F32F for ; Sat, 6 Sep 2014 00:22:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CA750201D3 for ; Sat, 6 Sep 2014 00:22:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EFBE82018B for ; Sat, 6 Sep 2014 00:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750913AbaIFAV6 (ORCPT ); Fri, 5 Sep 2014 20:21:58 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:65251 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750826AbaIFAV5 (ORCPT ); Fri, 5 Sep 2014 20:21:57 -0400 Received: by mail-pd0-f176.google.com with SMTP id w10so7356333pde.35 for ; Fri, 05 Sep 2014 17:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=converseincode.com; s=google; h=from:to:cc:subject:date:message-id; bh=xigv+dEO2/J4NH5mfiSPJC8EZIWzgZXvXhugHEnl5vA=; b=wVf67tx4CJAlrmYb1IwNZWJdYTtJD3Gmss+y7ySREJaUEDVx7Ne9x7/543hiHVmRYh Q14f1c+ChiHuBb0Gq6VZsk8hV/TCg5EPuJDUhmuOyuKNdTIi6EWj3mCszUvi+FZ6tA+2 +XiXy2rjOKphEBqBTKByw4RUySCFrb27Qt0Qs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xigv+dEO2/J4NH5mfiSPJC8EZIWzgZXvXhugHEnl5vA=; b=TncQtHkYX4TqOZzSHoSQCHjJqlJS00hnO8PBDW1Q5OUBC/eMza+JvQxTocA+RGTyvv zN33XVirsOMGHW0q02SZY7Ug+nEcVBKevGE6vW+dfGzzGeNYKTwQsSHIbBzIzpfPEiKr 6Apsf6ga7CQnEyuk6IWhuZn8PJTiWVoG4ebzuz0aOL0MnQxo4aqkKwm0bBT/Vk4cGTCO fhAcc+lp5ovlSppxssHe+yv7FG20XhUETe9+Q9UPZWW8nFhIpgSMfyZxRzbTfnZmU/eh WDX4enTndiu8dUQtkmFucfmXBSN90TB0MGQ6CcbQReB0v/tzCwdXZd5O6hSFD5mks5hO EedQ== X-Gm-Message-State: ALoCoQnWL0p5FOfnmNnmr/kqU/OnpZgo+JmwNV1yPjYLvdaBFFajSejxcz4GLhPB/LxRS77KfJ0n X-Received: by 10.66.227.71 with SMTP id ry7mr27035035pac.32.1409962916832; Fri, 05 Sep 2014 17:21:56 -0700 (PDT) Received: from galdor.websterwood.com (S0106dc9fdb80cffd.gv.shawcable.net. [96.50.97.138]) by mx.google.com with ESMTPSA id w8sm2703238pbs.7.2014.09.05.17.21.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Sep 2014 17:21:55 -0700 (PDT) From: behanw@converseincode.com To: mmarek@suse.cz Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Behan Webster Subject: [PATCH] kbuild, LLVMLinux: Add better clang cross build support Date: Fri, 5 Sep 2014 17:21:49 -0700 Message-Id: <1409962909-14660-1-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Behan Webster Add cross target to CC if using clang. Also add custom gcc toolchain path for fallback gcc tools. COMPILER is previously set to "clang" if CC=clang was set from the make command line. So -target and -gcc-toolchain can be added to CC, since we already know that it is set. Clang will fallback to using things like ld, as, and libgcc if (respectively) one of the llvm linkers isn't available, the integrated assembler is turned off, or an appropriately cross-compiled version of compiler-rt isn't available. To this end, you can specify the path to this fallback gcc toolchain with GCC_TOOLCHAIN. Signed-off-by: Behan Webster --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 2893d7f..c772619 100644 --- a/Makefile +++ b/Makefile @@ -360,7 +360,16 @@ include $(srctree)/scripts/Kbuild.include # Make variables (CC, etc...) AS = $(CROSS_COMPILE)as LD = $(CROSS_COMPILE)ld +ifeq ($(COMPILER),clang) +ifneq ($(CROSS_COMPILE),) +CC += -target $(CROSS_COMPILE:%-=%) +endif +ifneq ($(GCC_TOOLCHAIN),) +CC += -gcc-toolchain $(GCC_TOOLCHAIN) +endif +else CC = $(CROSS_COMPILE)gcc +endif CPP = $(CC) -E AR = $(CROSS_COMPILE)ar NM = $(CROSS_COMPILE)nm