Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp329327ybi; Fri, 7 Jun 2019 08:43:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqyI9hMmrj5X70qSBxinzPTjQ9Q9JoLXEZzPjJbja4dToNrhWz5MQV6ZhYphu/lqb8aC+HGW X-Received: by 2002:a63:9502:: with SMTP id p2mr3478111pgd.12.1559922214184; Fri, 07 Jun 2019 08:43:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559922214; cv=none; d=google.com; s=arc-20160816; b=blrB6hekBrKg/5rhpzT/6nUOcwe9NzUodWssUvg6R/gnzK8svBGtj0gS8+CRkx1XxG pPocSVig0cZ6BiGwkcELWYBL3UIkqI/ZWHH9Ma8KcBcOzKREDKOeT9vdXrONONCTegT3 noxV3odaz0qsRpOBIcwA6DsJInUYpJFCWCX35OvmOBt82p3SqdfRxZsBzBJ95IoMcVJR sqSoqbAnuuxHwHtPtXNroO7iW0RfxwfwZtYCtgie1m9SIH8/Sl7dPIOQex9jvysrHUWb 0xK/BbRSzHai7Cd1l/IVwm7FoVF00T1SgZiGw+kJONxsyeDqQ964ao2CZg6TQlaxiOjF b09A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=I7ozsQLaOgj0MR9jFDS0vY/ACLnRjUvlCOsI+qsnQSE=; b=TEt1AArX0NJQaszCruyKMqhjLCwZjqTcbi5ZqTYxawF2xeM7B6rQDJ8CYaISHm4oRe BOE481fuFEpXq8Yg7MxVDp8UPmrfVOl0ddnx9ty7yJYykkeEDTz5TCDsPVUa1lN6OWiu EUzvmomCvV13kob3JVCej88LEgpBJ0H3FReEm8vYLbSOuRy6fap4/4FdOQrjA8SGKSDy Mcw8FO/1BjuWD2vp/EIzn1IujIepqPKAFoUMWtbxXAi/cVooBh8oRMsFKTcqwTCA0mdm aHlpeYr3yT6N1b6edbyMPoOJTcEn9rQ7Ewb9CthOGvk26hHknFUaqlXVyx9fmw+6GlbC B1Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PMb1KwUO; 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 l11si2011211pgp.438.2019.06.07.08.43.16; Fri, 07 Jun 2019 08:43:34 -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=PMb1KwUO; 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 S1729965AbfFGPcx (ORCPT + 99 others); Fri, 7 Jun 2019 11:32:53 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:44883 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729956AbfFGPcv (ORCPT ); Fri, 7 Jun 2019 11:32:51 -0400 Received: by mail-pf1-f195.google.com with SMTP id t16so1386275pfe.11 for ; Fri, 07 Jun 2019 08:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=I7ozsQLaOgj0MR9jFDS0vY/ACLnRjUvlCOsI+qsnQSE=; b=PMb1KwUOxWy7M5vtJkbvKRrSeqFBXw5wn46RTCMPfk7VWqJr1DXAQEbeX8GP72niYE BNlslRoKbVLV5qwrRTf85CnT3M8NmPmSXpjujnimL4GmQrn0m1xaVXFBTTHKCAv0oGqe vbBCVaXK88Pepnh49gjS5NITkVkx8XKSOmaATWZIo/j4eI4sI0L7jWEam+302Vjpt3Eo z46upIm7QkeU7Y6YbxlnA6vrrSD9mpgcLQEpPfBrBCGDrFLR1GNxj83pVvFlbud/+TS0 G75AdhHeb1ZimhF9U9rAVvQpR/+OpyCz1eZRSaNuVx6YG0qM67yIkaCO7JYgzahAYbZI 4k9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=I7ozsQLaOgj0MR9jFDS0vY/ACLnRjUvlCOsI+qsnQSE=; b=GpxzLi6O9ohv2kb4RFM2gYpvYkY3lg1l8AA6lKQe8x4Y0XVSmDC9mQ7iUNWDcG+cSj SD52fvq4t2LyNtVY8p0uFMrNuYGGDmxs1N32i8WNP+GK8gRvz3yeMJ8R2Ebm2v7YDg3X G2hDyFLha6Uze2SVsDJ1CeQMxrWZ/w1+1Hhy9EE82mh5TpkukZPLSRpBtEgVnR7tLkei LPYcnQNUfunUGiJv1wy+Z3yxJ4gontnw8k1Ahk9sr7PSAsbdLgC64EY6rhfo61g92wDf KGpXD1hGC7zGnGPUGTZOqcrIn2EcZgI+Ao8s5jb7hvV61h1ey1QmwxnyyWwxQsJ0bKBg 9vYA== X-Gm-Message-State: APjAAAWRlDboKTxSaiFgymhvKQsQ2RfHVAp9jqqyBgvIY2tYTTIJvKiR CUmOwkoNiH/oUY9d9DhBsO8a6g== X-Received: by 2002:aa7:8ecb:: with SMTP id b11mr19920591pfr.220.1559921570760; Fri, 07 Jun 2019 08:32:50 -0700 (PDT) Received: from google.com ([2620:0:1008:1100:dac3:f780:2846:b802]) by smtp.gmail.com with ESMTPSA id b7sm2432205pgq.71.2019.06.07.08.32.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 08:32:50 -0700 (PDT) Date: Fri, 7 Jun 2019 08:32:46 -0700 From: Tom Roeder To: Nick Desaulniers 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 Subject: Re: [RFC PATCH] kbuild: Add option to generate a Compilation Database Message-ID: <20190607153246.GB101503@google.com> References: <20190606203003.112040-1-rrangel@chromium.org> <20190606205406.GA120512@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 06, 2019 at 04:40:00PM -0700, Nick Desaulniers wrote: > 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? Yes, for scripts/gen_compile_commands.py, you run a build first with whatever configuration you want, then call the script to produce the compile_commands.json file.