Skip to content

Fix errrors reported by GCC 11.2.1#366

Merged
plexoos merged 9 commits intostar-bnl:mainfrom
plexoos:pr/gcc11_fixes
Jul 8, 2022
Merged

Fix errrors reported by GCC 11.2.1#366
plexoos merged 9 commits intostar-bnl:mainfrom
plexoos:pr/gcc11_fixes

Conversation

@plexoos
Copy link
Copy Markdown
Member

@plexoos plexoos commented Jun 11, 2022

No description provided.

@plexoos plexoos force-pushed the pr/gcc11_fixes branch 4 times, most recently from f6f9e98 to a8d8044 Compare June 12, 2022 17:07
Copy link
Copy Markdown
Contributor

@genevb genevb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand memcpy to have no defined error return values, just returning the destination pointer argument that is passed to it. So it doesn't sound consequential to me whether the return value is tested to be negative vs. NULL, and whatever satisfies the computer is fine.

@plexoos plexoos marked this pull request as draft June 12, 2022 18:29
@plexoos
Copy link
Copy Markdown
Member Author

plexoos commented Jun 12, 2022

Sorry, I should have marked this PR as draft, of course, to avoid noisy notifications before proposing any final changes... I am just trying to see if the newer compiler can be satisfied with quick fixes.

Copy link
Copy Markdown
Contributor

@klendathu2k klendathu2k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally everything looks good. With the FGT code, I think the logic is inverted in a couple of places.

I would like to ask for some additional information on why the libquadmath library needs ti be linked on the FORtran side. I'm nervous with any compiler option that could change the floating point precision (for better or worse)... we stumbled upon a 30+ year old GEANT bug that took months to track down over such a change.

Comment thread StRoot/StFgtPool/StFgtClusterTools/StFgtGeneralBase.cxx Outdated
Comment thread StRoot/StFgtPool/StFgtClusterTools/StFgtGeneralBase.cxx Outdated
Comment thread mgr/ConsDefs.pm
Comment thread StarVMC/StarAgmlLib/AgMath.h
@veprbl
Copy link
Copy Markdown
Member

veprbl commented Jun 13, 2022

Also, I think we probably will need to plug a -fcommon to the CFLAGS if there are runtime issues, as the -fno-common is the default starting gcc 10 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85678).

@plexoos plexoos added infrastructure Build environment and configuration and removed infrastructure Build environment and configuration labels Jun 13, 2022
@klendathu2k
Copy link
Copy Markdown
Contributor

I don't see why StBiTree was ever introduced. Going back to the last fix to StBiTree, there were no codes which depended on it. Going forward to SL10k, SL11a, SL12a... still no codes depended on it. So.... safe to remove.

@plexoos plexoos force-pushed the pr/gcc11_fixes branch 2 times, most recently from cea4609 to 2ea920a Compare June 23, 2022 16:02
plexoos added a commit to plexoos/star-sw that referenced this pull request Jun 23, 2022
-fno-common is the default starting gcc 10

From https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html

> The -fcommon places uninitialized global variables in a common block.
> This allows the linker to resolve all tentative definitions of the same
> variable in different compilation units to the same object, or to
> a non-tentative definition. This behavior is inconsistent with C++, and
> on many targets implies a speed and code size penalty on global variable
> references. It is mainly useful to enable legacy code to link without
> errors.

Many thanks to @veprbl for the helpful suggestion:

star-bnl#366 (comment)
plexoos added 6 commits July 8, 2022 10:01
```
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: /opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/libgfortran_nonshared.a(nonshared-trigd.o): undefined reference to symbol 'fmaq@@QUADMATH_1.0'
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: /lib64/libquadmath.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
cons: *** [.sl79_gcc11/OBJ/asps/rexe/root4star] Error 1
cons: errors constructing .sl79_gcc11/OBJ/asps/rexe/root4star
```
Flexible array members and zero size arrays are not allowed to be
members of unions according to C++. Gcc 11 reveals this problem in the
code:

