From nobody Fri Jun 26 00:46:20 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gmcRw46Gcz6jdrq for ; Fri, 26 Jun 2026 00:46:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gmcRw3bDmz4013 for ; Fri, 26 Jun 2026 00:46:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782434780; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6t5Q6kFkMb4FyH+zdVEwcHgZsiik2RQirk3e+PtQN9o=; b=FUSonMdd5QCseDgdYs7kd/U1QAMSPP3ToiQQXZKaYVFYseS/h1QD2k15lGXQmX/f4279DY Kc1pRN6APbZ6Jbz3o52EWnofKkmdCOjnsrdTbHXHo5By61sWAw7frbkN3GYN7e1mzj5snM mvIUni5Y/EFvgikvejZXiK2QqZ+4sGwfHq8KMQwpV8sW7kJR6S6hHpXSxW/CVAu98olTDa 7Zr3L6efnvVBx73sUFny5lYOBSmoCL+JZG5kTqa0RGcLU4xGMbPmgaM+dPffyp8dgtpY+e Jn+Yq8dsNhrbrkSy/uno2yYnoZQVPkPUNQSdHunq52FkfSjY3BGKoepRGOP//Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782434780; a=rsa-sha256; cv=none; b=egouLMRBan+/fAweEuH8euJHjBzrfCMVOUfXmScQhETiA8LV6KaGW6IZTrC7YPk439qRwg Gd0/kz+uDMZR46P3ttubUdil2zXlZ+zvRETrHcsjP1YGAP3OolZs1tIlCWyvwrgeG1CQd7 wcVBCXjfHWUZ+ehQvD6dsHo/rY18LRUu2r9QVQ82vQUw72k+CL63nuNV/b+b1OQxKN3PpX 1GoptByCEzGiLaEMQBfQ9jaUAh/cRDawvPtPEO36pwVx4ibiwQi4/veUee+HVF/jkzJY4F 3EYWWMpae1ZFnqHzV6WYV2HBTZYV1gaiy7+we1SSmsVTaHspLg7v6Oiy3XgjYQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782434780; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6t5Q6kFkMb4FyH+zdVEwcHgZsiik2RQirk3e+PtQN9o=; b=IJAU1HqlxzI9DGk2zeNIp01p8KlGw5mnocEQVGlKSvJQZWeKQZTJaKUAEydMs00u1uUne+ P9HqeUyPCTyETyn2qHHg9qsgJuZa/U4nATQy0CLOB7gJsUiGHwyuhQ3jwwH2XRL2nJ/Yku 2JKLOhJ6DK5leCGdXEnsV7VWeTEb/DY84iJpG1LvB0c/bA+xYFMFouGke9H7dg7emnuwR3 fbrk2hjN6KXU5qBMbmi0c7Pql7yNJk4Wt2gWCrrxcPvVvTDcYQEFASegBv8VNmBbydGGOY 6slelkupewZrWh673usmpu3o4sXwjQMj7dOdmNz+sGivb7d+Ad/JOywZ6Kv1Dw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gmcRw0zsJz1SZ1 for ; Fri, 26 Jun 2026 00:46:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3dd8f by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 26 Jun 2026 00:46:20 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: d946a88e0ce3 - main - build.7: explain how to build KBI-compatible standalone module List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d946a88e0ce347a9a6fdbfdae0b23ef192b9bddc Auto-Submitted: auto-generated Date: Fri, 26 Jun 2026 00:46:20 +0000 Message-Id: <6a3dcbdc.3dd8f.2ca4a8c@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d946a88e0ce347a9a6fdbfdae0b23ef192b9bddc commit d946a88e0ce347a9a6fdbfdae0b23ef192b9bddc Author: Konstantin Belousov AuthorDate: 2026-06-26 00:21:36 +0000 Commit: Konstantin Belousov CommitDate: 2026-06-26 00:44:46 +0000 build.7: explain how to build KBI-compatible standalone module Reviewed by: imp, kevans Sponsored by: The FreeBSD Foundation MFC after: 3 days Differential revision: https://reviews.freebsd.org/D57859 --- share/man/man7/build.7 | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/share/man/man7/build.7 b/share/man/man7/build.7 index 9db04f12c15a..0ec12cf33cbc 100644 --- a/share/man/man7/build.7 +++ b/share/man/man7/build.7 @@ -1116,6 +1116,46 @@ Rebuild and reinstall a single loadable kernel module, in this case cd /usr/src/sys/modules/sound make all install clean cleandepend KMODDIR=/boot/kernel .Ed +.Pp +Important detail is that the kernel binary interface is affected +by its configuration. +Modules build outside of the regular kernel build procedure still +must be built against the target kernel configuration, which is +defined by the set of the +.Pa opt_*.h +headers generated by +.Xr config 8 . +Use the +.Va KERNBUILDDIR +variable to point the module build to the configured kernel. +There is no need to actually build the configured kernel in +that directory, module build only consumes the headers from it. +.Pp +Additionally, the +.Va SYSDIR +environment variable may be useful to point to specific kernel source +tree used to build the target kernel, since the kernel headers +define the binary interface for modules. +.Pp +Assuming that the +.Fx +sources are located in the +.Pa /home/user/src +directory, the used kernel config is named +.Vd MY_KERNEL +and that the module sources are in +.Pa my-module +directory, the following sequence of the commands would populate +.Pa /home/user/my-kernel-builddir +directory with the +.Pa opt_*.h +headers and then build the module compatible with +.Vd MY_KERNEL . +.Bd -literal -offset -indent +config -d /home/user/my-kernel-builddir -s /home/user/src/sys/amd64/conf MY-KERNEL +cd my-module +make all KERNBUILDDIR=/home/user/my-kernel-builddir SYSDIR +.Ed .Ss Example 5: Quickly rebuild a kernel in place Quickly rebuild and reinstall the kernel, only recompiling the files changed since last build; note that this will only work if the full