Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5789064rdb; Sun, 17 Sep 2023 12:21:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHvud4ZnZuESjVrFE81aBjKiqWVXYmb/p9UO85J2UaCcCJNgCTqO3i2BvqJHSC1o0pf60Q4 X-Received: by 2002:a17:903:41c3:b0:1c4:4a58:ff65 with SMTP id u3-20020a17090341c300b001c44a58ff65mr7201968ple.64.1694978501909; Sun, 17 Sep 2023 12:21:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694978501; cv=none; d=google.com; s=arc-20160816; b=lFKDszREfaVP0nv6+d+TKs2ao+C3JQOuqhcnmLqXUi0Ysr2NRwv9Sy8kButHDnCqIZ K+pYkA5YsA3v0Lrl2Ahp9iTzoqMn9sH3+XEBANJ3p7oMsJ/6UrG7SUFYAmBTsQ7KYph8 ykt+te7GHf/L1W1CZf9cvgH1wm+e33MO3Nc9spsWz67o2E4oTQZpZKS20AXBWyTNkhvL N+50EFaKW2S+OOhi2GSAl71mW3lMYLztqlTRgQ5iVln51neoxx602ZwC08Pnb6hCA1Qh BpWXYND9gyW9Zoy+SFTmqj0/oSNZ5YdNEYAjwSfBx3l9vjPpv+hgCZ2ajr6hH1l/E+A4 rS8w== 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=V6lKJaMJNy5UqS5OhiaH7K6+jWIbr0XWlcS+N2sg0Io=; fh=k5ekymPMm4m3LGPNeauBlQT++u+abAC+KV5nd8f/plA=; b=oS+DAPnBfIRNLEDwBpqWuJ0x2DVoySiKShsKd7oHXWnUwalYql1mstkfSLelSIzfx4 JzmBtScxENsgRoTCPpRlJ/nSZRd6JxkRTldt0AxpspMKkzontSs31CjyKByytHfVFHEh X5L5Kf5EERsDAfQej6eBUbbabI2WtNkSGInuW+bglBNIvywqc4PBaBgSIW4BJog1RaBE YS0Jau5cZVs7Q1Ljbwolh7AfKjd82lDnyO2+pDJ3kTGDkhJGUlZyM/xPuVg5pbhJE3L2 zSeZQTF+ggwBjc12ClupcGud8g0VFYDHSbe+EMwPwwGS28EAoD/p5BQFFzKFWnKy8ieu Jb2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oIzJcm+y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id x7-20020a170902a38700b001c46ce1a50bsi549949pla.20.2023.09.17.12.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 12:21:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oIzJcm+y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 049AC81F3462; Sun, 17 Sep 2023 12:21:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238306AbjIQTUb (ORCPT + 99 others); Sun, 17 Sep 2023 15:20:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231801AbjIQTUW (ORCPT ); Sun, 17 Sep 2023 15:20:22 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 201A8115; Sun, 17 Sep 2023 12:20:17 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66821C433C9; Sun, 17 Sep 2023 19:20:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694978416; bh=zlezv61pkEtIb39QJV+KksqxpQMU0fbcIUj51bSEwrY=; h=From:To:Cc:Subject:Date:From; b=oIzJcm+yqSjU0N+/nDHU6W2dBiG4y1dTlpVyxYVZl0TvEkebI5Rsm40kS+rbblFIW J9xYHqsfQSEGE/hrzWSnkCdsJc14eqkd2Z6cYnhuD2DqR3KVwaVBv1ceygvjxD7mp0 uSsZ9ztBuXxelRCElu1PTfkmN1VXpCVK1alE09zCaD6Ea3nwiJToHlkkSga0AmfxZF kJgY8RZB3FIxnaemnt6Qai0L4mOWctRk2BrqAUoNF6zQgCQJGZ894J/ExJ4LauKIxE 23CBrwm9tnAbGXXh1B2eSPvGstmkbum93JCxt3rbGQriU32RhBdOPt18egKTEpabXP kIIlN/4gJDHQQ== From: Arnd Bergmann To: Masahiro Yamada , Jonathan Corbet Cc: Arnd Bergmann , Javier Martinez Canillas , Sakari Ailus , Nicolas Schier , Nathan Chancellor , Nick Desaulniers , linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] Documentation: kbuild: explain handling optional dependencies Date: Sun, 17 Sep 2023 21:19:59 +0200 Message-Id: <20230917192009.254979-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 pete.vger.email 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 (pete.vger.email [0.0.0.0]); Sun, 17 Sep 2023 12:21:38 -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. Reviewed-by: Javier Martinez Canillas Reviewed-by: Sakari Ailus Reviewed-by: Nicolas Schier Signed-off-by: Arnd Bergmann --- v2: fix typos pointed out 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..0135905c0aa35 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 slightly counterintuitive:: + + config FOO + tristate "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 + tristate "Support for foo hardware" + depends on BAR_OPTIONAL + + config BAR_OPTIONAL + def_tristate BAR || !BAR + Kconfig recursive dependency limitations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 2.39.2