From patchwork Thu Sep 11 23:13:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vinicius Tinti X-Patchwork-Id: 4891071 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 06E279F1D3 for ; Thu, 11 Sep 2014 23:07:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB42D20225 for ; Thu, 11 Sep 2014 23:13:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F0AF201FB for ; Thu, 11 Sep 2014 23:13:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752525AbaIKXNU (ORCPT ); Thu, 11 Sep 2014 19:13:20 -0400 Received: from mail-qc0-f173.google.com ([209.85.216.173]:40102 "EHLO mail-qc0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752368AbaIKXNU (ORCPT ); Thu, 11 Sep 2014 19:13:20 -0400 Received: by mail-qc0-f173.google.com with SMTP id w7so22070708qcr.18 for ; Thu, 11 Sep 2014 16:13:19 -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:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=3an7UZ3V+yv3+39vnJxf1c36XxzL3sJtnj147MbCWs8=; b=syLEaus4TKS4WymWji4xoebHfpWdSL234U9Nj9NAfsv5BmUFGzN2x03M1xNPCGrOan 8y37yNJslcgXeSyDg8MtlkVOWNbNci3lhSWMugv7UskkN4pnYeozsz+RiYq3lOcm8pO4 5ANW1zyugUMXb5dDzW1BWIuXejQymqdwg+t0peTYYca3BBzY4+7q+dl1ltHMuhrDUbvN YU69OcgzuPkqjmW9QXKLiOkIBVRGGkMV/HlF7DocrsLk/rWyV0+otaCEmX+vkqCpXcrN GVXWsdpTbsgGtapTQ7pkKrP3XRuByjvrCUIfmeh2RaamlTq9snAhUMjOE0UWDHfwIXar YdVg== X-Received: by 10.224.37.10 with SMTP id v10mr6725038qad.31.1410477199185; Thu, 11 Sep 2014 16:13:19 -0700 (PDT) Received: from eudyptula.localdomain ([177.97.210.160]) by mx.google.com with ESMTPSA id f7sm1737260qas.32.2014.09.11.16.13.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Sep 2014 16:13:18 -0700 (PDT) From: =?UTF-8?q?Vin=C3=ADcius=20Tinti?= To: Michal Marek , Andrew Morton , Behan Webster , Zhao Gang , Borislav Petkov , Andi Kleen Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, =?UTF-8?q?Vin=C3=ADcius=20Tinti?= Subject: [PATCH v3] kbuild: add support to generate LLVM bitcode files Date: Thu, 11 Sep 2014 20:13:00 -0300 Message-Id: <1410477180-1328-1-git-send-email-viniciustinti@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: References: 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=-9.3 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=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 Allows kbuild to generate LLVM bitcode files using '.ll' suffix. # from c code CC=clang make kernel/pid.ll # from asm code CC=clang make arch/x86/kernel/preempt.ll Signed-off-by: Vinícius Tinti Signed-off-by: Behan Webster --- .gitignore | 1 + Makefile | 6 ++++++ scripts/Makefile.build | 14 ++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/.gitignore b/.gitignore index e213b27..823b9d6 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ *.lzo *.patch *.gcno +*.ll modules.builtin Module.symvers *.dwo diff --git a/Makefile b/Makefile index 1a60bdd..cd4a120 100644 --- a/Makefile +++ b/Makefile @@ -1250,6 +1250,8 @@ help: @echo ' (default: $$(INSTALL_MOD_PATH)/lib/firmware)' @echo ' dir/ - Build all files in dir and below' @echo ' dir/file.[oisS] - Build specified target only' + @echo ' dir/file.ll - Build the LLVM bitcode file' + @echo ' (requires compiler support for LLVM bitcode generation)' @echo ' dir/file.lst - Build specified mixed source/assembly target only' @echo ' (requires a recent binutils and recent build (System.map))' @echo ' dir/file.ko - Build module including final link' @@ -1526,6 +1528,10 @@ endif $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) %.symtypes: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.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 $@) # Modules /: prepare scripts FORCE diff --git a/scripts/Makefile.build b/scripts/Makefile.build index bf3e677..4d97e4f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -174,6 +174,20 @@ cmd_cc_symtypes_c = \ $(obj)/%.symtypes : $(src)/%.c FORCE $(call cmd,cc_symtypes_c) +# LLVM bitcode +# Generate .ll files from .s and .c +quiet_cmd_cc_ll_c = CC $(quiet_modtag) $@ + cmd_cc_ll_c = $(CC) $(c_flags) -emit-llvm -S -o $@ $< + +$(obj)/%.ll: $(src)/%.c FORCE + $(call if_changed_dep,cc_ll_c) + +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) + # 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)