This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fwd: Duplicate Symbols when compiling with arm-linux-gnueabihf


U.Mutlu wrote on 07/13/2018 09:24 AM:
I think it's caused by this:
-I/opt/sed-stash/biogears/external/linux-gcc5.4-armel/include

Ie. it seems a header file is included multiple times,
but has no protection defined against multiple including.
Add such protectors to the header file:

#ifndef fileXYZ_defined
#define fileXYZ_defined
...
#endif


And add "-Wall -Wextra" to CFLAGS and CXXFLAGS



Ignitus Boyone wrote on 07/13/2018 03:58 AM:
I've been able to reduce the original example down to 2 classes with a
common header.  It can likely be reduced further, but this kind of keeps
the style of the original codebase.

So, from what I can tell if you inherit from a template in two different
classes on arm-linux-gnueabihf  the template specification for the
inheritance  gets exported in the object format of both compilation units.
However when compiling to aarch64-linux-gnu this doesn't happen and you can
link the two objects together.   The make file in the tar ball provided in
the drive link allows you to easily switch between compilers and while the
example is functional in anyway it at least simplifies the recreate.

Does anyone have any idea's what difference in the output formats for armel
and aarch64 would cause this issue or if some gcc flag might help avoid the
issue.  The original source files are generated by XSD CodeSynthesis from
an XSD file.  I have some ability to modify the XSD definitions if this is
avoidable, but I'm hoping that a solution can be found with out needing
code changes.  I can explain further on request.

https://drive.google.com/open?id=1xfzEyugXOGKYuj69JKD2RXqbMBQ4ro4r

---------- Forwarded message ----------
From: Ignitus Boyone <ignitusboyone@gmail.com>
Date: Tue, Jul 10, 2018 at 12:24 PM
Subject: Duplicate Symbols when compiling with arm-linux-gnueabihf
To: gcc-help@gcc.gnu.org


I'm working on a problem where I have a code sample from biogears
https://github.com/BioGearsEngine/core

Where my XSD CodeSynthesis generated code fails the one definition rule
when compiled against an gcc5.4 armhf compiler.  I regularly build the same
files against gcc5.4 arm64 MacOS & Linux and Visual Studio 2017 Win64.  I
can also build against gcc5.4 aarch64.  I'm including an example from my
drive account that reduces this to two compilation units. Saddly, this
requires a number of headers from XSD and Xerces-C to compile so they are
included as well.


https://drive.google.com/open?id=1xfzEyugXOGKYuj69JKD2RXqbMBQ4ro4r

I'm hopping the mailing list can point me in to some build chain or output
format difference between arm7 and arm8 that might be the cause. Or a
difference in the ubuntu 16.04 cross-compiler default flags. I'm going to
admit. I can't really decide where to start on this so any help is
appreciated.


Error armhf
arm-linux-gnueabihf-g++ (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0
20160609
Copyright (C) 2015 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



arm-linux-gnueabihf-g++ -shared -Wl,-soname,libbiogears_cdm_d.so -o
libbiogears_cdm_d.so ActionData.o ActionListData.o


ActionListData.o:(.data.rel.ro+0x348): multiple definition of `typeinfo for
xsd::cxx::tree::simple_type<char, xsd::cxx
::tree::_type>::text_content_type'

ActionData.o:(.data.rel.ro+0x348): first defined here

ActionListData.o:(.data.rel.ro+0x54): multiple definition of `typeinfo for
xsd::cxx::tree::no_prefix_mapping<char>'
ActionData.o:(.data.rel.ro+0x54): first defined here

ActionListData.o:(.data.rel.ro+0xb4): multiple definition of `typeinfo for
xsd::cxx::tree::bounds<char>'
ActionData.o:(.data.rel.ro+0xb4): first defined here

ActionListData.o:(.data.rel.ro+0x3c): multiple definition of `typeinfo for
xsd::cxx::tree::not_derived<char>'
ActionData.o:(.data.rel.ro+0x3c): first defined here

ActionListData.o:(.data.rel.ro+0x48): multiple definition of `typeinfo for
xsd::cxx::tree::no_type_info<char>'
ActionData.o:(.data.rel.ro+0x48): first defined here

ActionListData.o:(.data.rel.ro+0x60): multiple definition of `typeinfo for
xsd::cxx::tree::expected_text_content<char>
'

Success aarch64
aarch64-linux-gnu-g++ (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609

Copyright (C) 2015 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



aarch64-linux-gnu-g++ --std=c++14 -I. -Ibiogears/schema -fPIC -o
ActionData.o -c ActionData.cxx
aarch64-linux-gnu-g++ --std=c++14 -I. -Ibiogears/schema -fPIC -o
ActionListData.o -c ActionListData.cxx
Building libbiogears_cdm.so

aarch64-linux-gnu-g++ -shared -Wl,-soname,libbiogears_cdm_d.so -o
libbiogears_cdm_d.so ActionData.o ActionListData.o


Success amd64
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609

Copyright (C) 2015 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



g++ --std=c++14 -I. -Ibiogears/schema -fPIC -o ActionData.o -c
ActionData.cxx
g++ --std=c++14 -I. -Ibiogears/schema -fPIC -o ActionListData.o -c
ActionListData.cxx
Building libbiogears_cdm.so

g++ -shared -Wl,-soname,libbiogears_cdm_d.so -o libbiogears_cdm_d.so
ActionData.o ActionListData.o

Linux biogears-dev01 4.4.0-130-generic #156-Ubuntu SMP Thu Jun 14 08:53:28
UTC 2018 x86_64 x86_64 x86_64 GNU/Linux






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]