```
g++ -fPIC -pipe -Wall -Woverloaded-virtual -std=c++0x -Wno-long-long -pthread -Wno-deprecated-declarations -m64 -O2 -g -falign-loops -falign-jumps -falign-functions -Dsl79_gcc11 -D__ROOT__ -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_NO_DEBUG -DNEW_DAQ_READER -I. -IOnlTools -IStRoot/RTS/src -IStRoot/RTS/include -IStRoot/RTS/trg/include -I. -IStRoot -I.sl79_gcc11/include -IOnlTools/Jevp/StJevpPlot -IOnlTools/Jevp/StJevpPresenter -IOnlTools/Jevp/StJevpServer -IOnlTools/Jevp/StJevpData -IOnlTools/Jevp/StJevpBuilders -IOnlTools/Jevp/StJevpViewer -I. -IOnlTools -IStRoot/RTS/src -IStRoot/RTS/include -IStRoot/RTS/trg/include -I. -IStRoot -I.sl79_gcc11/include -I/opt/software/linux-scientific7-x86_64/gcc-11.2.1/root-5.34.38-p7sjrh5whm6m2ao3zxkaoaqomiscvw52/include -I/opt/software/linux-scientific7-x86_64/gcc-11.2.1/root-5.34.38-p7sjrh5whm6m2ao3zxkaoaqomiscvw52/include -I/usr/include/mysql -I/opt/software/linux-scientific7-x86_64/gcc-11.2.1/libxml2-2.9.12-k3pblgujcxjatlcsu2xmhe7qcwtqpxn4/include/libxml2 -I/opt/software/linux-scientific7-x86_64/gcc-11.2.1/libiconv-1.16-ghg7qgnp355e4h2zsuua7ar3ngindtwn/include -c .sl79_gcc11/OBJ/OnlTools/Jevp/StJevpBuilders/bbcBuilder.cxx -o .sl79_gcc11/OBJ/OnlTools/Jevp/StJevpBuilders/bbcBuilder.o
In file included from .sl79_gcc11/OBJ/OnlTools/Jevp/StJevpBuilders/bbcBuilder.cxx:15:
.sl79_gcc11/OBJ/OnlTools/Jevp/StJevpBuilders/bbcBuilder.h:30:10: error: flexible array member in union
   30 |     TH1 *array[];
      |          ^~~~~
cons: *** [.sl79_gcc11/OBJ/OnlTools/Jevp/StJevpBuilders/bbcBuilder.o] Error 1
cons: errors constructing .sl79_gcc11/OBJ/OnlTools/Jevp/StJevpBuilders/bbcBuilder.o
```

Bulk replace:

sed -i 's/TH\(.*\*.*\)rray\[\];/TH\1rray\[1\];/g' OnlTools//Jevp/StJevpBuilders/*.h
Compiler errors seen in multiple files, e.g.:

```
.sl79_gcc11/OBJ/StRoot/StDaqLib/GENERIC/EventReader.cxx:452:37: error: ordered comparison of pointer with integer zero ('void*' and 'int')
  452 |     if (memcpy(&lr,DATAP,sizeof(lr))<0) {
```

```
g++ -fPIC -pipe -Wall -Woverloaded-virtual -std=c++0x -Wno-long-long -pthread -Wno-deprecated-declarations -m64 -O2 -g -falign-loops -falign-jumps -falign-functions -Dsl79_gcc11 -D__ROOT__ -DNEW_DAQ_READER -I. -IStRoot -I.sl79_gcc11/include -I/opt/software/linux-scientific7-x86_64/gcc-11.2.1/root-5.34.38-p7sjrh5whm6m2ao3zxkaoaqomiscvw52/include -c .sl79_gcc11/OBJ/StRoot/StEEmcPool/StEEmcPedFit/EEpixPed.cxx -o .sl79_gcc11/OBJ/StRoot/StEEmcPool/StEEmcPedFit/EEpixPed.o
.sl79_gcc11/OBJ/StRoot/StEEmcPool/StEEmcPedFit/EEpixPed.cxx: In member function 'void EEpixPed::findTowerHisto()':
.sl79_gcc11/OBJ/StRoot/StEEmcPool/StEEmcPedFit/EEpixPed.cxx:62:37: error: ordered comparison of pointer with integer zero ('char*' and 'int')
   62 |         bool A=strstr(tt1,"a04TB07")>0;
      |                ~~~~~~~~~~~~~~~~~~~~~^~
```
The library does not link due to multiple definitions

