Received: by 10.213.65.68 with SMTP id h4csp1016861imn; Wed, 4 Apr 2018 11:05:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+gwnsM+Boh7NIjmlGG2Tv/c9iTbKUtwesOEUbf2ry0105tDnZsE1V760hbDWFIJ/jwu77q X-Received: by 10.101.70.132 with SMTP id h4mr12585803pgr.155.1522865158229; Wed, 04 Apr 2018 11:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522865158; cv=none; d=google.com; s=arc-20160816; b=rYgdPezHszliFFEtqyaLrSNdvc34ATXCqBS1DYqLeGn8xCi1/1LlO+3XLo2TmxV6B3 qXf9x3Qd58TXiOO2Syp2OavfTuY56M2Yg58OI9+whFO+Q4Hw1cv9J4k4RGhAsRUqfxID HM6w3cVhuQxl3R1mT4M+LWsyqbJeewvIhpMwjv1uvO2zVZ32R2gAaHufDI2+krQ6Cnkw VITFkGfAPLMJWXYvFaPLgFZIg/9tN7/5eLLXrm3/ytdNN8nUN/pkC5LUJXIOX8EhpS9d BfQwjujXxm1G58lfjA3yR1tSrYOMzvfuIA0OmEpHb6KHiWO5EP+NCfw85x6W9+NHpXXz Gr4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:subject:cc:to:from :arc-authentication-results; bh=ioh/Wk604o5cQ9agykvKH0KdWXczSaTVjlQKoi/Zavw=; b=wfE86Ft7G9VIbLL2uBposEn3ucfqeFCVggrq/1Lb+nOyeizb1Y0FLIszNs33rpfezd Okm3ct/64dxvNNemry0tE5feawTZ58rsC1z3e61ZHGiHAtdxLRH9nWvVrKRa0V7Jvfa6 T4vk39sRComOvddPVZajtM7NY9JE8yWidnkfzlGdKzatIFKxCHHLNHFZIxd+2pIBCThN wjHO7ct0/Clx3YTnOZ3B1ZQU8ZCh9aAiwZU6psYi1TjnyQEYAf49HpjWvtPEVq99s1dz /7KOolOrBFdhA7u74Xx/mMzEMgXojeMgtDvxtIGpE2zUq+Fx0g4hTxupYx0ARUoO2GYR y7hA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1-v6si3566655plt.520.2018.04.04.11.05.43; Wed, 04 Apr 2018 11:05:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751453AbeDDSEe (ORCPT + 99 others); Wed, 4 Apr 2018 14:04:34 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44250 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750915AbeDDSE2 (ORCPT ); Wed, 4 Apr 2018 14:04:28 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w34I3gHQ052021 for ; Wed, 4 Apr 2018 14:04:28 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2h53ne0190-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 04 Apr 2018 14:04:27 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Apr 2018 19:04:25 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 4 Apr 2018 19:04:23 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w34I4Nho15597674; Wed, 4 Apr 2018 18:04:23 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 518E5AE051; Wed, 4 Apr 2018 18:54:28 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 95EE6AE045; Wed, 4 Apr 2018 18:54:27 +0100 (BST) Received: from localhost.localdomain (unknown [9.40.193.84]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 4 Apr 2018 18:54:27 +0100 (BST) From: Sandipan Das To: acme@kernel.org, jolsa@redhat.com Cc: linux-kernel@vger.kernel.org, naveen.n.rao@linux.vnet.ibm.com Subject: [PATCH 2/3] perf clang: Add support for recent clang versions Date: Wed, 4 Apr 2018 23:34:18 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180404180419.19056-1-sandipan@linux.vnet.ibm.com> References: <20180404180419.19056-1-sandipan@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 18040418-0040-0000-0000-0000042A76FC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18040418-0041-0000-0000-0000262DAA10 Message-Id: <20180404180419.19056-2-sandipan@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-04-04_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804040180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The clang API calls used by perf have changed in recent releases and builds succeed with libclang-3.9 only. This introduces compatibility with libclang-4.0 and above. Without this patch, we will see the following compilation errors with libclang-4.0+: util/c++/clang.cpp: In function ‘clang::CompilerInvocation* perf::createCompilerInvocation(llvm::opt::ArgStringList, llvm::StringRef&, clang::DiagnosticsEngine&)’: util/c++/clang.cpp:62:33: error: ‘IK_C’ was not declared in this scope Opts.Inputs.emplace_back(Path, IK_C); ^~~~ util/c++/clang.cpp: In function ‘std::unique_ptr perf::getModuleFromSource(llvm::opt::ArgStringList, llvm::StringRef, llvm::IntrusiveRefCntPtr)’: util/c++/clang.cpp:75:26: error: no matching function for call to ‘clang::CompilerInstance::setInvocation(clang::CompilerInvocation*)’ Clang.setInvocation(&*CI); ^ In file included from util/c++/clang.cpp:14:0: /usr/include/clang/Frontend/CompilerInstance.h:231:8: note: candidate: void clang::CompilerInstance::setInvocation(std::shared_ptr) void setInvocation(std::shared_ptr Value); ^~~~~~~~~~~~~ Fixes: 00b86691c77c ("perf clang: Add builtin clang support ant test case") Signed-off-by: Sandipan Das --- tools/perf/util/c++/clang.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/c++/clang.cpp b/tools/perf/util/c++/clang.cpp index 1bfc946e37dc..bf31ceab33bd 100644 --- a/tools/perf/util/c++/clang.cpp +++ b/tools/perf/util/c++/clang.cpp @@ -9,6 +9,7 @@ * Copyright (C) 2016 Huawei Inc. */ +#include "clang/Basic/Version.h" #include "clang/CodeGen/CodeGenAction.h" #include "clang/Frontend/CompilerInvocation.h" #include "clang/Frontend/CompilerInstance.h" @@ -58,7 +59,8 @@ createCompilerInvocation(llvm::opt::ArgStringList CFlags, StringRef& Path, FrontendOptions& Opts = CI->getFrontendOpts(); Opts.Inputs.clear(); - Opts.Inputs.emplace_back(Path, IK_C); + Opts.Inputs.emplace_back(Path, + FrontendOptions::getInputKindForExtension("c")); return CI; } @@ -71,10 +73,17 @@ getModuleFromSource(llvm::opt::ArgStringList CFlags, Clang.setVirtualFileSystem(&*VFS); +#if CLANG_VERSION_MAJOR < 4 IntrusiveRefCntPtr CI = createCompilerInvocation(std::move(CFlags), Path, Clang.getDiagnostics()); Clang.setInvocation(&*CI); +#else + std::shared_ptr CI( + createCompilerInvocation(std::move(CFlags), Path, + Clang.getDiagnostics())); + Clang.setInvocation(CI); +#endif std::unique_ptr Act(new EmitLLVMOnlyAction(&*LLVMCtx)); if (!Clang.ExecuteAction(*Act)) -- 2.14.3