]> git.itanic.dy.fi Git - linux-stable/commit
kbuild: resolve symlinks for O= properly
authorMasahiro Yamada <masahiroy@kernel.org>
Fri, 15 Dec 2023 16:06:37 +0000 (01:06 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Fri, 29 Dec 2023 13:25:21 +0000 (22:25 +0900)
commit7beba04eb305393e3f8386390f25b4a9475f27f2
tree8e35c7f8a4676e4468ebb7587e660ab0ddcadc61
parent8c88bc5b489e785c7ead94ce6fc3adb7f76e8715
kbuild: resolve symlinks for O= properly

Currently, Kbuild follows the logical chain of directories for the O=
option, just like 'cd' (or 'realpath --logical') does.

Example:

    $ mkdir -p /tmp/a /tmp/x/y
    $ ln -s /tmp/x/y /tmp/a/b
    $ realpath /tmp/a/b/..
    /tmp/x
    $ realpath --logical /tmp/a/b/..
    /tmp/a
    $ make O=/tmp/a/b/.. defconfig
    make[1]: Entering directory '/tmp/a'
      [snip]
    make[1]: Leaving directory '/tmp/a'

'make O=/tmp/a/b/.. defconfig' creates the kernel configuration in
/tmp/a instead of /tmp/x despite /tmp/a/b/.. resolves to /tmp/x.

This is because Kbuild internally uses the 'cd ... && pwd' for the
path resolution, but this behavior is not predictable for users.
Additionally, it is not consistent with how the Kbuild handles the
M= option or GNU Make works with 'make -C /tmp/a/b/..'.

Using the physical directory structure for the O= option seems more
reasonable.

The comment says "expand a shell special character '~'", but it has
already been expanded to the home directory in the command line.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>
Makefile