Tracktion / tracktion_engine

Tracktion Engine module
Other
1.16k stars 148 forks source link

provide fix for rpallocator for newer compilers/stdlibs #120

Closed stonepreston closed 2 years ago

stonepreston commented 2 years ago

Currently the engine is unable to be built using newer compilers/stdlibs such as GCC 11.2.0 and clang 14 (which are what is available in the newest LTS of Ubuntu 22.04). The compiler error is listed below:

home/stone/development/tracktion_engine/modules/tracktion_graph/utilities/tracktion_Allocation.test.cpp:161:54:   required from here
/usr/include/c++/11/bits/stl_vector.h:1483:9: error: no match for ‘operator==’ (operand types are ‘std::_Vector_base<int, rpallocator<int> >::_Tp_alloc_type’ {aka ‘std::allocator_traits<rpallocator<int> >::rebind_alloc<int>’} and ‘std::_Vector_base<int, rpallocator<int> >::_Tp_alloc_type’ {aka ‘std::allocator_traits<rpallocator<int> >::rebind_alloc<int>’})
 1483 |         __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value

The fix for this is to define operators for == and !=. The docs have this to say about ==

true only if the storage allocated by the allocator a1 can be deallocated through a2. Establishes reflexive, symmetric, and transitive relationship. Does not throw exceptions.

I have returned true for == in this PR, but i dont know enough about these allocators to say whether or not storage allocated by one can be deallocated by another. Hopefully you can provide some guidance as to what the desired behavior is for the allocator.

The fix does work, and I can confirm the engine compiles on GCC 11.2.0 and clang 14

drowaudio commented 2 years ago

Thanks for the fix! Yes I think true is correct in this case as rpallocator is a singleton so should be able to handle the allocations between different types (and it works on raw pointers). https://github.com/Tracktion/tracktion_engine/commit/edd6fb6b0e23aad25463ee2425d8ec9c9d38d918

github-actions[bot] commented 2 years ago

Unit Test Results

       3 files  ±0         3 suites  ±0   0s :stopwatch: ±0s    152 tests ±0     152 :heavy_check_mark: ±0  0 :zzz: ±0  0 :x: ±0  5 778 runs  ±0  5 778 :heavy_check_mark: ±0  0 :zzz: ±0  0 :x: ±0 

Results for commit edd6fb6b. ± Comparison against base commit 48e837ae.

github-actions[bot] commented 2 years ago

Performance Test Results

0 files  ±0  0 suites  ±0   0s :stopwatch: ±0s 0 tests ±0  0 :heavy_check_mark: ±0  0 :zzz: ±0  0 :x: ±0 

Results for commit edd6fb6b. ± Comparison against base commit 48e837ae.