error building in debug mode on debian


#1

Hi, after some time I’ve tried a fresh build of panda in debug mode on debian 8 with this command :

CXXFLAGS=-std=c++11 makepanda/makepanda.py --verbose --everything --no-fftw --no-gles --no-gles2  --outputdir built.debug --threads 7 --optimize 1 --installer

but I got this error:

...
[T1] Linking executable built.debug/bin/pview
g++ -o built.debug/bin/pview -Lbuilt.debug/lib -Lbuilt.debug/tmp built.debug/tmp/pview_pview.o built.debug/lib/libp3framework.so built.debug/lib/libpandaegg.so built.debug/lib/libpanda.so built.debug/lib/libpandaexpress.so built.debug/lib/libp3dtool.so built.debug/lib/libp3dtoolconfig.so -pthread -L/usr/X11R6/lib -ldl
built.debug/lib/libpandaegg.so: undefined reference to `PointerTo<EggTexture>::PointerTo()'
collect2: error: ld returned 1 exit status
Process exited with exit status 0 and signal code 1
The following command returned a non-zero value: g++ -o built.debug/bin/pview -Lbuilt.debug/lib -Lbuilt.debug/tmp built.debug/tmp/pview_pview.o built.debug/lib/libp3framework.so built.debug/lib/libpandaegg.so built.debug/lib/libpanda.so built.debug/lib/libpandaexpress.so built.debug/lib/libp3dtool.so built.debug/lib/libp3dtoolconfig.so -pthread -L/usr/X11R6/lib -ldl
Storing dependency cache.
Elapsed Time: 1 sec
Build process aborting.
Build terminated.
...

When building in release mode (i.e. with --optimize 3) there is no problem. The git branch is master.


#2

I’m trying, but I’m afraid I cannot reproduce this issue. I’ve tried with both clang and gcc. Which version of gcc are you using?

On a sidenote, you don’t have to pass -std=c++11 nowadays since makepanda already does the equivalent.


#3

The version of gcc in debian 8 is 4.9.2.

I also tried to build with gcc 5.4.0 on ubuntu 16.04 and I got similar results:
-the debug build is unsuccessful with this error

...
[T1] Linking executable built.debug/bin/pview
g++ -o built.debug/bin/pview -Lbuilt.debug/lib -Lbuilt.debug/tmp built.debug/tmp/pview_pview.o built.debug/lib/libp3framework.so built.debug/lib/libpandaegg.so built.debug/lib/libpanda.so built.debug/lib/libpandaexpress.so built.debug/lib/libp3dtool.so built.debug/lib/libp3dtoolconfig.so -pthread -L/usr/X11R6/lib -ldl
/usr/bin/ld: built.debug/bin/pview: hidden symbol `__cpu_model' in /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a(cpuinfo.o) is referenced by DSO
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Process exited with exit status 0 and signal code 1
The following command returned a non-zero value: g++ -o built.debug/bin/pview -Lbuilt.debug/lib -Lbuilt.debug/tmp built.debug/tmp/pview_pview.o built.debug/lib/libp3framework.so built.debug/lib/libpandaegg.so built.debug/lib/libpanda.so built.debug/lib/libpandaexpress.so built.debug/lib/libp3dtool.so built.debug/lib/libp3dtoolconfig.so -pthread -L/usr/X11R6/lib -ldl
Storing dependency cache.
Elapsed Time: 1 sec
Build process aborting.
Build terminated.
...

-the release build is successful


#4

Hmm, I believe the __cpu_model issue is fixed with my latest push, please try it again.


#5

I tried, but unfortunately the problem is still there:

  • with gcc 4.9.2/debian the error is the same as above
  • with gcc 5.4.0/ubuntu the error has changed in this other:
...
[T1] Linking executable built.debug/bin/bam2egg
g++ -o built.debug/bin/bam2egg -Lbuilt.debug/lib -Lbuilt.debug/tmp built.debug/tmp/bam2egg_bamToEgg.o built.debug/lib/libp3eggbase.a built.debug/lib/libp3progbase.a built.debug/lib/libp3converter.a built.debug/lib/libp3pandatoolbase.a built.debug/lib/libpandaegg.so built.debug/lib/libpanda.so built.debug/lib/libpandaexpress.so built.debug/lib/libp3dtool.so built.debug/lib/libp3dtoolconfig.so -pthread -L/usr/X11R6/lib -ldl
built.debug/lib/libpandaegg.so: undefined reference to `PointerTo<EggMaterial>::PointerTo()'
built.debug/lib/libpandaegg.so: undefined reference to `PointerTo<EggVertex>::PointerTo()'
built.debug/lib/libpandaegg.so: undefined reference to `PointerTo<EggTexture>::PointerTo()'
collect2: error: ld returned 1 exit status
Process exited with exit status 0 and signal code 1
The following command returned a non-zero value: g++ -o built.debug/bin/bam2egg -Lbuilt.debug/lib -Lbuilt.debug/tmp built.debug/tmp/bam2egg_bamToEgg.o built.debug/lib/libp3eggbase.a built.debug/lib/libp3progbase.a built.debug/lib/libp3converter.a built.debug/lib/libp3pandatoolbase.a built.debug/lib/libpandaegg.so built.debug/lib/libpanda.so built.debug/lib/libpandaexpress.so built.debug/lib/libp3dtool.so built.debug/lib/libp3dtoolconfig.so -pthread -L/usr/X11R6/lib -ldl
Storing dependency cache.
Elapsed Time: 3 sec
Build process aborting.
Build terminated.
...

#6

After some investigations, I found out that the debug build is successful if the constructors of PointerTo, ConstPointerTo and PointerToBase are made ALWAYS_INLINE.
That is in panda/src/express/pointerTo.h I put

...
ALWAYS_INLINE CONSTEXPR PointerTo() NOEXCEPT DEFAULT_CTOR;
...
ALWAYS_INLINE CONSTEXPR ConstPointerTo() NOEXCEPT DEFAULT_CTOR;
...

and in panda/src/express/pointerToBase.h I put

ALWAYS_INLINE CONSTEXPR PointerToBase() NOEXCEPT DEFAULT_CTOR;

#7

Nice catch! That looks like a compiler bug. Thanks for finding a workaround. I will commit it shortly.