GENIE-MC / Generator

The popular GENIE Generator product is used by nearly all accelerator neutrino experiments and it plays a key role in the exploitation of neutrino data. The Generator implements a modern software framework and it includes state-of-the-art physics modules. It captures the latest results of the GENIE global analysis of neutrino scattering data and includes several tunes that were produced using the proprietary Comparisons and Tuning products. The GENIE physics model is universal and comprehensive: It handles all neutrinos and targets, and all processes relevant from MeV to PeV energy scales. The Generator includes several tools (flux drivers, detector geometry navigators, specialized event generation apps, event reweighting engines) to simulate complex experimental setups in full detail and to support generator-related analysis tasks.
http://www.genie-mc.org
48 stars 93 forks source link

C++17 support #364

Closed ghkareem closed 1 year ago

ghkareem commented 1 year ago

Please can you provide support for C++17? Thanks!

mroda88 commented 1 year ago

Hi Kareem. What do you need exactly?

It is true that we state that we support C++14, which means we require a compiler that is at least able to compile C++14. Yet, C++17 is backward compatible so your C++17 compiler (or even C++20) should be able to compile GENIE without issues. Furthermore, I'm pretty sure that most developers compile the code using C++17 because we use the compiler configurations that comes with the ROOT version distributed by fermilab via cvmfs.

Having said that, I might be missing something due to the short request. If you can elaborate a little more, maybe we can see what we can do.

Cheers, Marco

ghkareem commented 1 year ago

Hi Marco! Thanks for your fast reply! So I am trying to compile with GCC13.2.0 using C++17 with ROOT 6.28/07. and whenever compiling GENIE, it is picking up some errors such as warning: #warning before C++23 is a GCC extension 30 | # warning "The C++ standard in this build does not match ROOT configuration (201703L); this might cause unexpected issues"

RConfigure.h:30:4: warning: #warning "The C++ standard in this build does not match ROOT configuration (201703L); this might cause unexpected issues" [-Wcpp]

RConfig.hxx:48:4: error: #error "ROOT requires support for C++14 or higher." 48 | # error "ROOT requires support for C++14 or higher."

RConfig.hxx:50:5: error: #error "Pass-std=c++14as compiler argument." 50 | # error "Pass-std=c++14as compiler argument."

Somehow as a consequence, it is picking up some older C++14 functions from the standard library that are yielding further errors such as

error: 'result_of_t' in namespace 'std' does not name a template type; did you mean 'result_of'? 201 | using InvokeResult_t = std::result_of_t<F(Args...)>;

somehow it is picking up an older C++14 version on my system, and if I parse the -std=c++17 or -std=gnu++17 flag, it is yielding the same errors (even if I make clean beforehand).

help is greatly appreciated! Thanks Marco!

karuboniru commented 1 year ago

I am working on GENIE with C++ 17 but not facing any issue compiling GENIE. Maybe something is adding some unintended compiling flag on your environment.

I think following information would be useful to address the cause:

And during compiling, there should be a lot of outputs that look like:

g++ -c  -W -Wall -fPIC -Wshadow -pthread -std=c++17 -m64 -march=native -I/var/home/yan/code/root-6.28.06/install/include -g -O2  -Wno-strict-aliasing  -I/usr/include/libxml2 -I/usr/include -I/var/home/yan/code/root-6.28.06/install/include -I/usr/include  -I/usr/include -I/var/home/yan/code/Generator.3.04.00/src/ TransverseEnhancementFFModel.cxx

Could you randomly pick one and paste it here?

ghkareem commented 1 year ago

Sure!

git describe = R-3_04_00

Here is the Content of src/make/Make.config:

