From patchwork Wed May 2 08:37:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 907383 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40bWzv4qwtz9s1d for ; Wed, 2 May 2018 18:44:43 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nZcfcSdV"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40bWzv39HjzF2Sc for ; Wed, 2 May 2018 18:44:43 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nZcfcSdV"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::244; helo=mail-pf0-x244.google.com; envelope-from=joel.stan@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nZcfcSdV"; dkim-atps=neutral Received: from mail-pf0-x244.google.com (mail-pf0-x244.google.com [IPv6:2607:f8b0:400e:c00::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40bWsc5F78zF2SV for ; Wed, 2 May 2018 18:39:16 +1000 (AEST) Received: by mail-pf0-x244.google.com with SMTP id j5so11184253pfh.2 for ; Wed, 02 May 2018 01:39:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=d/dR7BVl7uz2lcY74E/KWhXvdxASgWrX4n+xIFhnrwU=; b=nZcfcSdVMnAP0+mqL7IUvR41+CGBtLcsC0OfRSda1A8tI3U8qTLFddvJTPpyuNBp7O xrmTvmJ7h7mf2YALvB87f688Abjdugp+xFO3U5wTOao7wWijLkrbEL32vbq/FMmPulrp GbFJUGaI3pbpRoKvklKe9gf6teSPxqX9TAykCo18C0X+sTRvMzlfzHNPPhDv7NVp2UF3 1lN/AphZ6aE/ueCdY/U477+HHP+EjXP8yz9V+RtpCghnabw3mJk52iDuuElnXBkftbC0 iomHONJxpkcgMTOuI5eeGHyyq/GbcoSLcLx1/OKr1SghtcjyBTH0dg/MHlnpSArvkoyr mkhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=d/dR7BVl7uz2lcY74E/KWhXvdxASgWrX4n+xIFhnrwU=; b=CaqezHRfNxvi+DAVK+QVKXbVQO9lU3llJUreiQ7NIXdtfyx+IvEYFW2ZhGluTMJoeT 7zOL5vwKmaMD+QhrGr28UCucNxHukyKAyx0XbZjGMOeGDzsEm0iL2tqM+p7TaKhntypa tLSMY9RBbkM6vvHF3vSsyX/f2oFv9ANBcWxiQm2SAdLR7MIspdIMzhTSVIYdCSsz2spb CbmhYkssEdx2wIBZYZ0ovQAUTFbMsrcfFpvTjDrFJNjtdruJSkJ0rmcWxSzNxJyyro3x Y8rBnhYaIKN1hURU0DU1cMxZVBpjKmgiNAnjaNKuVk1DZSpG0VuST8s1AIXNfrVTcHhm p4dg== X-Gm-Message-State: ALQs6tDbQVyoLeNzknOfZtvHuInbmsZ9kKot9AGqGzpsWj+iE73a83pb 2RK0Znx1APiTba2eUw9SLi1qdsze X-Google-Smtp-Source: AB8JxZpaJ7FPktz9RpJ6awpmVIWoQxJ6U5PcFdIIZeWyQd91GmZYiKXbDwT07QpcRuOhdKr2kxkfJw== X-Received: by 2002:a63:b70b:: with SMTP id t11-v6mr14984892pgf.193.1525250354602; Wed, 02 May 2018 01:39:14 -0700 (PDT) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id b26sm23941510pfn.73.2018.05.02.01.39.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 May 2018 01:39:13 -0700 (PDT) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Wed, 02 May 2018 18:09:09 +0930 From: Joel Stanley To: skiboot@lists.ozlabs.org Date: Wed, 2 May 2018 18:07:52 +0930 Message-Id: <20180502083753.25090-13-joel@jms.id.au> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180502083753.25090-1-joel@jms.id.au> References: <20180502083753.25090-1-joel@jms.id.au> Subject: [Skiboot] [PATCH 12/13] Makefile: Add additional flags when using clang X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Clang needs to be told which target it's building for, as unlike GCC the one binary targets many architectures. Signed-off-by: Joel Stanley --- Makefile.main | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Makefile.main b/Makefile.main index 0a818a71f6b7..cd4b9161b665 100644 --- a/Makefile.main +++ b/Makefile.main @@ -21,6 +21,8 @@ try = $(shell set -e; if ($(1)) >/dev/null 2>&1; \ try-cflag = $(call try,$(1) $(2) -x c -c /dev/null -o /dev/null,$(2)) test_cflag = $(call try,$(1) $(2) -x c -c /dev/null -o /dev/null,1,0) +cc-name := $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) + # Base warnings CWARNS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -Werror-implicit-function-declaration -Wdeclaration-after-statement \ @@ -143,6 +145,27 @@ else AFLAGS += $(call try-cflag,$(CC),-mabi=elfv1) endif +ifeq ($(cc-name),clang) +ifneq ($(CROSS),) +CLANG_TARGET := --target=$(notdir $(CROSS:%-=%)) +GCC_TOOLCHAIN := $(realpath $(dir $(shell which $(LD)))/..) +endif +ifneq ($(GCC_TOOLCHAIN),) +CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN) +endif +CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) +AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) +CFLAGS += $(call cc-option, -no-integrated-as) +AFLAGS += $(call cc-option, -no-integrated-as) + +LDFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) + +CFLAGS += -mcpu=pwr8 +LDFLAGS += -mcpu=pwr8 +ASFLAGS += -mcpu=pwr8 + +endif + # Special tool flags: # Do not use the floating point unit CFLAGS += -msoft-float