Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1819270 - Unresolved symbol on static template called from static class method
Summary: Unresolved symbol on static template called from static class method
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: 0ad
Version: 32
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Paulo Andrade
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-03-31 15:20 UTC by Paulo Andrade
Modified: 2020-04-02 12:49 UTC (History)
14 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-02 12:49:47 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1799112 0 unspecified CLOSED 0ad: FTBFS in Fedora rawhide/f32 2022-05-16 11:32:56 UTC

Description Paulo Andrade 2020-03-31 15:20:24 UTC
Code did compile with previous gcc versions. But it is somewhat
old code.
Patch used to build on f32 is
https://src.fedoraproject.org/rpms/0ad/blob/a544c594cbf6dea76160dd338e75166390b6de2d/f/0ad-fcollada.patch

Patch to FAXInstanceExport.cpp was added due to error when calling
the static template from a static method, without an object instance.

The workaround was to define the template in the header file,
declaring the class.

Comment 1 Jonathan Wakely 2020-03-31 15:45:05 UTC
(In reply to Paulo Andrade from comment #0)
> Patch to FAXInstanceExport.cpp was added due to error when calling
> the static template from a static method, without an object instance.

That makes no sense.

> The workaround was to define the template in the header file,
> declaring the class.

I don't think it's a workaround, I think it's fixing invalid code.

I don't see a GCC bug here.

Comment 2 Paulo Andrade 2020-03-31 17:08:08 UTC
(In reply to Jonathan Wakely from comment #1)
> (In reply to Paulo Andrade from comment #0)
> > Patch to FAXInstanceExport.cpp was added due to error when calling
> > the static template from a static method, without an object instance.
> 
> That makes no sense.

  I also think so. Maybe I did not explain it correctly.

> > The workaround was to define the template in the header file,
> > declaring the class.
> 
> I don't think it's a workaround, I think it's fixing invalid code.
> 
> I don't see a GCC bug here.

  You might take a quick look on the source code here

https://github.com/0ad/0ad/tree/master/libraries/source/fcollada/src/FColladaPlugins/FArchiveXML

to have an idea of the source code.

Or latest (and very short lived) build logs after the patch at
https://koji.fedoraproject.org/koji/taskinfo?taskID=42916164

the failing build logs attached to
https://bugzilla.redhat.com/show_bug.cgi?id=1799112
do not show all errors (it only shows the last 32Kb), but without the patch, I see:

FColladaPlugins/FArchiveXML/FAXInstanceExport.cpp: In static member function 'st
atic xmlNode* FArchiveXML::WritePhysicsRigidBodyInstance(FCDObject*, xmlNode*)':
FColladaPlugins/FArchiveXML/FAXInstanceExport.cpp:258:126: error: cannot call member function 'xmlNode* FArchiveXML::AddPhysicsParameter(xmlNode*, const char*, FCDParameterAnimatableT<TYPE, QUALIFIERS>&) [with TYPE = FMVector3; int QUAL = 0; xmlNode = _xmlNode]' without object
  258 |  FArchiveXML::AddPhysicsParameter(techniqueNode, DAE_ANGULAR_VELOCITY_ELEMENT, physicsRigidBodyInstance->GetAngularVelocity());
      |                                                                                                                              ^
FColladaPlugins/FArchiveXML/FAXInstanceExport.cpp:259:111: error: cannot call member function 'xmlNode* FArchiveXML::AddPhysicsParameter(xmlNode*, const char*, FCDParameterAnimatableT<TYPE, QUALIFIERS>&) [with TYPE = FMVector3; int QUAL = 0; xmlNode = _xmlNode]' without object
  259 |  FArchiveXML::AddPhysicsParameter(techniqueNode, DAE_VELOCITY_ELEMENT, physicsRigidBodyInstance->GetVelocity());
      |                                                                                                               ^

the above is the reason of the patch to FAXInstanceExport.cpp

and the ending errors:

g++ -o "../../../binaries/system/libCollada.so" obj/Collada_Release/CommonConvert.o obj/Collada_Release/DLL.o obj/Collada_Release/Decompose.o obj/Collada_Release/GeomReindex.o obj/Collada_Release/Maths.o obj/Collada_Release/PMDConvert.o obj/Collada_Release/PSAConvert.o obj/Collada_Release/StdSkeletons.o obj/Collada
_Release/XMLFix.o obj/Collada_Release/precompiled.o    -L../../../binaries/system -L../../../libraries/source/fcollada/lib -L/usr/X11R6/lib -shared -Wl,-soname=libCollada.so -Wl,--no-undefined -Wl,--as-needed -Wl,-z,relro -Wl,-rpath,/usr/lib64/0ad -rdynamic -lFColladaSR -lxml2 -ldl
/usr/bin/ld: ../../../libraries/source/fcollada/lib/libFColladaSR.a(FAXInstanceExport.o): in function `FArchiveXML::WritePhysicsRigidBodyInstance(FCDObject*, _xmlNode*)':
/builddir/build/BUILD/0ad-0.0.23b-alpha/libraries/source/fcollada/src/FColladaPlugins/FArchiveXML/FAXInstanceExport.cpp:258: undefined reference to `_xmlNode* FArchiveXML::AddPhysicsParameter<FMVector3, 0>(_xmlNode*, char const*, FCDParameterAnimatableT<FMVector3, 0>&)'
/usr/bin/ld: /builddir/build/BUILD/0ad-0.0.23b-alpha/libraries/source/fcollada/src/FColladaPlugins/FArchiveXML/FAXInstanceExport.cpp:259: undefined reference to `_xmlNode* FArchiveXML::AddPhysicsParameter<FMVector3, 0>(_xmlNode*, char const*, FCDParameterAnimatableT<FMVector3, 0>&)'
collect2: error: ld returned 1 exit status

This bug report is just to work as a possible heads up on a possible issue,
as this code used to compile and build since f16, when the 0ad package
was added to Fedora.

Comment 3 Jonathan Wakely 2020-03-31 18:42:02 UTC
(In reply to Paulo Andrade from comment #2)
> Or latest (and very short lived) build logs after the patch at
> https://koji.fedoraproject.org/koji/taskinfo?taskID=42916164
> 
> the failing build logs attached to
> https://bugzilla.redhat.com/show_bug.cgi?id=1799112
> do not show all errors (it only shows the last 32Kb), but without the patch,
> I see:
> 
> FColladaPlugins/FArchiveXML/FAXInstanceExport.cpp: In static member function
> 'st
> atic xmlNode* FArchiveXML::WritePhysicsRigidBodyInstance(FCDObject*,
> xmlNode*)':
> FColladaPlugins/FArchiveXML/FAXInstanceExport.cpp:258:126: error: cannot
> call member function 'xmlNode* FArchiveXML::AddPhysicsParameter(xmlNode*,
> const char*, FCDParameterAnimatableT<TYPE, QUALIFIERS>&) [with TYPE =
> FMVector3; int QUAL = 0; xmlNode = _xmlNode]' without object
>   258 |  FArchiveXML::AddPhysicsParameter(techniqueNode,
> DAE_ANGULAR_VELOCITY_ELEMENT,
> physicsRigidBodyInstance->GetAngularVelocity());
>       |                                                                     
> ^
> FColladaPlugins/FArchiveXML/FAXInstanceExport.cpp:259:111: error: cannot
> call member function 'xmlNode* FArchiveXML::AddPhysicsParameter(xmlNode*,
> const char*, FCDParameterAnimatableT<TYPE, QUALIFIERS>&) [with TYPE =
> FMVector3; int QUAL = 0; xmlNode = _xmlNode]' without object
>   259 |  FArchiveXML::AddPhysicsParameter(techniqueNode,
> DAE_VELOCITY_ELEMENT, physicsRigidBodyInstance->GetVelocity());
>       |                                                                     
> ^
> 
> the above is the reason of the patch to FAXInstanceE

This should not be possible. Are you sure you didn't incorrectly apply the changes to FArchiveXML.h and accidentally remove the 'static', which would cause the error above?


> This bug report is just to work as a possible heads up on a possible issue,
> as this code used to compile and build since f16, when the 0ad package
> was added to Fedora.

That doesn't mean the code was correct.

I think this is the same issue as Bug 1794127, the code is not correct unless the function template is defined in the header, or there is an explicit instantiation declaration. In particular, see Bug 1794127 comment 7.

Comment 4 Jonathan Wakely 2020-03-31 20:29:06 UTC
(In reply to Jonathan Wakely from comment #3)
> (In reply to Paulo Andrade from comment #2)
> > Or latest (and very short lived) build logs after the patch at
> > https://koji.fedoraproject.org/koji/taskinfo?taskID=42916164
> > 
> > the failing build logs attached to
> > https://bugzilla.redhat.com/show_bug.cgi?id=1799112
> > do not show all errors (it only shows the last 32Kb), but without the patch,
> > I see:
> > 
> > FColladaPlugins/FArchiveXML/FAXInstanceExport.cpp: In static member function
> > 'st
> > atic xmlNode* FArchiveXML::WritePhysicsRigidBodyInstance(FCDObject*,
> > xmlNode*)':
> > FColladaPlugins/FArchiveXML/FAXInstanceExport.cpp:258:126: error: cannot
> > call member function 'xmlNode* FArchiveXML::AddPhysicsParameter(xmlNode*,
> > const char*, FCDParameterAnimatableT<TYPE, QUALIFIERS>&) [with TYPE =
> > FMVector3; int QUAL = 0; xmlNode = _xmlNode]' without object
> >   258 |  FArchiveXML::AddPhysicsParameter(techniqueNode,
> > DAE_ANGULAR_VELOCITY_ELEMENT,
> > physicsRigidBodyInstance->GetAngularVelocity());
> >       |                                                                     
> > ^
> > FColladaPlugins/FArchiveXML/FAXInstanceExport.cpp:259:111: error: cannot
> > call member function 'xmlNode* FArchiveXML::AddPhysicsParameter(xmlNode*,
> > const char*, FCDParameterAnimatableT<TYPE, QUALIFIERS>&) [with TYPE =
> > FMVector3; int QUAL = 0; xmlNode = _xmlNode]' without object
> >   259 |  FArchiveXML::AddPhysicsParameter(techniqueNode,
> > DAE_VELOCITY_ELEMENT, physicsRigidBodyInstance->GetVelocity());
> >       |                                                                     
> > ^
> > 
> > the above is the reason of the patch to FAXInstanceE
> 
> This should not be possible. Are you sure you didn't incorrectly apply the
> changes to FArchiveXML.h and accidentally remove the 'static', which would
> cause the error above?

I've just removed that part of the patch and it still builds fine, as expected.

Scratch build: https://koji.fedoraproject.org/koji/taskinfo?taskID=42929681

Comment 5 Paulo Andrade 2020-04-02 12:19:01 UTC
I agree that part should no longer be required, after fully declaring the
template in the header file.

But before that, it was required to avoid the compile time error. But
would still fail to link.

Will update the package to remove that part for next builds. Otherwise,
with that chunk it should just work, so, no need for a new f32 update.

It should be enough to move the static template definition from
FAXPhysicsExport.cpp to FArchiveXML.h
https://src.fedoraproject.org/rpms/0ad/blob/a544c594cbf6dea76160dd338e75166390b6de2d/f/0ad-fcollada.patch
Maybe it should be moved to some other .cpp file, or declared in every
.cpp file that uses it? If that is the case, the proper place would be
in the header file.

Comment 6 Jonathan Wakely 2020-04-02 12:23:04 UTC
(In reply to Paulo Andrade from comment #5)
> But before that, it was required to avoid the compile time error.

I still don't believe it.

Anyway, reassigning to the right component, as this isn't a GCC bug.

Comment 7 Paulo Andrade 2020-04-02 12:29:47 UTC
(In reply to Jonathan Wakely from comment #6)
> (In reply to Paulo Andrade from comment #5)
> > But before that, it was required to avoid the compile time error.
> 
> I still don't believe it.
> 
> Anyway, reassigning to the right component, as this isn't a GCC bug.

I will double check it. Agree it might have been my fault, as
mock build.log is not truncated, and in one of my test builds
I might have changed that, and looked in the wrong portion.
In a few minutes should be 100% sure.

Comment 8 Paulo Andrade 2020-04-02 12:49:47 UTC
You are right. I made several experiments in test builds,
and should have removed the static keyword in one of them.

Issue will be reported to fcollada interested parties.


Note You need to log in before you can comment on or make changes to this bug.