guillaumeblanc / ozz-animation

Open source c++ skeletal animation library and toolset
http://guillaumeblanc.github.io/ozz-animation/
Other
2.46k stars 302 forks source link

Build fails (linux/gcc) #122

Closed SnapperTT closed 3 years ago

SnapperTT commented 3 years ago

Two issues causing builds to fail:

[ 27%] Linking CXX static library libozz_geometry.a
/home/twigger/ozzTest/ozz-animation/extern/gtest/fused-src/gtest/gtest-all.cc: In function ‘bool testing::internal::StackGrowsDown()’:
/home/twigger/ozzTest/ozz-animation/extern/gtest/fused-src/gtest/gtest-all.cc:7844:24: error: ‘dummy’ may be used uninitialized [-Werror=maybe-uninitialized]
 7844 |   StackLowerThanAddress(&dummy, &result);
      |   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/home/twigger/ozzTest/ozz-animation/extern/gtest/fused-src/gtest/gtest-all.cc:7834:6: note: by argument 1 of type ‘const void*’ to ‘void testing::internal::StackLowerThanAddress(const void*, bool*)’ declared here
 7834 | void StackLowerThanAddress(const void* ptr, bool* result) {
      |      ^~~~~~~~~~~~~~~~~~~~~
/home/twigger/ozzTest/ozz-animation/extern/gtest/fused-src/gtest/gtest-all.cc:7842:7: note: ‘dummy’ declared here
 7842 |   int dummy;
      |       ^~~~

This can be fixed by disabling Wmaybe-uninitialized for the relavent functions:

#pragma GCC diagnostic push                                                                                                                                                                                                                                                               
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"                                                                                                                                                                                                                                    
#pragma GCC diagnostic ignored "-Wuninitialized"                                                                                                                                                                                                                                          
  int dummy;                                                                                                                                                                                                                                                                              
  *result = (&dummy < ptr);                                                                                                                                                                                                                                                               
#pragma GCC diagnostic pop                                                                                                                                                                                                                                                                
}                                                                                                                                                                                                                                                                                         

// Make sure AddressSanitizer does not tamper with the stack here.                                                                                                                                                                                                                        
GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_                                                                                                                                                                                                                                                      
bool StackGrowsDown() {                                                                                                                                                                                                                                                                   
#pragma GCC diagnostic push                                                                                                                                                                                                                                                               
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"                                                                                                                                                                                                                                    
#pragma GCC diagnostic ignored "-Wuninitialized"                                                                                                                                                                                                                                          
   int dummy;                                                                                                                                                                                                                                                                             
  bool result;                                                                                                                                                                                                                                                                            
  StackLowerThanAddress(&dummy, &result);                                                                                                                                                                                                                                                 
  return result;                                                                                                                                                                                                                                                                          
#pragma GCC diagnostic pop                                                                                                                                                                                                                                                                
}  

The second fail is due to std::thread::id::operator< not being defined

[ 98%] Linking CXX executable test_fuse_ozz_animation_tools
/usr/bin/ld: CMakeFiles/sample_multithread.dir/sample_multithread.cc.o: in function `bool __gnu_cxx::__ops::_Iter_less_iter::operator()<__gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > >, __gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > > >(__gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > >, __gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > >) const':
sample_multithread.cc:(.text._ZNK9__gnu_cxx5__ops15_Iter_less_iterclINS_17__normal_iteratorIPNSt6thread2idESt6vectorIS5_N3ozz12StdAllocatorIS5_EEEEESC_EEbT_T0_[_ZNK9__gnu_cxx5__ops15_Iter_less_iterclINS_17__normal_iteratorIPNSt6thread2idESt6vectorIS5_N3ozz12StdAllocatorIS5_EEEEESC_EEbT_T0_]+0x37): undefined reference to `std::operator<(std::thread::id, std::thread::id)'
/usr/bin/ld: CMakeFiles/sample_multithread.dir/sample_multithread.cc.o: in function `bool __gnu_cxx::__ops::_Val_less_iter::operator()<std::thread::id, __gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > > >(std::thread::id&, __gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > >) const':
sample_multithread.cc:(.text._ZNK9__gnu_cxx5__ops14_Val_less_iterclINSt6thread2idENS_17__normal_iteratorIPS4_St6vectorIS4_N3ozz12StdAllocatorIS4_EEEEEEEbRT_T0_[_ZNK9__gnu_cxx5__ops14_Val_less_iterclINSt6thread2idENS_17__normal_iteratorIPS4_St6vectorIS4_N3ozz12StdAllocatorIS4_EEEEEEEbRT_T0_]+0x2b): undefined reference to `std::operator<(std::thread::id, std::thread::id)'
/usr/bin/ld: CMakeFiles/sample_multithread.dir/sample_multithread.cc.o: in function `bool __gnu_cxx::__ops::_Iter_less_val::operator()<__gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > >, std::thread::id>(__gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > >, std::thread::id&) const':
sample_multithread.cc:(.text._ZNK9__gnu_cxx5__ops14_Iter_less_valclINS_17__normal_iteratorIPNSt6thread2idESt6vectorIS5_N3ozz12StdAllocatorIS5_EEEEES5_EEbT_RT0_[_ZNK9__gnu_cxx5__ops14_Iter_less_valclINS_17__normal_iteratorIPNSt6thread2idESt6vectorIS5_N3ozz12StdAllocatorIS5_EEEEES5_EEbT_RT0_]+0x2b): undefined reference to `std::operator<(std::thread::id, std::thread::id)'
SnapperTT commented 3 years ago

