From patchwork Wed Sep 13 11:37:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13382880 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EFE1EDEC45 for ; Wed, 13 Sep 2023 11:38:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240268AbjIMLiO (ORCPT ); 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 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org 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 Reviewed-by: Javier Martinez Canillas Reviewed-by: Sakari Ailus Reviewed-by: Nicolas Schier --- 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~