link failure: defined in discarded section

Hi:

I am trying to link a C++ code on an Ubuntu linux which does have a large number of template instantiations. If I use g++ (4.2.3) on linux then the code links just fine. Using pgCC 7.2-3 the code gives me the link errors
listed at the botom. Here are the compile and link lines:

mpicxx -g -DMPICH_IGNORE_CXX_SEEK -DMPICH_SKIP_MPICXX -DNDIM=3 -g -DMPICH_IGNORE_CXX_SEEK -DMPICH_SKIP_MPICXX -I. -I/packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/include -I/packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/include -I/packages/petsc/petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/include -I/packages/petsc/petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/include/private -I/packages/hypre/hypre-2.0.0-mpich2-1.0.6p1-pgi-7.2-3-debug/include -I/packages/hdf/hdf5-1.6.7-mpich2-1.0.6p1-pgi-7.2-3-debug/include -I/packages/mpi/mpich2-1.0.6p1-pgi-7.2-3-debug/include -DNDIM=3 -I/netscratch/bphilip/projects/utils/include -c testInterpolation.C -o testInterpolation.o

mpicxx -g -DMPICH_IGNORE_CXX_SEEK -DMPICH_SKIP_MPICXX -DNDIM=3 -L/packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib -L/packages/petsc/petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib -L/packages/hypre/hypre-2.0.0-mpich2-1.0.6p1-pgi-7.2-3-debug/lib -L/packages/hdf/hdf5-1.6.7-mpich2-1.0.6p1-pgi-7.2-3-debug/lib -L/packages/mpi/mpich2-1.0.6p1-pgi-7.2-3-debug/lib -R /packages/mpi/mpich2-1.0.6p1-pgi-7.2-3-debug/lib -L/packages/mpi/mpich2-1.0.6p1-pgi-7.2-3-debug/lib -L/nh/vendor/Linux/pgi/Ubuntu8.04-AMD64/PGI_Server-7.2-3/linux86-64/7.2-3/lib -R /nh/vendor/Linux/pgi/Ubuntu8.04-AMD64/PGI_Server-7.2-3/linux86-64/7.2-3/lib -L/usr/lib64 -R /usr/lib64 -L/usr/lib/gcc/x86_64-linux-gnu/4.2.3 -R /usr/lib/gcc/x86_64-linux-gnu/4.2.3 testInterpolation.o BogusTagAndInitStrategy.o
/netscratch/bphilip/projects/utils/lib/libAMRUtils3d.a /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI3d_appu.a /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI3d_algs.a /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI3d_solv.a /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI3d_geom.a /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI3d_mesh.a /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI3d_math_std.a /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI3d_pdat_std.a /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI3d_xfer.a /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI3d_hier.a /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI.a -L/packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib -L/packages/petsc/petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib -L/packages/hypre/hypre-2.0.0-mpich2-1.0.6p1-pgi-7.2-3-debug/lib -L/packages/hdf/hdf5-1.6.7-mpich2-1.0.6p1-pgi-7.2-3-debug/lib -L/packages/mpi/mpich2-1.0.6p1-pgi-7.2-3-debug/lib -R /packages/mpi/mpich2-1.0.6p1-pgi-7.2-3-debug/lib -L/packages/mpi/mpich2-1.0.6p1-pgi-7.2-3-debug/lib -L/nh/vendor/Linux/pgi/Ubuntu8.04-AMD64/PGI_Server-7.2-3/linux86-64/7.2-3/lib -R /nh/vendor/Linux/pgi/Ubuntu8.04-AMD64/PGI_Server-7.2-3/linux86-64/7.2-3/lib -L/usr/lib64 -R /usr/lib64 -L/usr/lib/gcc/x86_64-linux-gnu/4.2.3 -R /usr/lib/gcc/x86_64-linux-gnu/4.2.3 -lpetsccontrib -lpetscksp -lpetscsnes -lpetscdm -lpetscts -lpetscmat -lpetscvec -lpetsc -lHYPRE_sstruct_ls -lHYPRE_sstruct_mv -lHYPRE_struct_ls -lHYPRE_struct_mv -lHYPRE_parcsr_ls -lHYPRE_DistributedMatrixPilutSolver -lHYPRE_ParaSails -lHYPRE_Euclid -lHYPRE_MatrixMatrix -lHYPRE_DistributedMatrix -lHYPRE_IJ_mv -lHYPRE_parcsr_mv -lHYPRE_seq_mv -lHYPRE_krylov -lHYPRE_utilities -lhdf5 -llapack -lblas -lz -ldl -lSM -lICE -lX11 -L/usr/lib/gcc/x86_64-linux-gnu/4.2.3 -L/usr/lib64 -L/nh/vendor/Linux/pgi/Ubuntu8.04-AMD64/PGI_Server-7.2-3/linux86-64/7.2-3/lib -L/packages/mpi/mpich2-1.0.6p1-pgi-7.2-3-debug/lib -lmpichf90 -lmpich -lpthread -lrt -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lnspgc -lpgc -lm -lgcc -o testInterpolation

The output of mpicxx -show is:
pgCC -I/packages/mpi/mpich2-1.0.6p1-pgi-7.2-3-debug/include -L/packages/mpi/mpich2-1.0.6p1-pgi-7.2-3-debug/lib -lmpichcxx -lmpich -lpthread -lrt

The output of ld -v is:
GNU ld (GNU Binutils for Ubuntu) 2.18.0.20080103

The link errors I get are:

.gnu.linkonce.t.__CPR236__getReverseRotationIdentifier__Q3_6SAMRAI4hier40MultiblockPatchHierarchy__tm__9_XCiL_1_3SFQ4_J33JJ40J36MultiblockPatchHierarchy__tm__5_XZ1Z18RotationIdentifier_QJ90JMRAIJ40JJ104JJ142J' referenced in section .data’ of /netscratch/bphilip/projects/utils/lib/libAMRUtils3d.a(RefinementBoundaryInterpolation-template-inst.o): defined in discarded section .gnu.linkonce.t.__CPR236__getReverseRotationIdentifier__Q3_6SAMRAI4hier40MultiblockPatchHierarchy__tm__9_XCiL_1_3SFQ4_J33JJ40J36MultiblockPatchHierarchy__tm__5_XZ1Z18RotationIdentifier_QJ90JMRAIJ40JJ104JJ142J' of /netscratch/bphilip/projects/utils/lib/libAMRUtils3d.a(RefinementBoundaryInterpolation-template-inst.o) .gnu.linkonce.t.__CPR236__getReverseRotationIdentifier__Q3_6SAMRAI4hier40MultiblockPatchHierarchy__tm__9_XCiL_1_3SFQ4_J33JJ40J36MultiblockPatchHierarchy__tm__5_XZ1Z18RotationIdentifier_QJ90JMRAIJ40JJ104JJ142J’ referenced in section .data' of /netscratch/bphilip/projects/utils/lib/libAMRUtils3d.a(HierarchyBoundaryFragments.o): defined in discarded section .gnu.linkonce.t.__CPR236__getReverseRotationIdentifier__Q3_6SAMRAI4hier40MultiblockPatchHierarchy__tm__9_XCiL_1_3SFQ4_J33JJ40J36MultiblockPatchHierarchy__tm__5_XZ1Z18RotationIdentifier_QJ90JMRAIJ40JJ104JJ142J’ of /netscratch/bphilip/projects/utils/lib/libAMRUtils3d.a(HierarchyBoundaryFragments.o)
.gnu.linkonce.t.__CPR236__getReverseRotationIdentifier__Q3_6SAMRAI4hier40MultiblockPatchHierarchy__tm__9_XCiL_1_3SFQ4_J33JJ40J36MultiblockPatchHierarchy__tm__5_XZ1Z18RotationIdentifier_QJ90JMRAIJ40JJ104JJ142J' referenced in section .data’ of /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI3d_algs.a(tbox__Pointer-algs__HyperbolicLevelIntegrator-NDIM3.o): defined in discarded section .gnu.linkonce.t.__CPR236__getReverseRotationIdentifier__Q3_6SAMRAI4hier40MultiblockPatchHierarchy__tm__9_XCiL_1_3SFQ4_J33JJ40J36MultiblockPatchHierarchy__tm__5_XZ1Z18RotationIdentifier_QJ90JMRAIJ40JJ104JJ142J' of /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI3d_algs.a(tbox__Pointer-algs__HyperbolicLevelIntegrator-NDIM3.o) .gnu.linkonce.t.__CPR236__getReverseRotationIdentifier__Q3_6SAMRAI4hier40MultiblockPatchHierarchy__tm__9_XCiL_1_3SFQ4_J33JJ40J36MultiblockPatchHierarchy__tm__5_XZ1Z18RotationIdentifier_QJ90JMRAIJ40JJ104JJ142J’ referenced in section .data' of /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI3d_pdat_std.a(tbox__Pointer-pdat__CellDataFactory-NDIM_double3.o): defined in discarded section .gnu.linkonce.t.__CPR236__getReverseRotationIdentifier__Q3_6SAMRAI4hier40MultiblockPatchHierarchy__tm__9_XCiL_1_3SFQ4_J33JJ40J36MultiblockPatchHierarchy__tm__5_XZ1Z18RotationIdentifier_QJ90JMRAIJ40JJ104JJ142J’ of /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI3d_pdat_std.a(tbox__Pointer-pdat__CellDataFactory-NDIM_double3.o)
.gnu.linkonce.t.__CPR236__getReverseRotationIdentifier__Q3_6SAMRAI4hier40MultiblockPatchHierarchy__tm__9_XCiL_1_3SFQ4_J33JJ40J36MultiblockPatchHierarchy__tm__5_XZ1Z18RotationIdentifier_QJ90JMRAIJ40JJ104JJ142J' referenced in section .data’ of /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI3d_pdat_std.a(tbox__Pointer-pdat__CellDataFactory-NDIM_int3.o): defined in discarded section `.gnu.linkonce.t.__CPR236__getReverseRotationIdentifier__Q3_6SAMRAI4hier40MultiblockPatchHierarchy__tm__9_XCiL_1_3SFQ4_J33JJ40J36MultiblockPatchHierarchy__tm__5_XZ1Z18RotationIdentifier_QJ90JMRAIJ40JJ104JJ142J’ of /packages/samrai/SAMRAI-v2.3.0-petsc-dev-mpich2-1.0.6p1-pgi-7.2-3-debug/lib/libSAMRAI3d_pdat_std.a(tbox__Pointer-pdat__CellDataFactory-NDIM_int3.o)

I would appreciate your help!

bphilip -

We have seen this bug before(filed as FS4013). Some versions of the gnu linker seem
to get confused when handling the references from the .data sections into the
.linkonce sections.

These references are valid code, and they happen often with our implementation of
C++ templates. g++ may not run into this problem because their internal implemetation is slightly different.

If you can update to a newer version of g++ , you may see this gnu linker bug disappear.

Deborah:

Thanks for your response. Are you suggesting I update my version of g++ or my version of binutils?

Bobby

Hi Bobby,

I asked Deb and she meant for you to try updating your binutils.

  • Mat

We’ve found the issue, and it should be fixed for the next release.

C++ templated functions that contained large switch statements caused
the error for newer version of the gnu linker.
We have fixed our method of generation to be compatible with gnu’s new
requirements.

Thank you for your patience.
-Deborah Caruso