Skip to content

Commit

Permalink
Enable C++ modules for CLHEP
Browse files Browse the repository at this point in the history
The C++ modules feature as described in https://clang.llvm.org/docs/Modules.html
allow producing a binary header representation to avoid redundant header
reparsing.

This feature is used in ROOT's dictionary system since ROOT v6.20:
https://github.com/root-project/root/blob/master/README/README.CXXMODULES.md

CMSSW and other experiment migrate their dictionaries to use the provided by
ROOT C++ modules support: cms-sw/cmssw#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.

Conflicts:
	Matrix/src/DiagMatrix.cc
	Matrix/src/GenMatrix.cc
	Matrix/src/Matrix.cc
	Matrix/src/SymMatrix.cc
	Matrix/src/Vector.cc
  • Loading branch information
vgvassilev authored and lgarren committed Nov 9, 2020
1 parent 0700273 commit caa0aa3
Show file tree
Hide file tree
Showing 126 changed files with 443 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Exceptions/Exceptions/ZMexHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class ZMexHandler : public ZMhandleTo< ZMexHandlerBehavior > {
ZMhandleTo<ZMexHandlerBehavior>( behaviorWanted )
{ }

virtual ~ZMexHandler() { }
virtual ~ZMexHandler();

std::string name() const {
return rep_->name();
Expand Down
1 change: 1 addition & 0 deletions Exceptions/src/ZMerrno.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "CLHEP/Exceptions/ZMexception.h"

#include <string>

namespace zmex {

Expand Down
3 changes: 3 additions & 0 deletions Exceptions/src/ZMexClassInfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

#include "CLHEP/Exceptions/ZMexClassInfo.h"

#include "CLHEP/Exceptions/ZMexSeverity.h"

#include <string>

namespace zmex {

Expand Down
6 changes: 6 additions & 0 deletions Exceptions/src/ZMexHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@

#include "CLHEP/Exceptions/ZMexHandler.h"

#include "CLHEP/Exceptions/ZMexAction.h"
#include "CLHEP/Exceptions/ZMexception.h"
#include "CLHEP/Exceptions/ZMexLogResult.h"
#include "CLHEP/Exceptions/ZMexSeverity.h"

#include <string>


namespace zmex {

ZMexHandler::~ZMexHandler() { }

//******************************************
//
Expand Down
3 changes: 3 additions & 0 deletions Exceptions/src/ZMexLogger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@

#include "CLHEP/Exceptions/ZMexLogger.h"
#include "CLHEP/Exceptions/ZMexception.h"
#include "CLHEP/RefCount/ZMhandleTo.h"

#include <iostream>
#include <string>

// ----------------------------------------------------------------------

Expand Down
4 changes: 4 additions & 0 deletions Exceptions/src/ZMexSeverity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

#include "CLHEP/Exceptions/ZMexSeverity.h"

#include "CLHEP/Exceptions/ZMerrno.h"

#include <string>


namespace zmex {

Expand Down
2 changes: 2 additions & 0 deletions Exceptions/src/ZMexception.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@
#include "CLHEP/Exceptions/defs.h"
#include "CLHEP/Exceptions/ZMexception.h"
#include "CLHEP/Exceptions/ZMexAction.h"
#include "CLHEP/Exceptions/ZMexClassInfo.h"
#include "CLHEP/Exceptions/ZMexHandler.h"
#include "CLHEP/Exceptions/ZMexLogger.h"
#include "CLHEP/Exceptions/ZMexLogResult.h"
#include "CLHEP/Exceptions/ZMexSeverity.h"

#include <sstream>
#include <ctime>
Expand Down
6 changes: 4 additions & 2 deletions Exceptions/src/ZMthrow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@


#include "CLHEP/Exceptions/ZMthrow.h"
#include "CLHEP/Exceptions/ZMexSeverity.h"
#include "CLHEP/Exceptions/ZMexception.h"
#include "CLHEP/Exceptions/ZMerrno.h"
#include "CLHEP/Exceptions/ZMexAction.h"
#include "CLHEP/Exceptions/ZMexception.h"
#include "CLHEP/Exceptions/ZMexSeverity.h"

#include <string>

namespace zmex {

Expand Down
3 changes: 3 additions & 0 deletions Exceptions/test/exctest1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ using std::endl;


#include "CLHEP/Exceptions/ZMexception.h"
#include "CLHEP/Exceptions/ZMexAction.h"
#include "CLHEP/Exceptions/ZMexClassInfo.h"
#include "CLHEP/Exceptions/ZMexSeverity.h"
#include "CLHEP/Exceptions/ZMthrow.h"
using namespace zmex;

Expand Down
3 changes: 3 additions & 0 deletions Exceptions/test/exctest4.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ using std::endl;


#include "CLHEP/Exceptions/ZMexception.h"
#include "CLHEP/Exceptions/ZMexAction.h"
#include "CLHEP/Exceptions/ZMexClassInfo.h"
#include "CLHEP/Exceptions/ZMexSeverity.h"
#include "CLHEP/Exceptions/ZMthrow.h"
using namespace zmex;

Expand Down
6 changes: 6 additions & 0 deletions Exceptions/test/exctestNothrow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@

#include "CLHEP/Exceptions/ZMthrow.h"
#include "CLHEP/Exceptions/ZMexception.h"
#include "CLHEP/Exceptions/ZMexAction.h"
#include "CLHEP/Exceptions/ZMexClassInfo.h"
#include "CLHEP/Exceptions/ZMexSeverity.h"
#include "CLHEP/Exceptions/ZMerrno.h"

using namespace zmex;

#include <iostream>
#include <fstream>

using namespace std;


Expand Down
7 changes: 6 additions & 1 deletion Exceptions/test/testExceptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@
#include "CLHEP/Exceptions/defs.h"
#include "CLHEP/Cast/itos.h"
#include "CLHEP/Exceptions/ZMthrow.h"
#include "CLHEP/Exceptions/ZMexception.h"
#include "CLHEP/Exceptions/ZMexAction.h"
#include "CLHEP/Exceptions/ZMexClassInfo.h"
#include "CLHEP/Exceptions/ZMexSeverity.h"
#include "CLHEP/Exceptions/ZMerrno.h"
#include "CLHEP/Exceptions/ZMexception.h"

#include <iostream>


using namespace zmex;
Expand Down
4 changes: 4 additions & 0 deletions Exceptions/test/testThrowFrom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

#include "CLHEP/Exceptions/ZMthrow.h"
#include "CLHEP/Exceptions/ZMexception.h"
#include "CLHEP/Exceptions/ZMexAction.h"
#include "CLHEP/Exceptions/ZMexClassInfo.h"
#include "CLHEP/Exceptions/ZMexSeverity.h"

#include <iostream>
using namespace zmex;

ZMexStandardDefinition( ZMexception, ZMxTest );
Expand Down
3 changes: 3 additions & 0 deletions Exceptions/test/testzmex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

#include "CLHEP/Exceptions/ZMthrow.h"
#include "CLHEP/Exceptions/ZMexception.h"
#include "CLHEP/Exceptions/ZMexAction.h"
#include "CLHEP/Exceptions/ZMexClassInfo.h"
#include "CLHEP/Exceptions/ZMexSeverity.h"
#include "CLHEP/Exceptions/ZMerrno.h"


Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/GenericFunctions/ButcherTableau.icc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <ostream> // for std::endl
namespace Genfun {
ButcherTableau::ButcherTableau(const std::string &xname, unsigned int xorder):_name(xname),_order(xorder){
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <ostream> // for std::endl
namespace Genfun {
ExtendedButcherTableau::ExtendedButcherTableau(const std::string &mname,
unsigned int xorder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "CLHEP/GenericFunctions/AbsFunction.hh"

namespace Genfun {
class Argument;

/**
* @author
Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/src/ASin.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// -*- C++ -*-
// $Id: ASin.cc,v 1.4 2003/10/10 17:40:39 garren Exp $
#include "CLHEP/GenericFunctions/AbsFunction.hh"
#include "CLHEP/GenericFunctions/ASin.hh"
#include "CLHEP/GenericFunctions/Sqrt.hh"
#include "CLHEP/GenericFunctions/Square.hh"
Expand Down
3 changes: 3 additions & 0 deletions GenericFunctions/src/AdaptiveRKStepper.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include "CLHEP/GenericFunctions/AdaptiveRKStepper.hh"
#include "CLHEP/GenericFunctions/EmbeddedRKStepper.hh"

#include <cmath>
#include <stdexcept>
#include <vector>

namespace Genfun {

AdaptiveRKStepper::AdaptiveRKStepper(const EEStepper *stepper):
Expand Down
3 changes: 3 additions & 0 deletions GenericFunctions/src/AnalyticConvolution.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
// -*- C++ -*-
// $Id: AnalyticConvolution.cc,v 1.8 2010/07/22 21:55:10 garren Exp $
#include "CLHEP/GenericFunctions/AbsFunction.hh"
#include "CLHEP/GenericFunctions/AnalyticConvolution.hh"
#include "CLHEP/GenericFunctions/Gaussian.hh"
#include "CLHEP/GenericFunctions/Exponential.hh"
#include <cmath> // for isfinite
#if (defined _WIN32)
#include <float.h> // Visual C++ _finite
#endif
#include <iostream>

namespace Genfun {
FUNCTION_OBJECT_IMP(AnalyticConvolution)

Expand Down
3 changes: 3 additions & 0 deletions GenericFunctions/src/ArrayFunction.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// -*- C++ -*-
// $Id:
#include "CLHEP/GenericFunctions/AbsFunction.hh"
#include "CLHEP/GenericFunctions/ArrayFunction.hh"

#include <vector>

namespace Genfun {

FUNCTION_OBJECT_IMP(ArrayFunction)
Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/src/BetaDistribution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "CLHEP/GenericFunctions/BetaDistribution.hh"
#include <assert.h>
#include <cmath>
#include <iostream>
using namespace std;

namespace Genfun {
Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/src/BivariateGaussian.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "CLHEP/GenericFunctions/BivariateGaussian.hh"
#include <assert.h>
#include <cmath> // for exp()
#include <iostream>

#if (defined __STRICT_ANSI__) || (defined _WIN32)
#ifndef M_PI
Expand Down
7 changes: 4 additions & 3 deletions GenericFunctions/src/DefiniteIntegral.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// -*- C++ -*-
// $Id: DefiniteIntegral.cc,v 1.6 2010/06/16 18:22:01 garren Exp $

#include "CLHEP/GenericFunctions/AbsFunction.hh"
#include "CLHEP/GenericFunctions/DefiniteIntegral.hh"

#include <cmath>
#include <iostream>
#include <vector>
#include <stdexcept>
#include "CLHEP/GenericFunctions/DefiniteIntegral.hh"
#include "CLHEP/GenericFunctions/AbsFunction.hh"


namespace Genfun {

Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/src/EfficiencyFunctional.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "CLHEP/GenericFunctions/AbsFunction.hh"
#include <iostream>
#include <cmath> // for log()
#include <vector>

namespace Genfun {
EfficiencyFunctional::EfficiencyFunctional(const ArgumentList & aList):
Expand Down
2 changes: 2 additions & 0 deletions GenericFunctions/src/EmbeddedRKStepper.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "CLHEP/GenericFunctions/EmbeddedRKStepper.hh"
#include "CLHEP/GenericFunctions/ExtendedButcherTableau.hh"
#include <stdexcept>
#include <vector>

namespace Genfun {


Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/src/Exponential.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "CLHEP/GenericFunctions/Exponential.hh"
#include <assert.h>
#include <cmath> // for exp()
#include <iostream>

namespace Genfun {
FUNCTION_OBJECT_IMP(Exponential)
Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/src/FunctionComposition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// $Id: FunctionComposition.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
#include "CLHEP/GenericFunctions/FunctionComposition.hh"
#include <assert.h>
#include <iostream>

namespace Genfun {
FUNCTION_OBJECT_IMP(FunctionComposition)
Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/src/FunctionConvolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// $Id: FunctionConvolution.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
#include "CLHEP/GenericFunctions/FunctionConvolution.hh"
#include <assert.h>
#include <iostream>

namespace Genfun {
FUNCTION_OBJECT_IMP(FunctionConvolution)
Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/src/FunctionDifference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// $Id: FunctionDifference.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
#include "CLHEP/GenericFunctions/FunctionDifference.hh"
#include <assert.h>
#include <iostream>

namespace Genfun {
FUNCTION_OBJECT_IMP(FunctionDifference)
Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/src/FunctionDirectProduct.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// $Id: FunctionDirectProduct.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
#include "CLHEP/GenericFunctions/FunctionDirectProduct.hh"
#include <assert.h>
#include <iostream>

namespace Genfun {
FUNCTION_OBJECT_IMP(FunctionDirectProduct)
Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/src/FunctionProduct.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// $Id: FunctionProduct.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
#include "CLHEP/GenericFunctions/FunctionProduct.hh"
#include <assert.h>
#include <iostream>

namespace Genfun {
FUNCTION_OBJECT_IMP(FunctionProduct)
Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/src/FunctionQuotient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// $Id: FunctionQuotient.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
#include "CLHEP/GenericFunctions/FunctionQuotient.hh"
#include <assert.h>
#include <iostream>

namespace Genfun {
FUNCTION_OBJECT_IMP(FunctionQuotient)
Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/src/FunctionSum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// $Id: FunctionSum.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
#include "CLHEP/GenericFunctions/FunctionSum.hh"
#include <assert.h>
#include <iostream>

namespace Genfun {
FUNCTION_OBJECT_IMP(FunctionSum)
Expand Down
2 changes: 2 additions & 0 deletions GenericFunctions/src/GammaDistribution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "CLHEP/GenericFunctions/GammaDistribution.hh"
#include <assert.h>
#include <cmath>
#include <iostream>

using namespace std;

namespace Genfun {
Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/src/Gaussian.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "CLHEP/GenericFunctions/Variable.hh"
#include <assert.h>
#include <cmath> // for exp()
#include <iostream>

#if (defined __STRICT_ANSI__) || (defined _WIN32)
#ifndef M_PI
Expand Down
2 changes: 2 additions & 0 deletions GenericFunctions/src/IncompleteGamma.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "CLHEP/GenericFunctions/IncompleteGamma.hh"
#include <assert.h>
#include <cmath>
#include <iostream>

using namespace std;

namespace Genfun {
Expand Down
3 changes: 3 additions & 0 deletions GenericFunctions/src/InterpolatingPolynomial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include <cassert>
#include <cmath>
#include <cfloat>
#include <iostream>
#include <vector>

namespace Genfun {
FUNCTION_OBJECT_IMP(InterpolatingPolynomial)

Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/src/Landau.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "CLHEP/GenericFunctions/Variable.hh"
#include <cmath>
#include <assert.h>
#include <iostream>

using namespace std;

Expand Down
1 change: 1 addition & 0 deletions GenericFunctions/src/LikelihoodFunctional.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <sstream>
#include <stdexcept>
#include <cmath> // for log()
#include <vector>

namespace Genfun {
LikelihoodFunctional::LikelihoodFunctional(const ArgumentList & aList):
Expand Down
Loading

0 comments on commit caa0aa3

Please sign in to comment.