maplibre / maplibre-native

MapLibre Native - Interactive vector tile maps for iOS, Android and other platforms.
https://maplibre.org
BSD 2-Clause "Simplified" License
1.07k stars 315 forks source link

Fails to build with GCC 13 #872

Closed Vogtinator closed 1 year ago

Vogtinator commented 1 year ago

It fails to build with GCC 13 mostly due to missing includes.

To reproduce:

/data/git/maplibre-gl-native/build> cmake -D CMAKE_CXX_COMPILER=g++-13 -D CMAKE_C_COMPILER=gcc-13 -DMBGL_WITH_CORE_ONLY=OFF ..
/data/git/maplibre-gl-native/build> make -j8
...

I fixed some of them:

diff --git a/include/mbgl/i18n/number_format.hpp b/include/mbgl/i18n/number_format.hpp
index cb1e94c7b..dceddfe96 100644
--- a/include/mbgl/i18n/number_format.hpp
+++ b/include/mbgl/i18n/number_format.hpp
@@ -1,5 +1,6 @@
 #pragma once

+#include <cstdint>
 #include <string>

 namespace mbgl {
diff --git a/include/mbgl/util/geometry.hpp b/include/mbgl/util/geometry.hpp
index c4fe52e87..5fc9c59e7 100644
--- a/include/mbgl/util/geometry.hpp
+++ b/include/mbgl/util/geometry.hpp
@@ -1,5 +1,7 @@
 #pragma once

+#include <cstdint>
+
 #include <mapbox/geometry/geometry.hpp>
 #include <mapbox/geometry/point_arithmetic.hpp>
 #include <mapbox/geometry/for_each_point.hpp>
diff --git a/include/mbgl/util/string.hpp b/include/mbgl/util/string.hpp
index df205b907..370b08afa 100644
--- a/include/mbgl/util/string.hpp
+++ b/include/mbgl/util/string.hpp
@@ -1,6 +1,7 @@
 #pragma once

 #include <string>
+#include <cstdint>
 #include <cstdlib>
 #include <type_traits>
 #include <exception>
diff --git a/src/mbgl/programs/gl/shaders.hpp b/src/mbgl/programs/gl/shaders.hpp
index 46a87f4af..25a1e6cb5 100644
--- a/src/mbgl/programs/gl/shaders.hpp
+++ b/src/mbgl/programs/gl/shaders.hpp
@@ -1,5 +1,6 @@
 #pragma once

+#include <cstdint>
 #include <string>

 namespace mbgl {

But I'm stuck at a different issue now:

[ 73%] Building CXX object test/CMakeFiles/mbgl-test.dir/algorithm/update_tile_masks.test.cpp.o
In file included from /data/git/maplibre-gl-native/include/mbgl/actor/actor.hpp:3,
                 from /data/git/maplibre-gl-native/test/actor/actor_ref.test.cpp:1:
In member function ‘Object& mbgl::AspiringActor<Object>::object() [with Object = ActorRef_AskOnDestroyedActor_Test::TestBody()::TestActorRef]’,
    inlined from ‘mbgl::ActorRef<typename std::decay<_Tp>::type> mbgl::AspiringActor<Object>::self() [with Object = ActorRef_AskOnDestroyedActor_Test::TestBody()::TestActorRef]’ at /data/git/maplibre-gl-native/include/mbgl/actor/aspiring_actor.hpp:45:64,
    inlined from ‘mbgl::ActorRef<typename std::decay<_Tp>::type> mbgl::Actor<Object>::self() [with Object = ActorRef_AskOnDestroyedActor_Test::TestBody()::TestActorRef]’ at /data/git/maplibre-gl-native/include/mbgl/actor/actor.hpp:65:28,
    inlined from ‘virtual void ActorRef_AskOnDestroyedActor_Test::TestBody()’ at /data/git/maplibre-gl-native/test/actor/actor_ref.test.cpp:97:46:
/data/git/maplibre-gl-native/include/mbgl/actor/aspiring_actor.hpp:53:58: error: pointer may be used after ‘void operator delete(void*, std::size_t)’ [-Werror=use-after-free]
   53 |         return *reinterpret_cast<Object *>(&objectStorage);
      |                                                          ^
In file included from /usr/include/c++/13/memory:78,
                 from /data/git/maplibre-gl-native/include/mbgl/actor/mailbox.hpp:6,
                 from /data/git/maplibre-gl-native/include/mbgl/actor/aspiring_actor.hpp:3:
In member function ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = mbgl::Actor<ActorRef_AskOnDestroyedActor_Test::TestBody()::TestActorRef>]’,
    inlined from ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = mbgl::Actor<ActorRef_AskOnDestroyedActor_Test::TestBody()::TestActorRef>]’ at /usr/include/c++/13/bits/unique_ptr.h:94:7,
    inlined from ‘void std::__uniq_ptr_impl<_Tp, _Dp>::reset(pointer) [with _Tp = mbgl::Actor<ActorRef_AskOnDestroyedActor_Test::TestBody()::TestActorRef>; _Dp = std::default_delete<mbgl::Actor<ActorRef_AskOnDestroyedActor_Test::TestBody()::TestActorRef> >]’ at /usr/include/c++/13/bits/unique_ptr.h:212:16,
    inlined from ‘void std::unique_ptr<_Tp, _Dp>::reset(pointer) [with _Tp = mbgl::Actor<ActorRef_AskOnDestroyedActor_Test::TestBody()::TestActorRef>; _Dp = std::default_delete<mbgl::Actor<ActorRef_AskOnDestroyedActor_Test::TestBody()::TestActorRef> >]’ at /usr/include/c++/13/bits/unique_ptr.h:510:12,
    inlined from ‘virtual void ActorRef_AskOnDestroyedActor_Test::TestBody()’ at /data/git/maplibre-gl-native/test/actor/actor_ref.test.cpp:99:16:
/usr/include/c++/13/bits/unique_ptr.h:100:9: note: call to ‘void operator delete(void*, std::size_t)’ here
  100 |         delete __ptr;
      |         ^~~~~~~~~~~~
cc1plus: all warnings being treated as errors
louwers commented 1 year ago

Duplicate of #852

Vogtinator commented 1 year ago

Not fully a duplicate. GCC 13 has more errors on top of the GCC 12 failures.

louwers commented 1 year ago

Yes. 🙂

@Vogtinator Would you be willing to make a PR for the other issue you found and solved?

Vogtinator commented 1 year ago

Yep, once I got it all built locally.

Vogtinator commented 1 year ago

With #874 and the actor ref test commented out, I can successfully build it with cmake -D CMAKE_CXX_COMPILER=g++-13 -D CMAKE_C_COMPILER=gcc-13 -DMBGL_WITH_CORE_ONLY=OFF -DMBGL_WITH_QT=ON -DMBGL_WITH_EGL=ON ...

louwers commented 1 year ago

Thanks for your contribution. I will look into #852