linux-stable/Documentation/dev-tools
Masahiro Yamada 13b25489b6 kbuild: change working directory to external module directory with M=
Currently, Kbuild always operates in the output directory of the kernel,
even when building external modules. This increases the risk of external
module Makefiles attempting to write to the kernel directory.

This commit switches the working directory to the external module
directory, allowing the removal of the $(KBUILD_EXTMOD)/ prefix from
some build artifacts.

The command for building external modules maintains backward
compatibility, but Makefiles that rely on working in the kernel
directory may break. In such cases, $(objtree) and $(srctree) should
be used to refer to the output and source directories of the kernel.

The appearance of the build log will change as follows:

[Before]

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

[After]

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

Printing "Entering directory" twice is cumbersome. This will be
addressed later.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>
2024-11-28 08:10:23 +09:00
..
kunit The core clk framework is left largely untouched this time around except for 2024-09-23 15:01:48 -07:00
autofdo.rst kbuild: Add AutoFDO support for Clang build 2024-11-06 22:41:09 +09:00
checkpatch.rst scripts: checkpatch: check unused parameters for function-like macro 2024-05-11 15:51:44 -07:00
checkuapi.rst docs: dev-tools: Add UAPI checker documentation 2023-12-29 22:25:21 +09:00
clang-format.rst Docs: Move clang-format from process/ to dev-tools/ 2024-06-26 16:36:00 -06:00
coccinelle.rst kbuild: change working directory to external module directory with M= 2024-11-28 08:10:23 +09:00
gcov.rst selftests: rds: add testing infrastructure 2024-08-09 13:18:46 +01:00
gdb-kernel-debugging.rst docs/scripts/gdb: add necessary make scripts_gdb step 2023-01-26 11:21:05 -07:00
gpio-sloppy-logic-analyzer.rst gpio: add sloppy logic analyzer using polling 2024-07-01 10:54:11 +02:00
index.rst kbuild: Add Propeller configuration for kernel build 2024-11-27 09:38:27 +09:00
kasan.rst - Sumanth Korikkar has taught s390 to allocate hotplug-time page frames 2024-03-14 17:43:30 -07:00
kcov.rst kcov: improve documentation 2023-04-08 13:45:36 -07:00
kcsan.rst docs: update dev-tools/kcsan.rst url about KTSAN 2024-09-04 08:04:10 -06:00
kfence.rst kfence: introduce burst mode 2024-09-01 20:26:03 -07:00
kgdb.rst Documentation: kgdb: Replace deprecated remotebaud 2022-01-07 09:33:13 -07:00
kmemleak.rst docs: kmemleak: adjust to config renaming 2023-04-20 17:53:38 -06:00
kmsan.rst kmsan: allow disabling KMSAN checks for the current task 2024-07-03 19:30:22 -07:00
kselftest.rst selftests: Add information about TAP conformance in tests 2024-07-11 11:23:54 -06:00
ktap.rst Documentation: dev-tools: Clarify requirements for result description 2022-12-12 14:13:48 -07:00
propeller.rst kbuild: Add Propeller configuration for kernel build 2024-11-27 09:38:27 +09:00
sparse.rst Documentation/sparse: add hints about __CHECKER__ 2022-03-23 19:00:33 -07:00
testing-overview.rst Documentation: dev-tools: Add link to RV docs 2024-03-29 08:27:21 -06:00
ubsan.rst ubsan: Remove CONFIG_UBSAN_SANITIZE_ALL 2024-02-06 02:21:38 -08:00