From patchwork Sat Jul 19 01:34:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vinicius Tinti X-Patchwork-Id: 4588611 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 CE4109F37C for ; Sat, 19 Jul 2014 01:35:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0329220108 for ; Sat, 19 Jul 2014 01:35:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2064E200ED for ; Sat, 19 Jul 2014 01:35:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758259AbaGSBfJ (ORCPT ); Fri, 18 Jul 2014 21:35:09 -0400 Received: from mail-yh0-f50.google.com ([209.85.213.50]:47935 "EHLO mail-yh0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757378AbaGSBfI (ORCPT ); Fri, 18 Jul 2014 21:35:08 -0400 Received: by mail-yh0-f50.google.com with SMTP id v1so2754599yhn.23 for ; Fri, 18 Jul 2014 18:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=LResLH7LOcvDro7GyyRUIpGT1AyhUymGV9AlZYAucCA=; b=UIsXcq6NN2O3biUpgJYZ23xnlLpd9DbRg4tHyZ8+Sdg3+5rURJBxQ2FoOihD/fGcvu MQoBvrSFhLEa9lFbrWBIBAcjF1/f2Ex2KzeKHbKYzF8fkKPY0LRbolyZhxpv/napsvkA gCEhtGGYvPfZ8POIzC1mP3cztGhwye8zm6NIe86b/IVezjRm6viyDwE5gG5cZybIsUhT 8N+jD0dPz4C0nbGQa+8HgrcqmP1SEYuQup1/7508Y/NVcMBIvMkgs6jF36zs5yz59PLg r2mmlorVJLzoJsJPvxkPlTjFaSDLuKNwDUUQkE4/lYgYiMcmWT2V0LWHsK5DFyDdjc4m k7Wg== X-Received: by 10.236.120.110 with SMTP id o74mr13022329yhh.67.1405733707649; Fri, 18 Jul 2014 18:35:07 -0700 (PDT) Received: from localhost.localdomain ([186.213.64.87]) by mx.google.com with ESMTPSA id v25sm13988321yhi.21.2014.07.18.18.35.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Jul 2014 18:35:06 -0700 (PDT) From: =?UTF-8?q?Vin=C3=ADcius=20Tinti?= To: Michal Marek Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Vin=C3=ADcius=20Tinti?= , Behan Webster Subject: [PATCH] kbuild: add support to generate LLVM bitcode files Date: Fri, 18 Jul 2014 22:34:37 -0300 Message-Id: <1405733677-16650-1-git-send-email-viniciustinti@gmail.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 Allows kbuild to generate LLVM bitcode files with the .ll extension when building with Clang. # c code CC=clang make kernel/pid.ll # asm code CC=clang make arch/arm/kernel/calls.ll Signed-off-by: Vinícius Tinti Signed-off-by: Behan Webster --- Makefile | 7 +++++++ scripts/Makefile.build | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/Makefile b/Makefile index f3c543d..4eb0d14 100644 --- a/Makefile +++ b/Makefile @@ -1484,6 +1484,13 @@ endif %.symtypes: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +ifeq ($(COMPILER),clang) +%.ll: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.ll: %.S prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +endif + # Modules /: prepare scripts FORCE $(cmd_crmodverdir) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index bf3e677..9ea19d6 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -174,6 +174,14 @@ cmd_cc_symtypes_c = \ $(obj)/%.symtypes : $(src)/%.c FORCE $(call cmd,cc_symtypes_c) +ifeq ($(COMPILER),clang) +quiet_cmd_cc_ll_c = CC $(quiet_modtag) $@ +cmd_cc_ll_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -emit-llvm -S -o $@ $< + +$(obj)/%.ll: $(src)/%.c FORCE + $(call if_changed_dep,cc_ll_c) +endif + # C (.c) files # The C file is compiled and updated dependency information is generated. # (See cmd_cc_o_c + relevant part of rule_cc_o_c) @@ -315,6 +323,16 @@ quiet_cmd_asn1_compiler = ASN.1 $@ $(obj)/%-asn1.c $(obj)/%-asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler $(call cmd,asn1_compiler) +# LLVM bitcode +# --------------------------------------------------------------------------- +ifeq ($(COMPILER),clang) +quiet_cmd_as_ll_S = CPP $(quiet_modtag) $@ +cmd_as_ll_S = $(CPP) $(a_flags) -o $@ $< + +$(obj)/%.ll: $(src)/%.S FORCE + $(call if_changed_dep,as_ll_S) +endif + # Build the compiled-in targets # ---------------------------------------------------------------------------