A second solution to the first problem:

Turn instances of: int dummy;

Into int dummy; fakeAssignUninitialised(dummy); With fakeAssignUninitialised defined as: void fakeAssignUninitialised(int&a){}

guillaumeblanc commented 3 years ago

Hi, thanks for reporting these issues.

The first one has a fix from google test: https://github.com/google/googletest/pull/3024

For the second one, seems that std::thread::id operators are removed from c++20: https://en.cppreference.com/w/cpp/thread/thread/id. Are you compiling with c++20? What's your compiler version? The solution is to use a std::thread::id hash in this case I think.

Guillaume

SnapperTT commented 3 years ago

Cheers, the google fix is better than mine

I'm compiling with gcc 11.1.0, using -std=c++11. I have also tried -std=c++17.

(Aside: If I'm not mistaken the < operator should be automagically generated from the <=> operater in c++20, no?)

Output of make VERBOSE=1:

[ 45%] Linking CXX executable sample_multithread
cd /home/twigger/turf2/extlib/ozzAnimation/build/samples/multithread && /usr/bin/cmake -E cmake_link_script CMakeFiles/sample_multithread.dir/link.txt --verbose=1
/usr/bin/g++ -std=c++11 -rdynamic CMakeFiles/sample_multithread.dir/sample_multithread.cc.o -o sample_multithread  ../framework/libsample_framework.a -lpthread ../framework/glfw/libglfw.a /usr/lib/libGL.so /usr/lib/libGLU.so /usr/lib/libSM.so /usr/lib/libICE.so /usr/lib/libX11.so /usr/lib/libXext.so ../../src/geometry/runtime/libozz_geometry.a ../../src/animation/offline/libozz_animation_offline.a ../../src/animation/runtime/libozz_animation.a ../../src/base/libozz_base.a ../../src/options/libozz_options.a 
/usr/bin/ld: CMakeFiles/sample_multithread.dir/sample_multithread.cc.o: in function `bool __gnu_cxx::__ops::_Iter_less_iter::operator()<__gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > >, __gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > > >(__gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > >, __gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > >) const':
sample_multithread.cc:(.text._ZNK9__gnu_cxx5__ops15_Iter_less_iterclINS_17__normal_iteratorIPNSt6thread2idESt6vectorIS5_N3ozz12StdAllocatorIS5_EEEEESC_EEbT_T0_[_ZNK9__gnu_cxx5__ops15_Iter_less_iterclINS_17__normal_iteratorIPNSt6thread2idESt6vectorIS5_N3ozz12StdAllocatorIS5_EEEEESC_EEbT_T0_]+0x37): undefined reference to `std::operator<(std::thread::id, std::thread::id)'
/usr/bin/ld: CMakeFiles/sample_multithread.dir/sample_multithread.cc.o: in function `bool __gnu_cxx::__ops::_Val_less_iter::operator()<std::thread::id, __gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > > >(std::thread::id&, __gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > >) const':
sample_multithread.cc:(.text._ZNK9__gnu_cxx5__ops14_Val_less_iterclINSt6thread2idENS_17__normal_iteratorIPS4_St6vectorIS4_N3ozz12StdAllocatorIS4_EEEEEEEbRT_T0_[_ZNK9__gnu_cxx5__ops14_Val_less_iterclINSt6thread2idENS_17__normal_iteratorIPS4_St6vectorIS4_N3ozz12StdAllocatorIS4_EEEEEEEbRT_T0_]+0x2b): undefined reference to `std::operator<(std::thread::id, std::thread::id)'
/usr/bin/ld: CMakeFiles/sample_multithread.dir/sample_multithread.cc.o: in function `bool __gnu_cxx::__ops::_Iter_less_val::operator()<__gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > >, std::thread::id>(__gnu_cxx::__normal_iterator<std::thread::id*, std::vector<std::thread::id, ozz::StdAllocator<std::thread::id> > >, std::thread::id&) const':
sample_multithread.cc:(.text._ZNK9__gnu_cxx5__ops14_Iter_less_valclINS_17__normal_iteratorIPNSt6thread2idESt6vectorIS5_N3ozz12StdAllocatorIS5_EEEEES5_EEbT_RT0_[_ZNK9__gnu_cxx5__ops14_Iter_less_valclINS_17__normal_iteratorIPNSt6thread2idESt6vectorIS5_N3ozz12StdAllocatorIS5_EEEEES5_EEbT_RT0_]+0x2b): undefined reference to `std::operator<(std::thread::id, std::thread::id)'
collect2: error: ld returned 1 exit status
make[2]: *** [samples/multithread/CMakeFiles/sample_multithread.dir/build.make:125: samples/multithread/sample_multithread] Error 1
guillaumeblanc commented 3 years ago

Indeed <=> shall do the job. Maybe a mismatch in gcc stl then. Anyway, hashing is a valid and portable solution I think.

guillaumeblanc commented 3 years ago

Fixes are merged to develop/. Thanks for reporting the issues.