Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2159324imm; Sat, 16 Jun 2018 10:49:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJkcETPFzEem4wJtAoG/Ugba9vnuPLLj0WMc6YZ96PIeVKQQZdCcn/BgSl44pRS7F3ZGIyV X-Received: by 2002:a17:902:8206:: with SMTP id x6-v6mr7250838pln.220.1529171353892; Sat, 16 Jun 2018 10:49:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529171353; cv=none; d=google.com; s=arc-20160816; b=lPFSA07uiyRvjxTs85box2JtMcdY+YEtnZ9/xFDM7C3i7AaXLfOTAVwBGcZnDb9aGO Nfr8fAa4FZngCyCxxKDQ+U5QUlFavhFA1UUOkf3WPybWR9mT5rgiTWnQdsAYPUkeQs72 U9VQKG4/4fQzgUQpmABknM6Q129KG7lJrDkVL0cFZldflECmNOHKsC7jTxNEAIWkfNCH 96IQZn8g9i4m4ZxyW20ODtK3p6zwSHj4eZxfcCoAcAZdmJyS7S0lM3KWYChvYIVGIfVM TlQ8a4Uk/FFbb/FlXkkHJmDTH2bdmgEWYCCxk3RIeyG/JdJ30LIORMgDVGGQNioZKID6 D+3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:smtp-origin-cluster:to:smtp-origin-hostname :from:smtp-origin-hostprefix:dkim-signature :arc-authentication-results; bh=gSboO0QZwW0cTrQWKJCn64eZTeMkX9zF19fgpPudVr8=; b=UO4NDKhw3YG2wWJwuxWMXgiJ8MZrzj5laNmdL+QBPdRUvDHaOtVFF/quvSEiADvj0U 2qGXEaauwHvM0RRhoo7rEhT8oxfWWXoJcVYM2SWz54/hN4KbMdzJtxdNTsqf7asZc8h3 9aCNAG6g+/Sh0DUldtmLuq8kPu4S5Q9eNohuqY0ploaqIe489+x3jMnk81aWaqrYV7zG 3L7pum2yvjr52057m1I+X3/d+BgL1leO/T4Oz+I5bbQr0E/QvQxaaU2XzRiNoCZtTEFP UtnITydgij0bBs9zcy+Og+GntsHxmj16AZTi1hD/2mb/zhJD1xMYqLW4T5OlmE5L2f8s zm7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=PQ6FIkq6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10-v6si8703828pgq.503.2018.06.16.10.48.34; Sat, 16 Jun 2018 10:49:13 -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; dkim=pass header.i=@fb.com header.s=facebook header.b=PQ6FIkq6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932667AbeFPRrn (ORCPT + 99 others); Sat, 16 Jun 2018 13:47:43 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:55268 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932337AbeFPRrm (ORCPT ); Sat, 16 Jun 2018 13:47:42 -0400 Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5GHgfpr006163 for ; Sat, 16 Jun 2018 10:47:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=facebook; bh=gSboO0QZwW0cTrQWKJCn64eZTeMkX9zF19fgpPudVr8=; b=PQ6FIkq6eqViTLrBCjP9DsMbbGDWlBVuh9wTnV+O4wbIsFLlIKt3PJGvPpoWTex42c21 0AqWflYxDe/Iz3m1XfhjOR/FbMdpYuU72llFBVweTrFrDcdWkJYuFNlDIScMA43koEv7 lr92DBXRkH4G7J4tdBnhjRzczeqCyySNiHw= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2jn0cm0m1k-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sat, 16 Jun 2018 10:47:42 -0700 Received: from mx-out.facebook.com (192.168.52.123) by mail.thefacebook.com (192.168.16.24) with Microsoft SMTP Server (TLS) id 14.3.361.1; Sat, 16 Jun 2018 10:47:40 -0700 Received: by devbig003.ftw2.facebook.com (Postfix, from userid 128203) id D7DB83701240; Sat, 16 Jun 2018 10:47:39 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Yonghong Song Smtp-Origin-Hostname: devbig003.ftw2.facebook.com To: , , , , , , Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH] tools/perf: fix a clang 7.0 compilation error Date: Sat, 16 Jun 2018 10:47:39 -0700 Message-ID: <20180616174739.1076733-1-yhs@fb.com> X-Mailer: git-send-email 2.9.5 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-16_09:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Arnaldo reported the perf build failure with latest llvm/clang compiler (7.0). $ make LIBCLANGLLVM=3D1 -C tools/perf/ CC /tmp/tmp.t53Qo38zci/tests/kmod-path.o util/c++/clang.cpp: In function =E2=80=98std::unique_ptr > perf::getBPFObjectFromModule(llvm::Module*)=E2=80=99: util/c++/clang.cpp:150:43: error: no matching function for call to =E2=80=98llvm::TargetMachine::addPassesToEmitFile(llvm::legacy::Pa= ssManager&, llvm::raw_svector_ostream&, llvm::TargetMachine::CodeGenFileType)= =E2=80=99 TargetMachine::CGFT_ObjectFile)) { ^ In file included from util/c++/clang.cpp:25:0: /usr/local/include/llvm/Target/TargetMachine.h:254:16: note: candidate= : virtual bool llvm::TargetMachine::addPassesToEmitFile( llvm::legacy::PassManagerBase&, llvm::raw_pwrite_stream&, llvm::raw_pwrite_stream*, llvm::TargetMachine::CodeGenFileType, bo= ol, llvm::MachineModuleInfo*) virtual bool addPassesToEmitFile(PassManagerBase &, raw_pwrite_strea= m &, ^~~~~~~~~~~~~~~~~~~ /usr/local/include/llvm/Target/TargetMachine.h:254:16: note: candidate expects 6 arguments, 3 provided mv: cannot stat '/tmp/tmp.t53Qo38zci/util/c++/.clang.o.tmp': No such fi= le or directory make[7]: *** [/home/acme/git/perf/tools/build/Makefile.build:101: /tmp/tmp.t53Qo38zci/util/c++/clang.o] Error 1 make[6]: *** [/home/acme/git/perf/tools/build/Makefile.build:139: c++] = Error 2 make[5]: *** [/home/acme/git/perf/tools/build/Makefile.build:139: util]= Error 2 make[5]: *** Waiting for unfinished jobs.... CC /tmp/tmp.t53Qo38zci/tests/thread-map.o The function addPassesToEmitFile signature changed in llvm 7.0 and such a change caused the failure. This patch fixed the issue with using proper function signatures under different compiler versions. Reported-by: Arnaldo Carvalho de Melo Signed-off-by: Yonghong Song --- tools/perf/util/c++/clang.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/c++/clang.cpp b/tools/perf/util/c++/clang.cp= p index bf31cea..8951250 100644 --- a/tools/perf/util/c++/clang.cpp +++ b/tools/perf/util/c++/clang.cpp @@ -146,8 +146,15 @@ getBPFObjectFromModule(llvm::Module *Module) raw_svector_ostream ostream(*Buffer); =20 legacy::PassManager PM; - if (TargetMachine->addPassesToEmitFile(PM, ostream, - TargetMachine::CGFT_ObjectFile)) { + bool NotAdded; +#if CLANG_VERSION_MAJOR < 7 + NotAdded =3D TargetMachine->addPassesToEmitFile(PM, ostream, + TargetMachine::CGFT_ObjectFile); +#else + NotAdded =3D TargetMachine->addPassesToEmitFile(PM, ostream, nullptr, + TargetMachine::CGFT_ObjectFile); +#endif + if (NotAdded) { llvm::errs() << "TargetMachine can't emit a file of this type\n"; return std::unique_ptr>(nullptr);; } --=20 2.9.5