<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/Documentation/kbuild/modules.rst, branch linux-7.1.y</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=linux-7.1.y</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=linux-7.1.y'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2026-03-31T23:42:52+00:00</updated>
<entry>
<title>documentation: remove references to *_gpl sections</title>
<updated>2026-03-31T23:42:52+00:00</updated>
<author>
<name>Siddharth Nayyar</name>
<email>sidnayyar@google.com</email>
</author>
<published>2026-03-26T21:25:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=3b1299f25b07ef83e020d049dfc62ced9c09450d'/>
<id>urn:sha1:3b1299f25b07ef83e020d049dfc62ced9c09450d</id>
<content type='text'>
*_gpl sections are no longer present in the kernel binary.

Signed-off-by: Siddharth Nayyar &lt;sidnayyar@google.com&gt;
Reviewed-by: Petr Pavlu &lt;petr.pavlu@suse.com&gt;
Signed-off-by: Sami Tolvanen &lt;samitolvanen@google.com&gt;
</content>
</entry>
<entry>
<title>Documentation/kbuild: Fix indentation in modules.rst example</title>
<updated>2025-03-16T15:29:51+00:00</updated>
<author>
<name>Kefan Liu</name>
<email>liukefan24s@ict.ac.cn</email>
</author>
<published>2025-03-11T15:45:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=82e7a5997170f105dc5452f83f349e6e625e61f5'/>
<id>urn:sha1:82e7a5997170f105dc5452f83f349e6e625e61f5</id>
<content type='text'>
Correct the indentation in an example within the `modules.rst` file
to improve readability.

Signed-off-by: Kefan Liu &lt;liukefan24s@ict.ac.cn&gt;
Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
<entry>
<title>Documentation/kbuild: Document storage of symbol information</title>
<updated>2025-01-10T17:36:36+00:00</updated>
<author>
<name>Matthew Maurer</name>
<email>mmaurer@google.com</email>
</author>
<published>2025-01-03T17:37:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=272f8a6d625a0cf7fba9c5af5202edc84dee326c'/>
<id>urn:sha1:272f8a6d625a0cf7fba9c5af5202edc84dee326c</id>
<content type='text'>
Document where exported and imported symbols are kept, format options,
and limitations.

Signed-off-by: Matthew Maurer &lt;mmaurer@google.com&gt;
Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
<entry>
<title>kbuild: allow to start building external modules in any directory</title>
<updated>2024-11-27T23:11:55+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-11-10T01:34:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=8cd07cc6c88cab5cbfe5dd83aacf860a209eb521'/>
<id>urn:sha1:8cd07cc6c88cab5cbfe5dd83aacf860a209eb521</id>
<content type='text'>
Unless an explicit O= option is provided, external module builds must
start from the kernel directory.

This can be achieved by using the -C option:

  $ make -C /path/to/kernel M=/path/to/external/module

This commit allows starting external module builds from any directory,
so you can also do the following:

  $ make -f /path/to/kernel/Makefile M=/path/to/external/module

The key difference is that the -C option changes the working directory
and parses the Makefile located there, while the -f option only
specifies the Makefile to use.

As shown in the examples in Documentation/kbuild/modules.rst, external
modules usually have a wrapper Makefile that allows you to build them
without specifying any make arguments. The Makefile typically contains
a rule as follows:

    KDIR ?= /path/to/kernel
    default:
            $(MAKE) -C $(KDIR) M=$(CURDIR) $(MAKECMDGOALS)

The log will appear as follows:

    $ make
    make -C /path/to/kernel M=/path/to/external/module
    make[1]: Entering directory '/path/to/kernel'
    make[2]: Entering directory '/path/to/external/module'
      CC [M]  helloworld.o
      MODPOST Module.symvers
      CC [M]  helloworld.mod.o
      CC [M]  .module-common.o
      LD [M]  helloworld.ko
    make[2]: Leaving directory '/path/to/external/module'
    make[1]: Leaving directory '/path/to/kernel'

This changes the working directory twice because the -C option first
switches to the kernel directory, and then Kbuild internally recurses
back to the external module directory.

With this commit, the wrapper Makefile can directly include the kernel
Makefile:

    KDIR ?= /path/to/kernel
    export KBUILD_EXTMOD := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
    include $(KDIR)/Makefile

This avoids unnecessary sub-make invocations:

    $ make
      CC [M]  helloworld.o
      MODPOST Module.symvers
      CC [M]  helloworld.mod.o
      CC [M]  .module-common.o
      LD [M]  helloworld.ko

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
Reviewed-by: Nicolas Schier &lt;nicolas@fjasle.eu&gt;
</content>
</entry>
<entry>
<title>kbuild: support building external modules in a separate build directory</title>
<updated>2024-11-27T23:11:55+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-11-10T01:34:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=11b3d5175e6bc3779159228e6077be202d2b0069'/>
<id>urn:sha1:11b3d5175e6bc3779159228e6077be202d2b0069</id>
<content type='text'>
There has been a long-standing request to support building external
modules in a separate build directory.

This commit introduces a new environment variable, KBUILD_EXTMOD_OUTPUT,
and its shorthand Make variable, MO.

A simple usage:

 $ make -C &lt;kernel-dir&gt; M=&lt;module-src-dir&gt; MO=&lt;module-build-dir&gt;

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
Reviewed-by: Nicolas Schier &lt;nicolas@fjasle.eu&gt;
</content>
</entry>
<entry>
<title>kbuild: doc: replace "gcc" in external module description</title>
<updated>2024-09-23T18:07:21+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-09-19T17:37:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=fa911d1f377bbe4cc47e58afbd8fff7750b7ac62'/>
<id>urn:sha1:fa911d1f377bbe4cc47e58afbd8fff7750b7ac62</id>
<content type='text'>
Avoid "gcc" since it is not the only compiler supported by Kbuild.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
Reviewed-by: Nicolas Schier &lt;n.schier@avm.de&gt;
</content>
</entry>
<entry>
<title>kbuild: doc: describe the -C option precisely for external module builds</title>
<updated>2024-09-23T18:07:21+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-09-19T17:37:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=2eb5d7f2429945aeb4730c7c310a0e1b5ae4c8d0'/>
<id>urn:sha1:2eb5d7f2429945aeb4730c7c310a0e1b5ae4c8d0</id>
<content type='text'>
Building external modules is typically done using this command:

  $ make -C &lt;KERNEL_DIR&gt; M=&lt;EXTMOD_DIR&gt;

Here, &lt;KERNEL_DIR&gt; refers to the output directory where the kernel was
built, not the kernel source directory.

When the kernel is built in the source tree, there is no ambiguity, as
the output directory and the source directory are the same.

If the kernel was built in a separate build directory, &lt;KERNEL_DIR&gt;
should be the kernel output directory. Otherwise, Kbuild cannot locate
necessary build artifacts. This has been the method for building
external modules against a pre-built kernel in a separate directory
for over 20 years. [1]

If you pass the kernel source directory to the -C option, you must also
specify the kernel build directory using the O= option. This approach
works as well, though it results in a slightly longer command:

  $ make -C &lt;KERNEL_SOURCE_DIR&gt; O=&lt;KERNEL_BUILD_DIR&gt; M=&lt;EXTMOD_DIR&gt;

Some people mistakenly believe that O= should specify a build directory
for external modules when used together with M=. This commit adds more
clarification to Documentation/kbuild/kbuild.rst.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=e321b2ec2eb2993b3d0116e5163c78ad923e3c54

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
Reviewed-by: Nicolas Schier &lt;n.schier@avm.de&gt;
</content>
</entry>
<entry>
<title>kbuild: doc: remove the description about shipped files</title>
<updated>2024-09-23T18:07:21+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-09-19T17:37:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=e873fb948283a595bba6228efc69ed1191f45689'/>
<id>urn:sha1:e873fb948283a595bba6228efc69ed1191f45689</id>
<content type='text'>
The use of shipped files is discouraged in the upstream kernel these
days. [1]

Downstream Makefiles have the freedom to use shipped files or other
options to handle binaries, but this should not be advertised in the
upstream document.

[1]: https://lore.kernel.org/all/CAHk-=wgSEi_ZrHdqr=20xv+d6dr5G895CbOAi8ok+7-CQUN=fQ@mail.gmail.com/

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
Reviewed-by: Nicolas Schier &lt;n.schier@avm.de&gt;
</content>
</entry>
<entry>
<title>kbuild: doc: drop section numbering, use references in modules.rst</title>
<updated>2024-09-23T18:07:21+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-09-19T17:37:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=803d5059529aaabd53aabd5cd2c7b405824601b7'/>
<id>urn:sha1:803d5059529aaabd53aabd5cd2c7b405824601b7</id>
<content type='text'>
Do similar to commit 1a4c1c9df72e ("docs/kbuild/makefiles: drop section
numbering, use references").

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
<entry>
<title>kbuild: doc: throw out the local table of contents in modules.rst</title>
<updated>2024-09-23T18:07:21+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-09-19T17:37:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=7813cd68ea7ae909676aea19411b5c9c20436ebb'/>
<id>urn:sha1:7813cd68ea7ae909676aea19411b5c9c20436ebb</id>
<content type='text'>
Do similar to commit 5e8f0ba38a4d ("docs/kbuild/makefiles: throw out the
local table of contents").

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
</feed>
