Whamcloud - gitweb
LU-16961 clang: plugins and build system integration
authorTimothy Day <timday@amazon.com>
Mon, 11 Mar 2024 17:38:04 +0000 (10:38 -0700)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 16 Mar 2024 08:16:57 +0000 (08:16 +0000)
commitc155fab119d4e25cd6c41803d3343ae6117f0f8f
tree228495ec2708361307dd62cd5437254c30283cbb
parent37ceb7d5c59901e8e05b3d3acfe440b381e9e82f
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.

Lustre-change: https://review.whamcloud.com/51659
Lustre-commit: d684885098c40fee2951feb410bec739717ac9bc

Test-Parameters: trivial
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: I747ed91b53e765cc58e91a3eb9ec6c12b9908a96
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54350
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@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