GENIE_INSTALLATION_PATH=/proj/soft/GENIE/Install_gcc13.2.0
GOPT_ENABLE_PYTHIA8=YES
GOPT_ENABLE_INCL=NO
GOPT_ENABLE_GEANT4_INTERFACE=YES
GOPT_ENABLE_LHAPDF5=NO
GOPT_ENABLE_LHAPDF6=YES
GOPT_ENABLE_APFEL=NO
GOPT_ENABLE_FLUX_DRIVERS=YES
GOPT_ENABLE_GEOM_DRIVERS=YES
GOPT_ENABLE_T2K=YES
GOPT_ENABLE_FNAL=YES
GOPT_ENABLE_ATMO=YES
GOPT_ENABLE_NUCLEON_DECAY=YES
GOPT_ENABLE_NNBAR_OSCILLATION=NO
GOPT_ENABLE_BOOSTED_DARK_MATTER=NO
GOPT_ENABLE_HEAVY_NEUTRAL_LEPTON=NO
GOPT_ENABLE_HNL_VALIDATION=NO
GOPT_ENABLE_DARK_NEUTRINO=NO
GOPT_ENABLE_EVTLIB=NO
GOPT_ENABLE_INCL=NO
GOPT_ENABLE_GEANT4_INTERFACE=YES
GOPT_ENABLE_MASTERCLASS=NO
GOPT_ENABLE_TEST=YES
GOPT_ENABLE_DYLIBVERSION=YES
GOPT_ENABLE_LOW_LEVEL_MESG=NO
GOPT_ENABLE_PROFILER=NO
GOPT_ENABLE_DOXYGEN_DOC=NO
GOPT_ENABLE_GFORTRAN=NO
GOPT_ENABLE_G2C=NO
GOPT_WITH_COMPILER=gcc
GOPT_WITH_CXX_DEBUG_FLAG=-g
GOPT_WITH_CXX_OPTIMIZ_FLAG=-O2
GOPT_WITH_PROFILER_LIB=
GOPT_WITH_DOXYGEN_PATH=
GOPT_WITH_PYTHIA6_LIB=/proj/soft/PYTHIA6/Install_gcc13.2.0/lib
GOPT_WITH_PYTHIA8_LIB=/proj/soft/PYTHIA8/Pythia8.3.10_Install_gcc13.2.0/lib
GOPT_WITH_PYTHIA8_INC=/proj/soft/PYTHIA8/Pythia8.3.10_Install_gcc13.2.0/include
GOPT_WITH_LHAPDF5_LIB=
GOPT_WITH_LHAPDF5_INC=
GOPT_WITH_LHAPDF6_LIB=/proj/soft/LHAPDF/Install_v6.5.4_gcc13/lib
GOPT_WITH_LHAPDF6_INC=/proj/soft/LHAPDF/Install_v6.5.4_gcc13/include
GOPT_WITH_APFEL_LIB=
GOPT_WITH_APFEL_INC=
GOPT_WITH_LIBXML2_INC=/proj/soft/LIBXML2/Install_gcc13.2.0/include/libxml2
GOPT_WITH_LIBXML2_LIB=/proj/soft/LIBXML2/Install_gcc13.2.0/lib
GOPT_WITH_LOG4CPP_INC=/proj/soft/LOG4CPP/Install_gcc13.2.0_cmake3.27.4/include
GOPT_WITH_LOG4CPP_LIB=/proj/soft/LOG4CPP/Install_gcc13.2.0_cmake3.27.4/lib
GOPT_WITH_INCL_INC=
GOPT_WITH_INCL_LIB=
GOPT_WITH_BOOST_INC=
GOPT_WITH_BOOST_LIB=
GOPT_WITH_GEANT4_INC=/proj/soft/GEANT4/install_gcc13.2.0/include
GOPT_WITH_GEANT4_LIB=/proj/soft/GEANT4/install_gcc13.2.0/lib64
GOPT_WITH_GFORTRAN_LIB=
GOPT_WITH_G2C_LIB=

From root-config --cflags: -pthread -std=c++17 -m64 -I/proj/soft/ROOT6/install_V6-28-00_gcc13.2.0/include

and from compiling

g++ -c -W -Wall -fPIC -Wshadow -pthread -std=c++17 -m64 -I/proj/soft/ROOT6/install_V6-28-00_gcc13.2.0/include -g -O2 -Wno-strict-aliasing -I/proj/soft/LIBXML2/Install_gcc13.2.0/include/libxml2 -I/proj/soft/LOG4CPP/Install_gcc13.2.0_cmake3.27.4/include -I/proj/soft/ROOT6/install_V6-28-00_gcc13.2.0/include -I/proj/soft/LHAPDF/Install_v6.5.4_gcc13/include -I/proj/soft/GSL/Install_gcc13.2.0/include -I/proj/soft/GENIE/Generator/src/ XSecAlgorithmI.cxx

karuboniru commented 1 year ago

I see, how about the output of geant4-config --cflags ?

ghkareem commented 1 year ago

geant4-config --cflags yields

-DG4INTY_USE_XT -DG4VIS_USE_OPENGL -DG4UI_USE_TCSH -DG4INTY_USE_QT -DG4UI_USE_QT -DG4VIS_USE_OPENGLQT -I/proj/soft/Qt/install_qt-everywhere-5.12.6_gcc13.2.0/include/ -I/proj/soft/Qt/install_qt-everywhere-5.12.6_gcc13.2.0/include/QtCore -I/proj/soft/Qt/install_qt-everywhere-5.12.6_gcc13.2.0/.//mkspecs/linux-g++ -I/proj/soft/Qt/install_qt-everywhere-5.12.6_gcc13.2.0/include/QtGui -I/proj/soft/Qt/install_qt-everywhere-5.12.6_gcc13.2.0/include/QtWidgets -I/proj/soft/Qt/install_qt-everywhere-5.12.6_gcc13.2.0/include/QtOpenGL -I/proj/soft/Qt/install_qt-everywhere-5.12.6_gcc13.2.0/include/QtPrintSupport -DG4VIS_USE_OPENGLX -W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow -pipe -std=c++11 -I/proj/soft/GEANT4/install_gcc13.2.0/bin/../include/Geant4
ghkareem commented 1 year ago

ahh, I see, maybe there is conflict in the c++ from geant4?

ghkareem commented 1 year ago

That did the trick, thanks for the help!