Skip to content

Commit

Permalink
mir_2_15: Fix GCC 14 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
OPNA2608 committed Dec 27, 2024
1 parent cc38f61 commit 0e5a17a
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
From d31d3abb36163b0f0a892898349d6a99aaf50e10 Mon Sep 17 00:00:00 2001
From: OPNA2608 <[email protected]>
Date: Thu, 26 Dec 2024 23:12:39 +0100
Subject: [PATCH] Fix ignored return value of std::lock_guard

Upstream this seems to have been resolved as part of the big platform API change, so manually rewrote this change into a patch.
---
src/platforms/wayland/displayclient.cpp | 2 +-
src/server/frontend_xwayland/xcb_connection.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/platforms/wayland/displayclient.cpp b/src/platforms/wayland/displayclient.cpp
index 27bdfe5..987be52 100644
--- a/src/platforms/wayland/displayclient.cpp
+++ b/src/platforms/wayland/displayclient.cpp
@@ -563,7 +563,7 @@ void mgw::DisplayClient::on_display_config_changed()

void mgw::DisplayClient::delete_outputs_to_be_deleted()
{
- std::lock_guard{outputs_mutex};
+ std::lock_guard lock{outputs_mutex};
outputs_to_be_deleted.clear();
}

diff --git a/src/server/frontend_xwayland/xcb_connection.cpp b/src/server/frontend_xwayland/xcb_connection.cpp
index 4f72b98..0be74b0 100644
--- a/src/server/frontend_xwayland/xcb_connection.cpp
+++ b/src/server/frontend_xwayland/xcb_connection.cpp
@@ -207,7 +207,7 @@ void mf::XCBConnection::verify_not_in_error_state() const

auto mf::XCBConnection::query_name(xcb_atom_t atom) const -> std::string
{
- std::lock_guard{atom_name_cache_mutex};
+ std::lock_guard lock{atom_name_cache_mutex};
auto const iter = atom_name_cache.find(atom);

if (iter == atom_name_cache.end())
--
2.47.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
From ab00b6d09303c17ecc7a2131a95591716e9ad7a1 Mon Sep 17 00:00:00 2001
From: Jonathan Wakely <[email protected]>
Date: Thu, 26 Dec 2024 23:00:23 +0100
Subject: [PATCH] Add missing includes for <algorithm>

Co-authored-by: OPNA2608 <[email protected]>
---
src/miral/external_client.cpp | 1 +
src/miral/keymap.cpp | 1 +
src/platform/graphics/linux_dmabuf.cpp | 1 +
src/server/scene/rendering_tracker.cpp | 1 +
tests/unit-tests/graphics/test_overlapping_output_grouping.cpp | 1 +
5 files changed, 5 insertions(+)

diff --git a/src/miral/external_client.cpp b/src/miral/external_client.cpp
index 0c3d176..792b962 100644
--- a/src/miral/external_client.cpp
+++ b/src/miral/external_client.cpp
@@ -22,6 +22,7 @@
#include <mir/options/option.h>
#include <mir/server.h>

+#include <algorithm>
#include <stdexcept>

namespace mo = mir::options;
diff --git a/src/miral/keymap.cpp b/src/miral/keymap.cpp
index e494a10..010cb75 100644
--- a/src/miral/keymap.cpp
+++ b/src/miral/keymap.cpp
@@ -30,6 +30,7 @@
#define MIR_LOG_COMPONENT "miral::Keymap"
#include <mir/log.h>

+#include <algorithm>
#include <mutex>
#include <string>
#include <vector>
diff --git a/src/platform/graphics/linux_dmabuf.cpp b/src/platform/graphics/linux_dmabuf.cpp
index f5a750f..840c3d0 100644
--- a/src/platform/graphics/linux_dmabuf.cpp
+++ b/src/platform/graphics/linux_dmabuf.cpp
@@ -41,6 +41,7 @@
#include <mutex>
#include <vector>
#include <optional>
+#include <algorithm>
#include <drm_fourcc.h>
#include <wayland-server.h>

diff --git a/src/server/scene/rendering_tracker.cpp b/src/server/scene/rendering_tracker.cpp
index fe4e05e..24393a3 100644
--- a/src/server/scene/rendering_tracker.cpp
+++ b/src/server/scene/rendering_tracker.cpp
@@ -17,6 +17,7 @@
#include "rendering_tracker.h"
#include "mir/scene/surface.h"

+#include <algorithm>
#include <stdexcept>
#include <boost/throw_exception.hpp>

diff --git a/tests/unit-tests/graphics/test_overlapping_output_grouping.cpp b/tests/unit-tests/graphics/test_overlapping_output_grouping.cpp
index 4478578..7167ad1 100644
--- a/tests/unit-tests/graphics/test_overlapping_output_grouping.cpp
+++ b/tests/unit-tests/graphics/test_overlapping_output_grouping.cpp
@@ -22,6 +22,7 @@
#include <gtest/gtest.h>

#include <vector>
+#include <algorithm>

namespace mg = mir::graphics;
namespace geom = mir::geometry;
--
2.47.0

35 changes: 35 additions & 0 deletions pkgs/servers/mir/1003-mir-2_15-calloc-args-in-right-order.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From 2b3fa53f0115d73d1d515f8c839fc481ba5db46d Mon Sep 17 00:00:00 2001
From: Alan Griffiths <[email protected]>
Date: Thu, 26 Dec 2024 23:21:12 +0100
Subject: [PATCH] calloc args in right order

Co-authored-by: OPNA2608 <[email protected]>
---
examples/client/wayland_client.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/client/wayland_client.c b/examples/client/wayland_client.c
index a52b04c..e644a44 100644
--- a/examples/client/wayland_client.c
+++ b/examples/client/wayland_client.c
@@ -375,7 +375,7 @@ int main(int argc, char** argv)

struct wl_display* display = wl_display_connect(NULL);
struct globals* globals;
- globals = calloc(sizeof *globals, 1);
+ globals = calloc(1, sizeof *globals);

struct wl_registry* registry = wl_display_get_registry(display);

@@ -389,7 +389,7 @@ int main(int argc, char** argv)
void* pool_data = NULL;
struct wl_shm_pool* shm_pool = make_shm_pool(globals->shm, 400 * 400 * 4, &pool_data);

- struct draw_context* ctx = calloc(sizeof *ctx, 1);
+ struct draw_context* ctx = calloc(1, sizeof *ctx);

for (int i = 0; i < 4; ++i)
{
--
2.47.0

16 changes: 16 additions & 0 deletions pkgs/servers/mir/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ in
url = "https://github.com/canonical/mir/commit/0704026bd06372ea8286a46d8c939286dd8a8c68.patch";
hash = "sha256-k+51piPQandbHdm+ioqpBrb+C7Aqi2kugchAehZ1aiU=";
})

# Fix ignored return value of std::lock_guard
# Remove when version > 2.15.0
# Was changed as part of the big platform API change, no individual upstream commit with this fix
./1001-mir-2_15-Fix-ignored-return-value-of-std-lock_guard.patch

# Fix missing includes for methods from algorithm
# Remove when version > 2.16.4
# https://github.com/canonical/mir/pull/3191 backported to 2.15
./1002-mir-2_15-Add-missing-includes-for-algorithm.patch

# Fix order of calloc arguments
# Remove when version > 2.16.4
# Partially done in https://github.com/canonical/mir/pull/3192, though one of the calloc was fixed earlier
# when some code was moved into that file
./1003-mir-2_15-calloc-args-in-right-order.patch
];
};
}

0 comments on commit 0e5a17a

Please sign in to comment.