Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC39E5CDE2 for ; Wed, 6 Mar 2024 18:40:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709750422; cv=none; b=BEDtFyCcAFfZ/VQXHlfTBXgz1BROYgZXlGUOYQGRCmyMRPbXoG3TzP6lmQCteA1EjVG61eJPHZbHFJP8KlYxqComHy7FJyJC2guBi2dHsGZGkHwxuUMIGIdP1bGI4eKarmvyxJs8v483ruRysV9Fr7IsCEojWPL7t0muEDWecFQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709750422; c=relaxed/simple; bh=naRV30KansgHkf4z8iDs5HCMSQ2yOmTyAymWxIgw6Ek=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iKpZlBrnkny2TAptkcYuXWiFiKVOKHT4VXgsJr2S/vFRe9Jp8+38USKnDEVccfTHiBxtFGRno62kejiv0SF7Lyvz0fJ1TdMndg9dZAi+mwR48e1DRgcqQttOUvO5ryp/TazSdFrKWyT4o/pMbWUNl9k6vvoZqPjkbnsCya1Mzm4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=wwrt5alP; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="wwrt5alP" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-33e4d36f288so819088f8f.1 for ; Wed, 06 Mar 2024 10:40:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709750419; x=1710355219; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=rPESMKDgB77714G1diBfdcjFuhtpIqwIfC5iFsoM7Ys=; b=wwrt5alPGgdMl6yzIOSs5xVkMEnYQ8iVkkXChEtJhdqDsed3/WGcHd04c4dKTjFKVj yw3Gz0LDA+iomQHBqH+0BE8tUoGLmBYcQ2AhIN5+O+99yATCeZJJrB8qyxPC+UuB0n97 Bh/wlHuVZABGvbjHpKqdDh+zT0FCJ/ZfeUzXoGteL34+ZARLBLReyiACPZJna5z8wucG 6NSmno3aksaB5ZpNsgPz4OKtMvGZ8h6QGmRzA6tvWwwxWBVU4rNkYIHA7qHruwQDGsrt bViwtkDGpq5RucBLFIRkbx0SFxMqBVlzJrSBgscotkQAytMXqqUoZzh3Xypg5M2nAnSh NExg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709750419; x=1710355219; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rPESMKDgB77714G1diBfdcjFuhtpIqwIfC5iFsoM7Ys=; b=MM+D+Uc9uli6kB5WENlwVSwVw0olrDAYUvtiYY7RTaxVeYGb0XuOFe6u5a4t8rixhg aKgGPp5kS46doBnHpXfwVkp0YEj4CxOXBHBK7GtK+3cy8CDO6tlmP9UJfr+5fyaxmB4j /s+8PJHtd6cvwz3W4vQkJPtupuYzpIyBqgEz7/BDpm6HDyxAp/Kf4k+s+EbI9mncavYj yqVIFnS5UBe2Ueyg1WpcSTLSzX7CP+xDGmmcAaDpyYGOSpfZQmPhEyv/c0oraa4ThHDP FyB4zRlHDTFXtv2ZKMk10iMG/wiy/VCo4yoR/TGvvpTlt5yEx68tR5lysBO7smbJbT4m 91Pg== X-Gm-Message-State: AOJu0YyXghOa3Yggc4GGrOTk/cqqPC4TC4zsOfR2tkMGdbFusR/4M4o3 YJIp6/ATjeL/oA285Eh0dHC7DlzyAswobCZkRKT9fTRDqtJ57Z/KmRJTv5HSaL8= X-Google-Smtp-Source: AGHT+IG/WsOGKo6wD4CJGPT8cTpdL8w+Q8TYP0XJO+hlbvqneDk/mKtadRAhatK1sbsqqpEr4YQPJg== X-Received: by 2002:adf:c042:0:b0:33d:27c3:9f47 with SMTP id c2-20020adfc042000000b0033d27c39f47mr5371227wrf.35.1709750418883; Wed, 06 Mar 2024 10:40:18 -0800 (PST) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id j12-20020adfea4c000000b0033e11bd9febsm17799318wrn.90.2024.03.06.10.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 10:40:18 -0800 (PST) Date: Wed, 6 Mar 2024 21:40:14 +0300 From: Dan Carpenter To: =?utf-8?B?5p2O5Lmm55WF?= Cc: smatch@vger.kernel.org Subject: Re: Re: Re: about using smatch in all debian C code Message-ID: <114bf6c8-2916-4770-aafe-33e6cab7ff4f@moroto.mountain> References: <4640a9aa.3db.18bb28dbe21.Coremail.lishuchang@hust.edu.cn> <8cc9d3ba-f542-4d41-aea7-c5045e4769cb@kadam.mountain> <28841114.12973.18e12649674.Coremail.lishuchang@hust.edu.cn> <65cbde84.26ce5.18e132930df.Coremail.lishuchang@hust.edu.cn> Precedence: bulk X-Mailing-List: smatch@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <65cbde84.26ce5.18e132930df.Coremail.lishuchang@hust.edu.cn> On Wed, Mar 06, 2024 at 05:47:30PM +0800, 李书畅 wrote: > I'm sorry Dan, after reading smatch.txt, I still can't figure out how > to run smatch over a single C file before building a database, can you > show me the commands I need to enter? It's like the following > directory format: > > qemu (compiled) > -block.c > smatch (compiled) > Smatch needs all the same flags and arguments that we pass to GCC, plus a couple others which are specific to Smatch such as -p=kernel. So in the kernel the build system will call: gcc --foo --bar --whatever file.c smatch -p=kernel --foo --bar --whatever file.c But that's because the kernel build system was already set up to run a static checker. When you're compiling something else, then the way to do it is to trick the build system into using smatch/cgcc script as the compiler instead of gcc. The cgcc script will run gcc and then run $CHECK (where check is sparse by default). So with normal makefiles you would do something like: CHECK="~/smatch/smatch -p=qemu" CC=~/smatch/cgcc make But qemu is using a mix of Makefiles and meson to build and I don't really know how that works. regards, dan carpenter