```
g++ -O2 -g -falign-loops -falign-jumps -falign-functions -shared -Wl,-Bdynamic -o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/StEStructPoolTSP.so .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Activate.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/AddCandidate.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/AddExtraCandidates.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/AddTourCandidates.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/AdjustCandidateSet.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/AllocateStructures.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Ascent.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Best2OptMove.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Best3OptMove.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Best4OptMove.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Best5OptMove.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/BestKOptMove.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Between.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Between_SL.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Between_SSL.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/BridgeGain.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/BuildKDTree.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/C.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/CandidateReport.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/ChooseInitialTour.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Connect.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/CreateCandidateSet.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/CreateDelaunayCandidateSet.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/CreateQuadrantCandidateSet.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Delaunay.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Distance.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Distance_SPECIAL.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/ERXT.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Excludable.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Exclude.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/FindTour.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Flip.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Flip_SL.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Flip_SSL.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Forbidden.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/FreeStructures.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Gain23.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/GenerateCandidates.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Genetic.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/GeoConversion.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/GetTime.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/GreedyTour.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Hashing.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Heap.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/IsCandidate.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/IsCommonEdge.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/KSwapKick.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKHmain.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LinKernighan.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Make2OptMove.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Make3OptMove.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Make4OptMove.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Make5OptMove.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/MakeKOptMove.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/MergeBetterTourWithBestTour.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/MergeWithTour.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Minimum1TreeCost.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/MinimumSpanningTree.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/NormalizeNodeList.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/NormalizeSegmentList.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/OrderCandidateSet.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/PatchCycles.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/PrintParameters.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Random.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/ReadCandidates.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/ReadLine.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/ReadParameters.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/ReadPenalties.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/ReadProblem.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/RecordBestTour.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/RecordBetterTour.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/RemoveFirstActive.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/ResetCandidateSet.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/RestoreTour.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/SFCTour.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/SegmentSize.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Sequence.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/SolveDelaunaySubproblems.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/SolveKMeansSubproblems.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/SolveKarpSubproblems.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/SolveRoheSubproblems.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/SolveSFCSubproblems.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/SolveSubproblem.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/SolveSubproblemBorderProblems.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/SolveTourSegmentSubproblems.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Statistics.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/StoreTour.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/SymmetrizeCandidateSet.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/TrimCandidateSet.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/WriteCandidates.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/WritePenalties.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/WriteTour.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/eprintf.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/fscanint.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/malloc.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/printff.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/qsort.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/StEStructTEventList.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/StarTSP.o .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/StEStructPoolTSP_Cint.o
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/AddCandidate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:195: multiple definition of `FirstNode'; .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Activate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:195: first defined here
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/AddCandidate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:231: multiple definition of `MergeTourFiles'; .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Activate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:231: first defined here
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/AddCandidate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:305: multiple definition of `BestSubsequentMove'; .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Activate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:305: first defined here
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/AddCandidate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:305: multiple definition of `BacktrackMove'; .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Activate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:305: first defined here
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/AddCandidate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:305: multiple definition of `BestMove'; .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Activate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:305: first defined here
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/AddCandidate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:304: multiple definition of `c'; .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Activate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:304: first defined here
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/AddCandidate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:304: multiple definition of `C'; .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Activate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:304: first defined here
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/AddCandidate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:304: multiple definition of `D'; .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Activate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:304: first defined here
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/AddCandidate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:304: multiple definition of `Distance'; .sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/Activate.o:/star-sw/.sl79_gcc11/OBJ/StRoot/StEStructPool/TSP/SRC/LKH.h:304: first defined here
```
This class (StBiTree) does not seem to be used by any code in this repository

```
g++ -fPIC -pipe -Wall -Woverloaded-virtual -std=c++0x -Wno-long-long -pthread -Wno-deprecated-declarations -m64 -O2 -g -falign-loops -falign-jumps -falign-functions -Dsl79_gcc11 -D__ROOT__ -DNEW_DAQ_READER -I. -IStRoot -I.sl79_gcc11/include -I/opt/software/linux-scientific7-x86_64/gcc-11.2.1/root-5.34.38-p7sjrh5whm6m2ao3zxkaoaqomiscvw52/include -c .sl79_gcc11/OBJ/StRoot/StarRoot/StBiTree.cxx -o .sl79_gcc11/OBJ/StRoot/StarRoot/StBiTree.o
In file included from .sl79_gcc11/OBJ/StRoot/StarRoot/StBiTree.h:11,
                 from .sl79_gcc11/OBJ/StRoot/StarRoot/StBiTree.cxx:1:
