Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8744415ybi; Thu, 6 Jun 2019 19:07:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxL9C7OZyVGeNORErTJAmfb7h0CGUZ73MkYMZz2T9QIWrxa1bZQb+FPSwND9tPf+k9ImuZD X-Received: by 2002:a63:1b07:: with SMTP id b7mr694371pgb.289.1559873242868; Thu, 06 Jun 2019 19:07:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559873242; cv=none; d=google.com; s=arc-20160816; b=aWRzyHuYZPZM/MWTCar9hwDshZlY+xLviIZ8Rl4BlsnV9dmFLJoF8rAsVoX+f3zhtq 7yr+uOwlS5lUL58WvbMn+2QknLqWeycQ4eK7lpQTUHV3fJXKifuTfDFnc8sJXFmkIN76 IqUPuFaappqCSLKEnthEEXfrD0PVxATnqQYmGkj+cUciFaM8e4hD/kiUkFFIpjH45VnO oQVPfqp+LDKW4ojNIILLq/vTbC1sZy+gcXe425b6lUw9nURRc5lKPZta1eLF5xBMBpRX EVDrk+MUEb9SJkarBa4vj2i1WPdRipEhRbnoL2q37J0/fIjGOUmkWi8GNg80n5fe5VYu LkKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=zupcycHQhyZT5TPbzZH69TXNfK4PGS1TsnXYmh2heXA=; b=XNj1FQULlimzmatg+4GOIjQnnjYkL5Gnhux4bXDbaGNIK7R72ec2r5HsRTiyjST7sX yoqZCLFvW3TEVjZbSN8gmXN5hEKnP2HdvDBGXH2+tGRQmdFkoXUc4J2IuowTEfSLVH4B BHLiZx/zR51bIYkihl4XWrEy7abGKjCZyNNCdb4LhDvzbUPgE5WXq/e87XJ+ozqb1fnY UEuL9UbFrPCloOdUva+HmSxekfSSxVC7Hgd1AbgaxbbVoQWytpHkDh+yKOwQf95EkPe1 CEzcUol+BpSy71/QCV5gaPyPIHJ85CaR/YnZGvlhGSQIVZH3Y9f86llmwVQBWoi32oHL 2uKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OK7y4D8O; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c20si538542pfn.256.2019.06.06.19.06.49; Thu, 06 Jun 2019 19:07:22 -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=@google.com header.s=20161025 header.b=OK7y4D8O; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727839AbfFFXkN (ORCPT + 99 others); Thu, 6 Jun 2019 19:40:13 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:42842 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727167AbfFFXkM (ORCPT ); Thu, 6 Jun 2019 19:40:12 -0400 Received: by mail-pl1-f194.google.com with SMTP id go2so58868plb.9 for ; Thu, 06 Jun 2019 16:40:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zupcycHQhyZT5TPbzZH69TXNfK4PGS1TsnXYmh2heXA=; b=OK7y4D8OareDzwfMyIRJGXrsJrkBCTjHx+5e2R1/XnVCdlMIeUq2ylw1JdESiMjw4U vQuzE8d1AM5MapxQeB4XiUvJKPY9nfGTyJlfyEYbAf0cX6CGSM1fTIOoHvwvr8N89Fwz oKuJdZJ1czJp/0Awj+h8sAVxQNfO0Iyaa+Nu8ToGeJcB6izf81oFHFtnMGT2gOAc+zLf YhEPKHZQLHD8ZPVr6sOBalOoiKDdbP2er0moAg9N8sP/yQTvr/fJRlLyZxbUTLfxT+Nd SMQAWURCIlVmkk6htR9ZFo+Zq8eXp8j1EypQH3Tr8EqXWAx/dtpgQkohFh5HoSD/8mmt 3vlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zupcycHQhyZT5TPbzZH69TXNfK4PGS1TsnXYmh2heXA=; b=EV2ArIQEKJ047feQkYc/Ljt+QOTPqHCeOcv3W0qufHScNnSLWh1tE9CNusaDQWXT4/ LURifOoNZUIqIVW7VUJTei4RnlcathRDmvqpAVYYyiTcZ5FqySz9L3CpU25oVbkQuDBm xib/OTRoHAV0ni4+Zq3/MQnx30eMsbC0mNuNTGAShSqtsrYWUg/B5ukKliYcgaumhs6U qX0WJAuePM58OOhQcRN2VniAWTtaMTVbsfOysXrNfyflC/qKeubuWjtCdwHIbBoW9HCK LRnR+LxNsxEZKVYG7dbL7vI466P06kU9D/yunOHxtQE9JCzorcryd6FlTvYitwSLMiyD RDOA== X-Gm-Message-State: APjAAAX7z6pTT+RgYtsLjoFFQRQzE11vtL2fEESkHdCZW/rty1eQ7kd1 sbiZ7td5v3n/qw2TUTDLkvUAO6CDvAKNhpg4glYYMg== X-Received: by 2002:a17:902:b944:: with SMTP id h4mr50886675pls.179.1559864411389; Thu, 06 Jun 2019 16:40:11 -0700 (PDT) MIME-Version: 1.0 References: <20190606203003.112040-1-rrangel@chromium.org> <20190606205406.GA120512@google.com> In-Reply-To: <20190606205406.GA120512@google.com> From: Nick Desaulniers Date: Thu, 6 Jun 2019 16:40:00 -0700 Message-ID: Subject: Re: [RFC PATCH] kbuild: Add option to generate a Compilation Database To: Tom Roeder Cc: Raul E Rangel , Masahiro Yamada , Matthias Kaehlcke , zwisler@chromium.org, Joe Lawrence , Kees Cook , Linux Kbuild mailing list , Petr Mladek , LKML , Michal Marek , Andy Shevchenko , Changbin Du , Tetsuo Handa , Sri Krishna chowdary , Matthew Wilcox , Mikulas Patocka , Andrew Morton Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 6, 2019 at 1:54 PM Tom Roeder wrote: > > On Thu, Jun 06, 2019 at 02:30:03PM -0600, Raul E Rangel wrote: > > Clang tooling requires a compilation database to figure out the build > > options for each file. This enables tools like clang-tidy and > > clang-check. > > > > See https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html for more > > information. I'm also super happy to see this! https://nickdesaulniers.github.io/blog/2017/05/31/running-clang-tidy-on-the-linux-kernel/ I don't know enough about GNU Make/Kbuild to answer the questions, but hopefully Masahiro can help there. > I'm glad to see someone adding this to the Makefile directly. I added > scripts/gen_compile_commands.py in b302046 (in Dec 2018) when I was Heh, cool. I had a script that basically did this; we recently dropped it from the Android trees when doing an audit of out of tree patches. > working on using clang-check to look for bugs in KVM. That script I'm very interested in this work; my summer intern is looking into static analyses of the Linux kernel. Can you maybe reach out to me off thread to tell me more about what you found (or didn't)? > > Normally cmake is used to generate the compilation database, but the > > linux kernel uses make. Another option is using > > [BEAR](https://github.com/rizsotto/Bear) which instruments > > exec to find clang invocations and generate the database that way. It's probably possible to get this to work w/ GCC if the additional dependency of bear exists on the host's system (and may reduce the number of implementations). Downside is the additional host dependency. Sounds like it may also be possible to just run scripts/gen_compile_commands.py at build time if this config is enabled? Maybe a comparison of the output of Tom's script and your patch might reveal if one approach is incomplete? -- Thanks, ~Nick Desaulniers