ShipSoft / shipdist

Recipes to build SHiP software and its dependencies
2 stars 10 forks source link

std=c++17 #50

Open ThomasRuf opened 4 years ago

ThomasRuf commented 4 years ago

protobuf does not build with c++17 option. Works with c++11. Is it possible to have protobuf compiled with c++11 and the rest with c++17?

/usr/include/c++/9/bits/stl_tree.h:780:8: error: static assertion failed: comparison object must be invocable as const 780 | is_invocable_v<const _Compare&, const _Key&, const _Key&>, | ^~~~~~~~~~~~~ google/protobuf/compiler/java/java_file.cc:159:6: warning: 'bool google::protobuf::compiler::java::{anonymous}::CompareFieldsByName(const google::protobuf::FieldDescriptor, const google::protobuf::FieldDescriptor)' defined but not used [-Wunused-function] 159 | bool CompareFieldsByName(const FieldDescriptor a, const FieldDescriptor b) { | ^~~~~~~

ThomasRuf commented 4 years ago

bypassed this for the moment by installing protobuf-compiler and using --always-prefer-system

olantwin commented 4 years ago

I think we should be able to override the standard per recipe, so in this case in protobuf.sh. The ABI should be compatible, if I am not mistaken.

Maybe we should check whether we can upgrade to a newer protobuf version, as I'd be surprised if they didn't support c++17 generally.

ThomasRuf commented 4 years ago

switching to the version used by alice didn't helped, v3.11.4.

version v3.12.3 works. Needs modification in default-fairship.sh, not in protobuf.sh

olantwin commented 4 years ago

Same error?

I think protobuf should build with C++17, at least most issues referencing it I can find in their repository seem fixed in v3.11.x...

ThomasRuf commented 4 years ago

FairRoot does not know about c++17. CMakeLists.txt needs to be modified:

If(${POS_C++11} EQUAL -1) String(FIND ${CMAKE_CXX_FLAGS} "-std=c++14" POS_C++11) If(${POS_C++11} EQUAL -1) String(FIND ${CMAKE_CXX_FLAGS} "-std=c++17" POS_C++11) If(${POS_C++11} EQUAL -1) Message(FATAL_ERROR "FairSoft wasn't compiled with c++11 or c++14 or c++17 support. Please recompile FairSoft with a compiler which supports at least c++11.") EndIf() EndIf() EndIf()

olantwin commented 4 years ago

To be fair, it could be that C++17 is newer than our FairRoot version.

ThomasRuf commented 4 years ago

next issue with GEANT4_VMC:

SHiPBuild/sw/ubuntu2004_x86-64/ROOT/9680bccb30_FAIRSHIP-1/include/TString.h:275:27: note: 'std::string_view' is only available from C++17 onwards 275 | explicit TString(const std::string_view &sub);

it seems that the GEANT4_VMC build ignores the c++17 option.

the logic in macro geant4_vmc/cmake/FindROOT.cmake is probably buggy, and sets set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

ThomasRuf commented 4 years ago

removed whole logic. Still find strange cxxflags in the make files: /usr/bin/c++ -fPIC -fPIC -DG4USE_STD11 -std=c++11 -fPIC -g -O2 -std=c++17 -O3 -DNDEBUG -fno-

ThomasRuf commented 4 years ago

has another weird logic:

Extract C++ standard

string(FIND ${ROOT_CFLAGS} "-std=" POSITION)
if (${POSITION} GREATER -1)
  string(SUBSTRING ${ROOT_CFLAGS} ${POSITION} 11 ROOT_CXX_STD)
  #message(STATUS "ROOT_CXX_STD: " ${ROOT_CXX_STD})
ThomasRuf commented 4 years ago

at least the message looks ok: -- ROOT_CXX_STD: -std=c++17
no idea where the c++11 has its origin.

ThomasRuf commented 4 years ago

Found it, they come from Geant4, geant4_vmc/cmake/UseGeant4.cmake set(CMAKE_CXX_FLAGS "${Geant4_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")

-- Geant4_CXX_FLAGS: -fPIC -DG4USE_STD11 -std=c++11

it seems, geant4 ignored the global c++17. Which then causes confusion in geant4_vmc.

ThomasRuf commented 4 years ago

need to move to Geant4 10.6. Updated Intel settings to support use of C++17 with Intel 19 when using CMake-3.8-3.10. Versions from 3.11 fully support Intel 19/C++17.

ThomasRuf commented 4 years ago

error above disappeared now. But new one appeared:

[ 10%] Building CXX object source/CMakeFiles/geant4vmc.dir/digits+hits/src/TG4SDConstruction.cxx.o In file included from /media/disk0/SHiPBuild/sw/SOURCES/GEANT4_VMC/v3-6-ship/0/source/global/include/TG4Globals.h:18, from /media/disk0/SHiPBuild/sw/SOURCES/GEANT4_VMC/v3-6-ship/0/source/geometry/include/TG4GeometryServices.h:19, from /media/disk0/SHiPBuild/sw/SOURCES/GEANT4_VMC/v3-6-ship/0/source/digits+hits/src/TG4SDConstruction.cxx:19: /media/disk0/SHiPBuild/sw/SOURCES/GEANT4_VMC/v3-6-ship/0/source/global/include/TG4G3Control.h:118:3: error: 'kLOSS' conflicts with a previous declaration 118 | kLOSS, | ^~~~~ In file included from /media/disk0/SHiPBuild/sw/ubuntu2004_x86-64/GEANT4/geant4-10.6-release-1/include/Geant4/G4MaterialPropertiesTable.hh:63, from /media/disk0/SHiPBuild/sw/ubuntu2004_x86-64/GEANT4/geant4-10.6-release-1/include/Geant4/G4Material.hh:104, from /media/disk0/SHiPBuild/sw/ubuntu2004_x86-64/GEANT4/geant4-10.6-release-1/include/Geant4/G4StepPoint.hh:61, from /media/disk0/SHiPBuild/sw/ubuntu2004_x86-64/GEANT4/geant4-10.6-release-1/include/Geant4/G4Step.hh:61, from /media/disk0/SHiPBuild/sw/ubuntu2004_x86-64/GEANT4/geant4-10.6-release-1/include/Geant4/G4VSensitiveDetector.hh:33, from /media/disk0/SHiPBuild/sw/SOURCES/GEANT4_VMC/v3-6-ship/0/source/digits+hits/include/TG4SensitiveDetector.h:18, from /media/disk0/SHiPBuild/sw/SOURCES/GEANT4_VMC/v3-6-ship/0/source/digits+hits/src/TG4SDConstruction.cxx:17: /media/disk0/SHiPBuild/sw/ubuntu2004_x86-64/GEANT4/geant4-10.6-release-1/include/Geant4/G4MaterialPropertiesIndex.hh:88:3: note: previous declaration 'G4MaterialConstPropertyIndex kLOSS' 88 | kLOSS, // loss | ^~~~~ make[2]: [source/CMakeFiles/geant4vmc.dir/build.make:88: source/CMakeFiles/geant4vmc.dir/digits+hits/src/TG4SDConstruction.cxx.o] Error 1 make[1]: [CMakeFiles/Makefile2:497: source/CMakeFiles/geant4vmc.dir/all] Error 2

ThomasRuf commented 4 years ago

Move to https://github.com/vmc-project/geant4_vmc . This one builds. immediately next problem: fairroot

-- Looking for nanomsg... - found /usr/lib/x86_64-linux-gnu/libnanomsg.so CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:469 (file): file STRINGS file "/include/google/protobuf/stubs/common.h" cannot be read. Call Stack (most recent call first): CMakeLists.txt:246 (find_package)

CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:475 (math): math cannot parse the expression: " / 1000000": syntax error, unexpected exp_DIVIDE (2). Call Stack (most recent call first): CMakeLists.txt:246 (find_package)

CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:476 (math): math cannot parse the expression: " / 1000 % 1000": syntax error, unexpected exp_DIVIDE (2). Call Stack (most recent call first): CMakeLists.txt:246 (find_package)

CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:477 (math): math cannot parse the expression: " % 1000": syntax error, unexpected exp_MOD (2). Call Stack (most recent call first): CMakeLists.txt:246 (find_package)

CMake Warning at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:499 (message): Protobuf compiler version 3.6.1 doesn't match library version ERROR.ERROR.ERROR Call Stack (most recent call first): CMakeLists.txt:246 (find_package)

-- Found Protobuf: /lib/libprotobuf.so (found version "ERROR.ERROR.ERROR") ... -- Could NOT find Boost (missing: Boost_INCLUDE_DIR thread system timer program_options random filesystem chrono exception regex serialization log log_setup atomic date_time signals) (Required is at least version "1.64") -- C++11 support found. -- Build CbmModule with Gdml support -- Looking for CLOCK_REALTIME -- Looking for CLOCK_REALTIME - found -- Building of the FairMQ library is switched off due to at least one of the following reasons : one or more C++11 feature(s), ZeroMQ or the necessary boost libraries couldn't be found on the system.

ThomasRuf commented 4 years ago

via trial and error. The problem above can be fixed with FairRoot/CMakeLists.txt: set(CMAKE_PREFIX_PATH "/usr") find_package(Protobuf NO_DEFAULT_PATH PATHS "/usr")

no idea how to do this that it also works for other systems than ubuntu.

olantwin commented 4 years ago

need to move to Geant4 10.6. Updated Intel settings to support use of C++17 with Intel 19 when using CMake-3.8-3.10. Versions from 3.11 fully support Intel 19/C++17.

AFAIK FairRoot has been fixed to support new GEANT4 very recently.

For newer FairRoot versions FairMQ and FairLogger are needed as separate package, which I'll implement over the next few days (also as part of our performance studies to use mult-threaded GEANT4.

olantwin commented 4 years ago

via trial and error. The problem above can be fixed with FairRoot/CMakeLists.txt: set(CMAKE_PREFIX_PATH "/usr") find_package(Protobuf NO_DEFAULT_PATH PATHS "/usr")

no idea how to do this that it also works for other systems than ubuntu.

Once we find a combination that works we can try to start generalising it.

olantwin commented 4 years ago

Move to https://github.com/vmc-project/geant4_vmc . This one builds. immediately next problem: fairroot

-- Looking for nanomsg... - found /usr/lib/x86_64-linux-gnu/libnanomsg.so CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:469 (file): file STRINGS file "/include/google/protobuf/stubs/common.h" cannot be read. Call Stack (most recent call first): CMakeLists.txt:246 (find_package)

CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:475 (math): math cannot parse the expression: " / 1000000": syntax error, unexpected exp_DIVIDE (2). Call Stack (most recent call first): CMakeLists.txt:246 (find_package)

CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:476 (math): math cannot parse the expression: " / 1000 % 1000": syntax error, unexpected exp_DIVIDE (2). Call Stack (most recent call first): CMakeLists.txt:246 (find_package)

CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:477 (math): math cannot parse the expression: " % 1000": syntax error, unexpected exp_MOD (2). Call Stack (most recent call first): CMakeLists.txt:246 (find_package)

CMake Warning at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:499 (message): Protobuf compiler version 3.6.1 doesn't match library version ERROR.ERROR.ERROR Call Stack (most recent call first): CMakeLists.txt:246 (find_package)

-- Found Protobuf: /lib/libprotobuf.so (found version "ERROR.ERROR.ERROR") ... -- Could NOT find Boost (missing: Boost_INCLUDE_DIR thread system timer program_options random filesystem chrono exception regex serialization log log_setup atomic date_time signals) (Required is at least version "1.64") -- C++11 support found. -- Build CbmModule with Gdml support -- Looking for CLOCK_REALTIME -- Looking for CLOCK_REALTIME - found -- Building of the FairMQ library is switched off due to at least one of the following reasons : one or more C++11 feature(s), ZeroMQ or the necessary boost libraries couldn't be found on the system.

I'll also look into using VMC standalone alongside this soon.

ThomasRuf commented 4 years ago

FairRoot almost builds, except:

CMake Error at examples/advanced/GoTutorial/cmake_install.cmake:41 (file): file INSTALL cannot find "/media/disk0/SHiPBuild/sw/SOURCES/FairRoot/May30-ship/0/examples/advanced/GoTutorial/bin/go-processor":

GoTutorial/src/ directory exists. -- Looking for Go... found Go 1.13.8

only suspicous lines in the log file: ./../../../../../sw/SOURCES/FairRoot/May30-ship/0/examples/advanced/GoTutorial/src/go-processor/main.go:10:2: code in directory /media/disk0/SHiPBuild/sw/SOURCES/FairRoot/May30-ship/0/examples/advanced/GoTutorial/src/github.com/sbinet-alice/fer expects import "github.com/alice-go/fer" ../../../../../../sw/SOURCES/FairRoot/May30-ship/0/examples/advanced/GoTutorial/src/go-processor/main.go:11:2: code in directory /media/disk0/SHiPBuild/sw/SOURCES/FairRoot/May30-ship/0/examples/advanced/GoTutorial/src/github.com/sbinet-alice/fer/config expects import "github.com/alice-go/fer/config" ../../../../../../sw/SOURCES/FairRoot/May30-ship/0/examples/advanced/GoTutorial/src/go-sink/main.go:10:2: code in directory /media/disk0/SHiPBuild/sw/SOURCES/FairRoot/May30-ship/0/examples/advanced/GoTutorial/src/github.com/sbinet-alice/fer expects import "github.com/alice-go/fer" ../../../../../../sw/SOURCES/FairRoot/May30-ship/0/examples/advanced/GoTutorial/src/go-sink/main.go:11:2: code in directory /media/disk0/SHiPBuild/sw/SOURCES/FairRoot/May30-ship/0/examples/advanced/GoTutorial/src/github.com/sbinet-alice/fer/config expects import "github.com/alice-go/fer/config"

olantwin commented 4 years ago

We can probably skip building that tutorial: We don't use go and FairRoot is even removing it in more recent versions.

One less dependency to worry about :)