.sl79_gcc11/OBJ/StRoot/StarRoot/StBiTreeIter.h:12:7: error: too many template-parameter-lists
   12 | class iterator<input_iterator_tag, class StBiTree<T> > {
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
plexoos added 3 commits July 8, 2022 10:01
The compiler errors are:

```
g++ -fPIC -pipe -Wall -Woverloaded-virtual -std=c++0x -Wno-long-long -pthread -Wno-deprecated-declarations -m64 -O2 -g -falign-loops -falign-jumps -falign-functions -Dsl79_gcc11 -D__ROOT__ -DNEW_DAQ_READER -I. -IStRoot -I.sl79_gcc11/include -I/opt/software/linux-scientific7-x86_64/gcc-11.2.1/root-5.34.38-p7sjrh5whm6m2ao3zxkaoaqomiscvw52/include -c .sl79_gcc11/OBJ/StarVMC/StarAgmlLib/AgAttribute.cxx -o .sl79_gcc11/OBJ/StarVMC/StarAgmlLib/AgAttribute.o
In file included from .sl79_gcc11/OBJ/StarVMC/StarAgmlLib/AgBlock.h:17,
                 from .sl79_gcc11/OBJ/StarVMC/StarAgmlLib/AgAttribute.cxx:2:
.sl79_gcc11/OBJ/StarVMC/StarAgmlLib/AgMath.h:57:28: error: 'double abs(double)' conflicts with a previous declaration
   57 | inline double abs (double x) {return fabs(x);}
      |                            ^
In file included from /opt/rh/devtoolset-11/root/usr/include/c++/11/cstdlib:77,
                 from /opt/rh/devtoolset-11/root/usr/include/c++/11/ext/string_conversions.h:41,
                 from /opt/rh/devtoolset-11/root/usr/include/c++/11/bits/basic_string.h:6607,
                 from /opt/rh/devtoolset-11/root/usr/include/c++/11/string:55,
                 from /opt/software/linux-scientific7-x86_64/gcc-11.2.1/root-5.34.38-p7sjrh5whm6m2ao3zxkaoaqomiscvw52/include/TSchemaHelper.h:25,
                 from /opt/software/linux-scientific7-x86_64/gcc-11.2.1/root-5.34.38-p7sjrh5whm6m2ao3zxkaoaqomiscvw52/include/TGenericClassInfo.h:17,
                 from /opt/software/linux-scientific7-x86_64/gcc-11.2.1/root-5.34.38-p7sjrh5whm6m2ao3zxkaoaqomiscvw52/include/Rtypes.h:270,
                 from /opt/software/linux-scientific7-x86_64/gcc-11.2.1/root-5.34.38-p7sjrh5whm6m2ao3zxkaoaqomiscvw52/include/TObject.h:31,
                 from /opt/software/linux-scientific7-x86_64/gcc-11.2.1/root-5.34.38-p7sjrh5whm6m2ao3zxkaoaqomiscvw52/include/TNamed.h:26,
                 from .sl79_gcc11/OBJ/StarVMC/StarAgmlLib/AgAttribute.h:4,
                 from .sl79_gcc11/OBJ/StarVMC/StarAgmlLib/AgAttribute.cxx:1:
/opt/rh/devtoolset-11/root/usr/include/c++/11/bits/std_abs.h:71:3: note: previous declaration 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
In file included from .sl79_gcc11/OBJ/StarVMC/StarAgmlLib/AgBlock.h:17,
                 from .sl79_gcc11/OBJ/StarVMC/StarAgmlLib/AgAttribute.cxx:2:
.sl79_gcc11/OBJ/StarVMC/StarAgmlLib/AgMath.h:42:14: error: '_fpos_' was not declared in this scope; did you mean 'fpos_t'?
   42 | #define fpos _fpos_
      |              ^~~~~~
In file included from /opt/software/linux-scientific7-x86_64/gcc-11.2.1/root-5.34.38-p7sjrh5whm6m2ao3zxkaoaqomiscvw52/include/Riostream.h:31,
                 from .sl79_gcc11/include/Stiostream.h:36,
                 from .sl79_gcc11/include/StMessMgr.h:106,
                 from .sl79_gcc11/OBJ/StarVMC/StarAgmlLib/AgAttribute.cxx:3:
/opt/rh/devtoolset-11/root/usr/include/c++/11/fstream:98:52: error: template argument 2 is invalid
   98 |                             fpos<typename _Traits::state_type>>::value,
      |                                                    ^~~~~~~~~~
/opt/rh/devtoolset-11/root/usr/include/c++/11/fstream:98:66: error: '::value' has not been declared
   98 |                             fpos<typename _Traits::state_type>>::value,
      |                                                                  ^~~~~
cons: *** [.sl79_gcc11/OBJ/StarVMC/StarAgmlLib/AgAttribute.o] Error 1
cons: errors constructing .sl79_gcc11/OBJ/StarVMC/StarAgmlLib/AgAttribute.o
```

As suggested by @klendathu2k in star-bnl#370 (comment)
we expose std::abs in StarVMC/StarAgmlLib/AgMath.h
There is no operator== overload in std::ostream
Using 'x' prefix is deprecated by GNU Fortran and requires the
`-fallow-invalid-boz` option to enable the extension in GCC 11.
@plexoos plexoos added the infrastructure Build environment and configuration label Jul 8, 2022
@plexoos
Copy link
Copy Markdown
Member Author

plexoos commented Jul 8, 2022

Rebased this PR branch before final merge. No new changes since previous reviews except incorporating changes suggested by @klendathu2k in #370

@plexoos plexoos marked this pull request as ready for review July 8, 2022 14:41
@plexoos plexoos requested a review from perevbnlgov as a code owner July 8, 2022 14:41
@plexoos plexoos changed the title Fix errrors reported by gcc11 Fix errrors reported by GCC 11.2.1 Jul 8, 2022
@plexoos plexoos merged commit 1566c47 into star-bnl:main Jul 8, 2022
@plexoos plexoos deleted the pr/gcc11_fixes branch July 8, 2022 18:43
plexoos added a commit to plexoos/star-sw that referenced this pull request Jul 8, 2022
-fno-common is the default starting gcc 10

From https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html

> The -fcommon places uninitialized global variables in a common block.
> This allows the linker to resolve all tentative definitions of the same
> variable in different compilation units to the same object, or to
> a non-tentative definition. This behavior is inconsistent with C++, and
> on many targets implies a speed and code size penalty on global variable
> references. It is mainly useful to enable legacy code to link without
> errors.

Many thanks to @veprbl for the helpful suggestion:

star-bnl#366 (comment)
plexoos added a commit that referenced this pull request Jul 9, 2022
-fno-common is the default starting gcc 10

From https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html

> The -fcommon places uninitialized global variables in a common block.
> This allows the linker to resolve all tentative definitions of the same
> variable in different compilation units to the same object, or to
> a non-tentative definition. This behavior is inconsistent with C++, and
> on many targets implies a speed and code size penalty on global variable
> references. It is mainly useful to enable legacy code to link without
> errors.

Many thanks to @veprbl for the helpful suggestion:

#366 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infrastructure Build environment and configuration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants