Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3284899rdb; Wed, 13 Sep 2023 07:42:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsZa1sr7ZKVYXntxu2iC6MGMrQXLXsdJuvPkjQjA8yx5J3p+jNfLGwgMJ+gmGlDi8i38EX X-Received: by 2002:a05:6808:13c1:b0:3a9:e40c:683c with SMTP id d1-20020a05680813c100b003a9e40c683cmr3448539oiw.1.1694616172566; Wed, 13 Sep 2023 07:42:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694616172; cv=none; d=google.com; s=arc-20160816; b=INeGWt0Xt9xvTOezbwjnc6uPcTpATk67MPci5SaBfw25v+93ti6j9Qv48mUDKMDFjA j6fI8Nt2rGbT2DoCPo+OqlKQQ493FNVPML5duw51jJqhmmDYXhbmrD9AtdrdWlwsmsPP kZFlBr5VXsgEsYQbVoZcXbpTnUj7yPpIhxmmYUBpu3Wuxa47GuPuZ/EdcLEzqRQCFFiz HiHz+Ocmxr5+hz4gmcCWs3hrM9l6xqSC2+HyMRVWQ+l2l4EgcO30Ejkt0ePAdPsd1tsD Abvoji2MuLVDG0e9tlM09tQ6LJHgpLy6WYt/ntj9EmrDBbFr0e9MJIbpkVMyPwSzehFX 0+Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=pYqar9YRVbwg/cwPFSOW3VAZBsAcUV1fDfATajXhv4U=; fh=T5vjsOk+LqmOpNHkVJQva5DBwF0yPkg+vX2TknFp1fw=; b=zLlzXICpkz7F0vUR/6YFac4V3ffidDRJcteFimm7GSUPZxeCKCwxFBQ7WQxBnaUknt Jd27InMsRXCPO65eEDhhgzfRCaKXRAA0JDXmlbx7X4GgegJWW5l39e9Ae5MuHcDciMp2 TwmqQEqe3QmaVTFB21jd4quon9Lt0mKfDxaV0ZyYpYvGJL6zPXkklRbaS15fiNQrQXGa RqElXlBmS1A2hNfs/RXYpREFpLVeohnQVJ9YnCULyVCjXhcqAQCd/aibpFI5j+V1LyMC jSWJ7owKAdWAdUGhTjA3t4yTRer1FoFTclxmER6NWIScVo7Ov6Z/Fz0ZoS5jqZCI7u6r v7MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gZFTatLF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id r66-20020a632b45000000b0056482047ae0si10303998pgr.723.2023.09.13.07.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 07:42:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gZFTatLF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 2BDE583E5AE8; Wed, 13 Sep 2023 04:38:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240364AbjIMLiO (ORCPT + 99 others); Wed, 13 Sep 2023 07:38:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237669AbjIMLiN (ORCPT ); Wed, 13 Sep 2023 07:38:13 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F4200173E; Wed, 13 Sep 2023 04:38:09 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F97FC433C7; Wed, 13 Sep 2023 11:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694605089; bh=NjwWLoIbmcBjw9qBYI11QfNE6lfJieDTK6MDYKZZGNE=; h=From:To:Cc:Subject:Date:From; b=gZFTatLF1uEsqurqOmmsA3CNkNaxJ0Zw84AnKKp0Lrc864Z/PUFoh0Ngvx5V4G0b4 V2BLSg7cbESyA9rSQmqum8mFtbLKnIv/F+l4pICNh8DEmr2RjeAcCO1QyRjhKmOF8+ wb5RBUhl6bqGOBLyihYqygeQLm1JYJ5DnNqlmH0th6wKpU5WIxiE4TLvW+4yBA56z1 xTU1GKqAbPMKyBtO+vNh5hmQA4Quqbw69FEjrhkJj/uswOEKCnLqMyF+3Ml8zW1vh7 fJBjlqnca0EpQ1pRZsG77TESna82DFx9gCdOBc+MFHTct2AQy4h+3IrceCKtLge7wx /wB+YDct+56Jg== From: Arnd Bergmann To: 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: [PATCH] Documentation: kbuild: explain handling optional dependencies Date: Wed, 13 Sep 2023 13:37:52 +0200 Message-Id: <20230913113801.1901152-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 04:38:13 -0700 (PDT) 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. 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 + +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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 2.39.2