• Vassil Vassilev's avatar
    Enable C++ modules for CLHEP · caa0aa3b
    Vassil Vassilev authored and Lynn Garren's avatar Lynn Garren committed
    The C++ modules feature as described in https://clang.llvm.org/docs/Modules.html
    allow producing a binary header representation to avoid redundant header
    This feature is used in ROOT's dictionary system since ROOT v6.20:
    CMSSW and other experiment migrate their dictionaries to use the provided by
    ROOT C++ modules support: https://github.com/cms-sw/cmssw/issues/15248
    Dictionaries which transiently include clhep can be further optimized by
    building a separate module for CLHEP which this MR aims for.
    The current patch introduces a module.modulemap file containing a mapping between
    a binary artifact (a module or a pcm file) and a set of header files. The C++
    modules are more picky on translation unit encapsulation and thus require all
    headers which a translation unit uses to be included. In addition to the
    missing include we outline a few virtual destructors to avoid pollution of .o
    files with weak virtual tables.
    This patch enables builds with modules via rootcling/genreflex/rootcint and
    enables compile-time module builds if configured like:
    cmake -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-fmodules -Xclang -fmodules-local-submodule-visibility" ../clhep/
    The module.modulemap file is easy to maintain as it globs for the well-behaved
    header files and enumerates already the ones needed special treatment.
    Once merged we will backport this to cmssw.