linux/Documentation/kbuild
Nathan Chancellor e9c281928c kbuild: Make $(LLVM) more flexible
The LLVM make variable allows a developer to quickly switch between the
GNU and LLVM tools. However, it does not handle versioned binaries, such
as the ones shipped by Debian, as LLVM=1 just defines the tool variables
with the unversioned binaries.

There was some discussion during the review of the patch that introduces
LLVM=1 around versioned binaries, ultimately coming to the conclusion
that developers can just add the folder that contains the unversioned
binaries to their PATH, as Debian's versioned suffixed binaries are
really just symlinks to the unversioned binaries in /usr/lib/llvm-#/bin:

$ realpath /usr/bin/clang-14
/usr/lib/llvm-14/bin/clang

$ PATH=/usr/lib/llvm-14/bin:$PATH make ... LLVM=1

However, that can be cumbersome to developers who are constantly testing
series with different toolchains and versions. It is simple enough to
support these versioned binaries directly in the Kbuild system by
allowing the developer to specify the version suffix with LLVM=, which
is shorter than the above suggestion:

$ make ... LLVM=-14

It does not change the meaning of LLVM=1 (which will continue to use
unversioned binaries) and it does not add too much additional complexity
to the existing $(LLVM) code, while allowing developers to quickly test
their series with different versions of the whole LLVM suite of tools.

Some developers may build LLVM from source but not add the binaries to
their PATH, as they may not want to use that toolchain systemwide.
Support those developers by allowing them to supply the directory that
the LLVM tools are available in, as it is no more complex to support
than the version suffix change above.

$ make ... LLVM=/path/to/llvm/

Update and reorder the documentation to reflect these new additions.
At the same time, notate that LLVM=0 is not the same as just omitting it
altogether, which has confused people in the past.

Link: https://lore.kernel.org/r/20200317215515.226917-1-ndesaulniers@google.com/
Link: https://lore.kernel.org/r/20220224151322.072632223@infradead.org/
Suggested-by: Masahiro Yamada <masahiroy@kernel.org>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2022-03-31 12:03:46 +09:00
..
gcc-plugins.rst gcc-plugins: Remove cyc_complexity 2021-10-21 08:41:47 -07:00
headers_install.rst Kbuild updates for v5.3 2019-07-12 16:03:16 -07:00
index.rst Kbuild updates for v5.7 2020-03-31 16:03:39 -07:00
issues.rst docs: kbuild: fix build with pdf and fix some minor issues 2019-07-15 11:03:04 -03:00
kbuild.rst kbuild: Add environment variables for userprogs flags 2022-02-14 10:37:32 +09:00
kconfig-language.rst doc: kbuild: fix default in imply table 2022-01-08 18:28:21 +09:00
kconfig-macro-language.rst kconfig: doc: fix $(fileno) to $(filename) 2020-12-21 16:01:44 +09:00
Kconfig.recursion-issue-01 kbuild: document recursive dependency limitation / resolution 2015-10-08 15:36:16 +02:00
Kconfig.recursion-issue-02 docs: use the lore redirector everywhere 2021-10-12 13:58:19 -06:00
kconfig.rst kconfig: change defconfig_list option to environment variable 2021-04-14 15:22:48 +09:00
Kconfig.select-break kbuild: document recursive dependency limitation / resolution 2015-10-08 15:36:16 +02:00
llvm.rst kbuild: Make $(LLVM) more flexible 2022-03-31 12:03:46 +09:00
makefiles.rst kbuild: Add environment variables for userprogs flags 2022-02-14 10:37:32 +09:00
modules.rst kbuild: doc: replace arch/$(ARCH)/ with arch/$(SRCARCH)/ 2020-12-21 13:56:58 +09:00
reproducible-builds.rst gcc-plugins: fix gcc-plugins directory path in documentation 2020-06-28 12:16:55 +09:00