Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4060426rdb; Thu, 14 Sep 2023 10:29:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGW3Nc0/veo7iSzysBwp6g7yMKXTH9aFrlGlpuu7DVc+r+LLC/DY+2iwg1fRlWVd1o1MVYA X-Received: by 2002:a17:903:1cf:b0:1b5:522a:1578 with SMTP id e15-20020a17090301cf00b001b5522a1578mr3856795plh.29.1694712569618; Thu, 14 Sep 2023 10:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694712569; cv=none; d=google.com; s=arc-20160816; b=jAkrblJyJW86jrgLvuF7BUMtK9TnMKOMVatP8Fu9HXJFZeQ3aHRhCiqhGYyj3vrZES yMocOdzHoGSOXhi/Lvi3eeFKwbMgvz5c8Y+QPIs+GpQ+rjVCWOviGDYk7IwNGzcVegqq GS+hfaimtWzZlz35KZ96sQkPii6uuZsK6ZM4I4XsgAKFoTn6dmiIjPLLH2CIR34DsQuJ UoY0mAKNSVMyfQ1WUQ0rl398S6Im0yt1pbBxOj0aiaPP+ZmqHcCbzZwlglR9L/aVzuU+ lMqwauqHETa9vVG1y1ULvnQpdi0hSxNDvYmoYfx7gl3k613uLtvl5STiBXJgEHBX/iJf ND2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=u3LkUS2Pm2JCYUEnGdleEoBOoVhJUBbDXVNh1NVZcb0=; fh=9jSASVlJbG88vqg1LaWpnQRVgK7VQsYWTw7Q7k+Jhp4=; b=L8sISkDdB1xvnQ1OKn8/B48D2U87j+BNGRKvQnfFGQZa9y2tPjUpwSCI+1nhCX7xTt l/JHUfv/xqS+jRaitRi8DQfSGhHRVRqC5T2VNUfUimhLNS/n7pglqPagrJPIAcfNLdFB dpsYXFsP/yHV+4WU6THEG7sQGqfVb3rMnRxkCXqatafxOvlJ2ax2R4yXAag7Pd+kRXVL mISiwuKb26g8ksNe0Cxlmxt11BExQyhL1HO9Ycv2et/r2jiK02jYAa0NIXH/wroWQ9pN eFai6SHFODElCquMUuD1dLbdKnKFHC4X6irPKRLalY3lvCtm7kmR8vrDzx7fOcCS7Xcl 3oag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Wqui1O5q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id ky15-20020a170902f98f00b001c3976e22f5si1876575plb.515.2023.09.14.10.29.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:29:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Wqui1O5q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 58DCF832C34C; Thu, 14 Sep 2023 10:26:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240743AbjINRZh (ORCPT + 99 others); Thu, 14 Sep 2023 13:25:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240675AbjINRZP (ORCPT ); Thu, 14 Sep 2023 13:25:15 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E36A646BA; Thu, 14 Sep 2023 10:24:02 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80430C433CA; Thu, 14 Sep 2023 17:24:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694712242; bh=ZhpxjopJ3z7akt/jZEVl/F9TEAnY0hg7X8xCLV/k4O4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Wqui1O5qsQOM/LFdsntH0+UWUe/39BdypVs0luN1i69deScv28jm3hrnsmhl23i1k 7viCHzhArkfZxTF7+1SzNq0Ah82tRT1enVRzTj4NO1lX2YhLNbkyY+2PuaZoOQf38c kqwaSQflYbmRzOrJyMd93qebTd+AF89+YVrObDprNnleECdpVXtIO8UEb9OIdzQeKl seZ5vZwS4VjuUlZjEqD40C7kzblInnLqNWwymqnuOnaBUB5OCagNHapwfb8QRc5pGW KV/X0vYq79lXvsg6YpahUg+Q8/jse6tl2TjmDGJuD3MM0K8C1RDMqYzxNllZ3MVTVw iq6bYM+2zmRSQ== Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-570e63f5224so1252278eaf.0; Thu, 14 Sep 2023 10:24:02 -0700 (PDT) X-Gm-Message-State: AOJu0YytmxBJIvVzljYUiQqEc02RzSef2UDIdAhXsqNGLLo/pICfWwJL svZyxg4BdrNl9yC+o9dWMSUCM1Fpqbw1Uwq20BY= X-Received: by 2002:a05:6870:9691:b0:1a6:cfcc:befd with SMTP id o17-20020a056870969100b001a6cfccbefdmr1544368oaq.5.1694712241904; Thu, 14 Sep 2023 10:24:01 -0700 (PDT) MIME-Version: 1.0 References: <20230913113801.1901152-1-arnd@kernel.org> <874jjwx44g.fsf@intel.com> In-Reply-To: From: Masahiro Yamada Date: Fri, 15 Sep 2023 02:23:25 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] Documentation: kbuild: explain handling optional dependencies To: Arnd Bergmann Cc: Jani Nikula , Arnd Bergmann , Jonathan Corbet , Sakari Ailus , Javier Martinez Canillas , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 (groat.vger.email [0.0.0.0]); Thu, 14 Sep 2023 10:26:21 -0700 (PDT) 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 groat.vger.email On Thu, Sep 14, 2023 at 11:57=E2=80=AFPM Arnd Bergmann wrot= e: > > On Thu, Sep 14, 2023, at 15:42, Jani Nikula wrote: > > On Wed, 13 Sep 2023, Arnd Bergmann wrote: > >> From: Arnd Bergmann > >> > >> +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 lo= gic > >> +uses the slighly counterintuitive > >> + > >> + config FOO > >> + bool "Support for foo hardware" > >> + depends on BAR || !BAR > > > > depends on BAR || BAR=3Dn > > > > 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=3Dn" | wc -l > > 107 > > > > Maybe worth mentioning both? > > I fear that would add more confusion than it avoids: > "!BAR" is actually different from "BAR=3Dn", but > "BAR || !BAR" is the same as "BAR || BAR=3Dn" here, and > trying to explain this in the documentation would either > make it incorrect or unhelpfully complicated. The rules are already explained in line 231-278 of Documentation/kbuild/kconfig-language.rst y, m, n are internally 2, 1, 0. !A returns (2 - A). A=3DB returns 2 if the equation is true, 0 otherwise. A||B returns max(A,B) Given those in my mind, this is simple math. For each case of BAR=3Dy, =3Dm, =3Dn, BAR 2 1 0 !BAR 0 1 2 BAR=3Dn 0 0 2 BAR||!BAR 2 1 2 BAR||BAR=3Dn 2 1 2 BAR!=3Dm||m 2 1 2 So, the last three are equivalent. They are equally complicated and confusing, though. After all, what we are doing is to create this matrix: | WIREGUARD | y m n ---------------------------- y | O O O IPV6 m | X O O n | O O O It is unclear why WIREGUARD must be entirely disabled just because of the optional feature being modular. My preference is to use IS_REACHABLE(CONFIG_IPV6) instead of IS_ENABLED(CONFIG_IPV6) under drivers/net/wireguard, then get rid of "depends on IPV6 || !IPV6) If you want to make it clearer on the Kconfig level, perhaps the following is also possible. config WIREGUARD tristate "WireGuard" config WIREGUARD_IPV6 def_bool y depends on WIREGUARD depends on IPV6 >=3D WIREGUARD config IPV6 tristate "IPV6" --=20 Best Regards Masahiro Yamada