Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4029355rdb; Thu, 14 Sep 2023 09:37:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+xTe/f96r8T6+NyoqmhbYdcH/IUEu8tqHYPrcjviJwbl5zcdPnrQ8ZQmKmpYZzA0ptHBH X-Received: by 2002:a05:6a00:3994:b0:68f:fa41:4e92 with SMTP id fi20-20020a056a00399400b0068ffa414e92mr6495316pfb.1.1694709445493; Thu, 14 Sep 2023 09:37:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694709445; cv=none; d=google.com; s=arc-20160816; b=xxKhdAmD2rM37E77zNT1lEvqpa3xbwl50XdqkrrJ+MmbjgHf0WHxVbMxQBY5l7/LiT ZH0Or86uUG3POgUwztTrp+1pe8prr4fKoWy9v25UNpuCZgF5hB2WBLc6tafjSdI+uNlU Nhucp+zHoBF+2RB75AzWiH8Nx/EIc0kckKEpyGnN+JmitidnllZuw9RoyAijnzgSWUFQ Nua8QcUsnMkFI3dvLVKixxpAiHt9REH9EWMtVNqZZ+jXur9DyONEMu/a5MRY0Z2FbQVd tJn5E/U3NWh8S9MpyD/BSIYAH/R/HGgC9Hi00KCFZ8vAwbnq7te4iqRsWQyrdZv4npld NnEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from:dkim-signature; bh=JWA6Wo+082prPCP4iQ0IKkSedoLJXHKZ5vIjbyz8vL8=; fh=/D3+IBWD4XuJm0x8En89gfdxa9l1Rqh4S2QDUiAS0sU=; b=CjVReq7M2v1pHC5UUrah6IfdeBHRDCup1qZ89oamo/qjILqMBUdWz96nWt1euv2X0p XBP162ZJu4t316KGx1Fqz0QANQseJHWGPbnPk/FRtHlZptD4H/6JoGkHTneAXuNYRQRH Ulx2qmpUqEUP6NuPqpTBcEnQ9wk9BohTDiPwAkoXDkLwyivNtFfEZ9eJN1MQMQleGh/G R9BZI11lj1NVdGbNeD7rHjrXO3fWPCgI1psQpMtGR8KSpS7rXpJ7p7v+a3eQ5liremIe xcih7n15T5HeYS1dYcTMR10j4t+B9WeNtjEVbrG491knbOAmoCoIuxzXOQ+5vkj/AReH PLFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dK3Ka0Bt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id t22-20020a63eb16000000b005660335e26fsi1777897pgh.485.2023.09.14.09.37.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 09:37:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dK3Ka0Bt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 3829D82F96AA; Thu, 14 Sep 2023 06:59:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239348AbjINN7k (ORCPT + 99 others); Thu, 14 Sep 2023 09:59:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231720AbjINN7j (ORCPT ); Thu, 14 Sep 2023 09:59:39 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E9461BE; Thu, 14 Sep 2023 06:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694699975; x=1726235975; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=M9/pjtPgrCPB3pKfZPcjSZj8sNqVAWupOs4Vq63aUF0=; b=dK3Ka0Bt8SpiQICGk+guBf++P+yNwT0g8WiZ1Qnn5KKj8XQvNzztz5xq lojyMZnGLPt8RRVcNb2weSdIkea6mQzMsEDSkZVd/boK9oCpfEcFF7Qy+ BQ77PH/rnfNPZVGHTXqdp3dUGXM5zG60VHbZxHiuegd/BUBwhT0iq/yJU AqsmGqwXxlSj4e+wQNQLVIO6p8DH2XGKgfoTVamhICquJmnn5qZ1nkrbV EDS4qhhNv8G0MgbxQqZBCyQY+d6SGmm8LnZN0clAez5g/vo/bYa46Orbl 3eLRYiaeBMIQJnXJ8o109fXZY0xX3nbaaGbq0aTHZRPyEjB3/pgW31Gh6 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="364002912" X-IronPort-AV: E=Sophos;i="6.02,146,1688454000"; d="scan'208";a="364002912" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2023 06:43:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="991391112" X-IronPort-AV: E=Sophos;i="6.02,146,1688454000"; d="scan'208";a="991391112" Received: from jnikula-mobl4.fi.intel.com (HELO localhost) ([10.237.66.162]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2023 06:42:58 -0700 From: Jani Nikula To: Arnd Bergmann , Masahiro Yamada , Jonathan Corbet Cc: Sakari Ailus , Javier Martinez Canillas , Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Documentation: kbuild: explain handling optional dependencies In-Reply-To: <20230913113801.1901152-1-arnd@kernel.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20230913113801.1901152-1-arnd@kernel.org> Date: Thu, 14 Sep 2023 16:42:55 +0300 Message-ID: <874jjwx44g.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:59:40 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email On Wed, 13 Sep 2023, Arnd Bergmann wrote: > From: Arnd Bergmann > > This problem frequently comes up in randconfig testing, with > drivers failing to link because of a dependency on an optional > feature. > > The Kconfig language for this is very confusing, so try to > document it in "Kconfig hints" section. Thanks for doing this. > > Signed-off-by: Arnd Bergmann > --- > Documentation/kbuild/kconfig-language.rst | 26 +++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/Documentation/kbuild/kconfig-language.rst b/Documentation/kbuild/kconfig-language.rst > index 858ed5d80defe..89dea587a469a 100644 > --- a/Documentation/kbuild/kconfig-language.rst > +++ b/Documentation/kbuild/kconfig-language.rst > @@ -573,6 +573,32 @@ above, leading to: > bool "Support for foo hardware" > depends on ARCH_FOO_VENDOR || COMPILE_TEST > > +Optional dependencies > +~~~~~~~~~~~~~~~~~~~~~ > + > +Some drivers are able to optionally use a feature from another module > +or build cleanly with that module disabled, but cause a link failure > +when trying to use that loadable module from a built-in driver. > + > +The most common way to express this optional dependency in Kconfig logic > +uses the slighly counterintuitive > + > + config FOO > + bool "Support for foo hardware" > + depends on BAR || !BAR depends on BAR || BAR=n seems to be an alternative that's about as common: $ git grep "depends on \([A-Z0-9_]\+\) || \!\1" | wc -l 109 $ git grep "depends on \([A-Z0-9_]\+\) || \1=n" | wc -l 107 Maybe worth mentioning both? BR, Jani. > + > +This means that there is either a dependency on BAR that disallows > +the combination of FOO=y with BAR=m, or BAR is completely disabled. > +For a more formalized approach if there are multiple drivers that have > +the same dependency, a helper symbol can be used, like > + > + config FOO > + bool "Support for foo hardware" > + depends on BAR_OPTIONAL > + > + config BAR_OPTIONAL > + def_tristate BAR || !BAR > + > Kconfig recursive dependency limitations > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Jani Nikula, Intel