2020-08-06 08:22 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0006412Spring engineAIpublic2020-07-25 17:59
Reporteresainane 
Assigned ToKloot 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version104.0 +git 
Target VersionFixed in Version 
Summary0006412: CircuitAI does not build with C++17: C++17 requires comparator for std::map to be const
DescriptionBuilding Spring fails partway through a build at:

[ 45%] Building CXX object AI/Skirmish/CppTestAI/CMakeFiles/CppTestAI.dir/src/AIExport.cpp.o


Proposed fix to the AI/Skirmish/CircuitAI submodule, which resolves the issue:

$ git diff
diff --git a/src/circuit/util/Defines.h b/src/circuit/util/Defines.h
index f060ac7f..294212a1 100644
--- a/src/circuit/util/Defines.h
+++ b/src/circuit/util/Defines.h
@@ -50,7 +50,7 @@ template<typename T> static inline constexpr T SQUARE(T x) { return x * x; }
 typedef std::vector<springai::AIFloat3> F3Vec;
 
 struct cmp_str {
- bool operator()(char const* a, char const* b) {
+ bool operator()(char const* a, char const* b) const {
                return strcmp(a, b) < 0;
        }
 };

Will make PR with this later, unless someone else gets there first.
Steps To ReproduceFrom the root of a spring repository:

git reset --hard e1f249fcc # maintenance+1544
mkdir build-circuit-test
cd build-circuit-test
cmake -DCMAKE_BUILD_TYPE=Release -DAI_TYPES=ALL ..
make -j 12 # Get to the failing point quickly
VERBOSE=1 make # Grab the failing command


Verify that this is the failing command:

cd $REPO/build-circuit-test/AI/Skirmish/CircuitAI && /usr/lib/ccache/c++ -DASIO_STANDALONE -DBUILDING_AI -DBUILDING_SKIRMISH_AI -DCircuitAI_EXPORTS -DSPRING_DATADIR=\"/usr/local/share/games/spring\" -DSYNCCHECK -DTHREADPOOL -DUSE_LIBSQUISH -DUSE_VALGRIND -D_GLIBCXX_USE_NANOSLEEP -D_GNU_SOURCE=1 -D_RANDOM_TCC -D_REENTRANT -I$REPO/AI/Skirmish/CircuitAI/src/circuit -I$REPO/AI/Skirmish/CircuitAI/src/lib -I/usr/include/SDL2 -I$REPO/build-circuit-test/AI/Wrappers/Cpp/src-generated -I$REPO/AI/Wrappers/Cpp/src -I$REPO/rts -I$REPO/build-circuit-test/src-generated/engine -I$REPO/rts/ExternalAI/Interface -I$REPO/AI/Wrappers -fuse-ld=gold -std=c++17 -fdiagnostics-color=auto -mtune=generic -msse -mfpmath=sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -mno-sse4 -mno-sse4a -mno-avx -mno-fma -mno-fma4 -mno-xop -mno-lwp -mno-avx2 -fsingle-precision-constant -frounding-math -mieee-fp -pipe -fno-strict-aliasing -fvisibility=hidden -fvisibility-inlines-hidden -pthread -O2 -Wformat -Wformat-security -DNDEBUG -fPIC -fpic -Wall -o CMakeFiles/CircuitAI.dir/src/AIExport.cpp.o -c $REPO/AI/Skirmish/CircuitAI/src/AIExport.cpp
In file included from /usr/include/c++/8/map:60,
                 from $REPO/build-circuit-test/AI/Wrappers/Cpp/src-generated/IncludesHeaders.h:10,
                 from $REPO/build-circuit-test/AI/Wrappers/Cpp/src-generated/OOAICallback.h:10,
                 from $REPO/AI/Skirmish/CircuitAI/src/AIExport.cpp:7:
/usr/include/c++/8/bits/stl_tree.h: In instantiation of ‘class std::_Rb_tree<const char*, std::pair<const char* const, circuit::CCircuitDef*>, std::_Select1st<std::pair<const char* const, circuit::CCircuitDef*> >, cmp_str, std::allocator<std::pair<const char* const, circuit::CCircuitDef*> > >’:
/usr/include/c++/8/bits/stl_map.h:151:17: required from ‘class std::map<const char*, circuit::CCircuitDef*, cmp_str>’
$REPO/AI/Skirmish/CircuitAI/src/circuit/CircuitAI.h:211:12: required from here
/usr/include/c++/8/bits/stl_tree.h:457:21: error: static assertion failed: comparison object must be invocable as const
       static_assert(is_invocable_v<const _Compare&, const _Key&, const _Key&>,
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
✘ 1 ➭$


Verify that removing --std=c++17 is sufficient to fix the command:

cd $REPO/build-circuit-test/AI/Skirmish/CircuitAI && /usr/lib/ccache/c++ -DASIO_STANDALONE -DBUILDING_AI -DBUILDING_SKIRMISH_AI -DCircuitAI_EXPORTS -DSPRING_DATADIR=\"/usr/local/share/games/spring\" -DSYNCCHECK -DTHREADPOOL -DUSE_LIBSQUISH -DUSE_VALGRIND -D_GLIBCXX_USE_NANOSLEEP -D_GNU_SOURCE=1 -D_RANDOM_TCC -D_REENTRANT -I$REPO/AI/Skirmish/CircuitAI/src/circuit -I$REPO/AI/Skirmish/CircuitAI/src/lib -I/usr/include/SDL2 -I$REPO/build-circuit-test/AI/Wrappers/Cpp/src-generated -I$REPO/AI/Wrappers/Cpp/src -I$REPO/rts -I$REPO/build-circuit-test/src-generated/engine -I$REPO/rts/ExternalAI/Interface -I$REPO/AI/Wrappers -fuse-ld=gold -fdiagnostics-color=auto -mtune=generic -msse -mfpmath=sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -mno-sse4 -mno-sse4a -mno-avx -mno-fma -mno-fma4 -mno-xop -mno-lwp -mno-avx2 -fsingle-precision-constant -frounding-math -mieee-fp -pipe -fno-strict-aliasing -fvisibility=hidden -fvisibility-inlines-hidden -pthread -O2 -Wformat -Wformat-security -DNDEBUG -fPIC -fpic -Wall -o CMakeFiles/CircuitAI.dir/src/AIExport.cpp.o -c $REPO/AI/Skirmish/CircuitAI/src/AIExport.cpp
✔ 0 ➭$
Additional Information$ uname -a
Linux sybil 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 GNU/Linux

$ gcc --version
gcc (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 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.

$ dpkg -l 'libc-bin:amd64' 'libstdc++6:amd64'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-================-============-============-=================================
ii libc-bin 2.28-10 amd64 GNU C Library: Binaries
ii libstdc++6:amd64 8.3.0-6 amd64 GNU Standard C++ Library v3
TagsNo tags attached.
Checked infolog.txt for ErrorsIrrelevant
Attached Files

-Relationships
+Relationships

-Notes

~0020491

ThinkSome (reporter)

Is this the same issue?

In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include/g++-v9/map:60,
                 from /tmp/portage/games-strategy/spring-104.0.1_p1544/work/spring-104.0.1_p1544_build/AI/Wrappers/Cpp/src-generated/IncludesHeaders.h:10,
                 from /tmp/portage/games-strategy/spring-104.0.1_p1544/work/spring-104.0.1_p1544_build/AI/Wrappers/Cpp/src-generated/Unit.h:10,
                 from /tmp/portage/games-strategy/spring-104.0.1_p1544/work/spring-104.0.1_p1544/AI/Skirmish/CircuitAI/src/circuit/unit/CoreUnit.h:11, from /tmp/portage/games-strategy/spring-104.0.1_p1544/work/spring-104.0.1_p1544/AI/Skirmish/CircuitAI/src/circuit/unit/AllyUnit.h:11, from /tmp/portage/games-strategy/spring-104.0.1_p1544/work/spring-104.0.1_p1544/AI/Skirmish/CircuitAI/src/circuit/unit/AllyTeam.h:11, from /tmp/portage/games-strategy/spring-104.0.1_p1544/work/spring-104.0.1_p1544/AI/Skirmish/CircuitAI/src/circuit/CircuitAI.h:11,
                 from /tmp/portage/games-strategy/spring-104.0.1_p1544/work/spring-104.0.1_p1544/AI/Skirmish/CircuitAI/src/circuit/CircuitAI.cpp:8:
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include/g++-v9/bits/stl_tree.h: In instantiation of 'static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type) [with _Key = const char*; _Val = std::pair<const char* const, circuit::CCircuitDef*>; _KeyOfValue = std::_Select1st<std::pair<const char* const, circuit::CCircuitDef*> >; _Compare = cmp_str; _Alloc = std::allocator<std::pair<const char* const, circuit::CCircuitDef*> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<std::pair<const char* const, circuit::CCircuitDef*> >*]':
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include/g++-v9/bits/stl_tree.h:2459:62: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_
Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_hint_unique(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator, _Args&& ...) [with _Args = {const std::piecewise_construct_t&, std::tuple<const char*&&>, std::tuple<>}; _Key = const char*; _Val = std::pair<const char* const, circuit::CCircuitDef*>; _KeyOfValue = std::_Select1st<std::pair<const char* const, circuit::CCircuitDef*> >; _Compare = cmp_str; _Alloc = std::allocator<std::pair<const char* const, circuit::CCircuitDef*> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const char* const, circuit::CCircuitDef*> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>
::const_iterator = std::_Rb_tree_const_iterator<std::pair<const char* const, circuit::CCircuitDef*> >]'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include/g++-v9/bits/stl_map.h:518:8: required from 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = const char*; _Tp = circuit::CCircuitDef*; _Compare = cmp_str; _Alloc = std::allocator<std::pair<const char* const, circuit::CCircuitDef*> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = circuit::CCircuitDef*; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = const char*]'
/tmp/portage/games-strategy/spring-104.0.1_p1544/work/spring-104.0.1_p1544/AI/Skirmish/CircuitAI/src/circuit/CircuitAI.cpp:1415:27: required from here
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include/g++-v9/bits/stl_tree.h:780:8: error: static assertion failed: comparison object must be invocable as const 780 | is_invocable_v<const _Compare&, const _Key&, const _Key&>, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~0020492

lamer (reporter)

most likely the same.
Thanks, PR: https://github.com/spring/CircuitAI/pull/16
+Notes

-Issue History
Date Modified Username Field Change
2020-07-23 10:31 esainane New Issue
2020-07-24 13:27 ThinkSome Note Added: 0020491
2020-07-24 15:37 lamer Note Added: 0020492
2020-07-25 17:59 hokomoko Assigned To => Kloot
2020-07-25 17:59 hokomoko Status new => resolved
2020-07-25 17:59 hokomoko Resolution open => fixed
+Issue History