Whamcloud - gitweb
LU-16961 clang: plugins and build system integration 59/51659/4
authorTimothy Day <timday@amazon.com>
Thu, 13 Jul 2023 04:19:41 +0000 (04:19 +0000)
committerOleg Drokin <green@whamcloud.com>
Thu, 31 Aug 2023 06:33:21 +0000 (06:33 +0000)
commitd684885098c40fee2951feb410bec739717ac9bc
tree38c3dc409ec73b7f4756648d3e21ff0c581178bf
parenta1bc7a84ce5b3b649fd590a80645f299205024c2
LU-16961 clang: plugins and build system integration

Clang has a plugin system. Compiler extensions can be created
by making a shared library and loading it via the "-fplugin"
options. This makes it simple to implement custom warnings
and static analyzers.

This patch adds a plugin to detect functions that should have
been made static. This plugin has been run over the majority
of the Lustre tree and patches have been submitted for all
warnings. The plugin did not return any false positives in
my testing.

It also add the "--enable-compiler-plugins" configure option,
which automatically builds and sets up the in-tree C compiler
plugins. The option force-enables the plugin regardless of
which compiler is in use. This behavior could be changed if
there is ever a need to support GCC specific plugins.

Also, add the configure checks needed to support building C++
in the Lustre tree. Clang and GCC plugins (and the compilers
themselves) are written in C++.

The license for the plugin mirrors that of the LLVM project
itself. This leaves the door open for contributing this
plugin upstream in the future. This isn't being upstreamed
now because it lacks any significant user community. Hence,
the plugin does not appear to meet the requirements for
upstreaming based on https://clang.llvm.org/get_involved.html.

Test-Parameters: trivial
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: I747ed91b53e765cc58e91a3eb9ec6c12b9908a96
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51659
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
autoMakefile.am
cc-plugins/.gitignore [new file with mode: 0644]
cc-plugins/FindStatic.cpp [new file with mode: 0644]
cc-plugins/Makefile.am [new file with mode: 0644]
config/lustre-build.m4
config/lustre-compiler-plugins.m4 [new file with mode: 0644]
config/lustre-toolchain.m4