Edit: so remove the GoTutorial from the CMakeLists.txt of examples/advanced

ThomasRuf commented 4 years ago

would you immediately know how to remove this tutorial? Otherwise, I will look around.

ThomasRuf commented 4 years ago

found it!

ThomasRuf commented 4 years ago

all build. Running run_simScript.py:

*** G4Exception : had013 issued by : G4NeutronElasticXS::Initialise(..) Environment variable G4PARTICLEXSDATA is not defined

ThomasRuf commented 4 years ago

If I have geant4 development package, from where does alibuild take the version number for the environment variables, for example G4NEUTRONHPDATA: "$GEANT4_ROOT/share/$G4VERSION/data/G4NDL4.5" defined in many places, defaults-fairship.sh, geant4.sh.

for the moment, set by hand: setenv G4PARTICLEXSDATA /media/disk0/SHiPBuild/sw/ubuntu2004_x86-64/GEANT4/geant4-10.6-release-1/share/Geant4-10.6.1/data/G4PARTICLEXS2.1

ThomasRuf commented 4 years ago

python $FAIRSHIP/macro/run_simScript.py: ... Macro finished succesfully. number of retries, events without HNL 783 Output file is ./ship.conical.Pythia8-TGeant4.root Parameter file is ./ship.params.conical.Pythia8-TGeant4.root Real time 162.43102979660034 s, CPU time 143.44 s

python $FAIRSHIP/macro/ShipReco.py -f ship.conical.Pythia8-TGeant4.root -g geofile_full.conical.Pythia8-TGeant4.root

event 0 Error in : UpstreamTaggerHit, discarding: const double* mom, no [dimension] finished writing tree

python $FAIRSHIP/macro/ShipAna.py -f ship.conical.Pythia8-TGeant4_rec.root -g geofile_full.conical.Pythia8-TGeant4.root -- histograms are filled and displayed OK

eventdisplay: ModuleNotFoundError: No module named 'tkinter'

missing: sudo apt-get install python3-tk

grafik

olantwin commented 4 years ago

If I have geant4 development package, from where does alibuild take the version number for the environment variables, for example G4NEUTRONHPDATA: "$GEANT4_ROOT/share/$G4VERSION/data/G4NDL4.5" defined in many places, defaults-fairship.sh, geant4.sh.

for the moment, set by hand: setenv G4PARTICLEXSDATA /media/disk0/SHiPBuild/sw/ubuntu2004_x86-64/GEANT4/geant4-10.6-release-1/share/Geant4-10.6.1/data/G4PARTICLEXS2.1

Probably from git describe, but I'm not entirely sure. So from the most recent git tag effectively.