Skip to content

Commit 57986b9

Browse files
authored
wlcs,mir_2_15: Fix GCC 14 compat (NixOS#368425)
2 parents 7929bdc + 0e5a17a commit 57986b9

File tree

5 files changed

+181
-0
lines changed

5 files changed

+181
-0
lines changed

pkgs/by-name/wl/wlcs/package.nix

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
lib,
44
gitUpdater,
55
fetchFromGitHub,
6+
fetchpatch,
67
testers,
78
cmake,
89
pkg-config,
@@ -23,6 +24,15 @@ stdenv.mkDerivation (finalAttrs: {
2324
hash = "sha256-BQPRymkbGu4YvTYXTaTMuyP5fHpqMWI4xPwjDRHZNEQ=";
2425
};
2526

27+
patches = [
28+
# Remove when version > 1.7.0
29+
(fetchpatch {
30+
name = "0001-wlcs-Fix-GCC14-compat.patch";
31+
url = "https://github.com/canonical/wlcs/commit/5c812e560052e2cbff4c6d26439935020ddee52f.patch";
32+
hash = "sha256-8YrVKhgpTYZi8n4dZ4pRWJoAcZtr9eaFMv0NNV7/kWU=";
33+
})
34+
];
35+
2636
strictDeps = true;
2737

2838
nativeBuildInputs = [
@@ -38,6 +48,9 @@ stdenv.mkDerivation (finalAttrs: {
3848
wayland-scanner # needed by cmake
3949
];
4050

51+
# GCC14-exclusive maybe-uninitialized error at higher optimisation levels that looks weird
52+
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isGNU "-Wno-error=maybe-uninitialized";
53+
4154
passthru = {
4255
tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
4356
updateScript = gitUpdater {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
From d31d3abb36163b0f0a892898349d6a99aaf50e10 Mon Sep 17 00:00:00 2001
2+
From: OPNA2608 <[email protected]>
3+
Date: Thu, 26 Dec 2024 23:12:39 +0100
4+
Subject: [PATCH] Fix ignored return value of std::lock_guard
5+
6+
Upstream this seems to have been resolved as part of the big platform API change, so manually rewrote this change into a patch.
7+
---
8+
src/platforms/wayland/displayclient.cpp | 2 +-
9+
src/server/frontend_xwayland/xcb_connection.cpp | 2 +-
10+
2 files changed, 2 insertions(+), 2 deletions(-)
11+
12+
diff --git a/src/platforms/wayland/displayclient.cpp b/src/platforms/wayland/displayclient.cpp
13+
index 27bdfe5..987be52 100644
14+
--- a/src/platforms/wayland/displayclient.cpp
15+
+++ b/src/platforms/wayland/displayclient.cpp
16+
@@ -563,7 +563,7 @@ void mgw::DisplayClient::on_display_config_changed()
17+
18+
void mgw::DisplayClient::delete_outputs_to_be_deleted()
19+
{
20+
- std::lock_guard{outputs_mutex};
21+
+ std::lock_guard lock{outputs_mutex};
22+
outputs_to_be_deleted.clear();
23+
}
24+
25+
diff --git a/src/server/frontend_xwayland/xcb_connection.cpp b/src/server/frontend_xwayland/xcb_connection.cpp
26+
index 4f72b98..0be74b0 100644
27+
--- a/src/server/frontend_xwayland/xcb_connection.cpp
28+
+++ b/src/server/frontend_xwayland/xcb_connection.cpp
29+
@@ -207,7 +207,7 @@ void mf::XCBConnection::verify_not_in_error_state() const
30+
31+
auto mf::XCBConnection::query_name(xcb_atom_t atom) const -> std::string
32+
{
33+
- std::lock_guard{atom_name_cache_mutex};
34+
+ std::lock_guard lock{atom_name_cache_mutex};
35+
auto const iter = atom_name_cache.find(atom);
36+
37+
if (iter == atom_name_cache.end())
38+
--
39+
2.47.0
40+
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
From ab00b6d09303c17ecc7a2131a95591716e9ad7a1 Mon Sep 17 00:00:00 2001
2+
From: Jonathan Wakely <[email protected]>
3+
Date: Thu, 26 Dec 2024 23:00:23 +0100
4+
Subject: [PATCH] Add missing includes for <algorithm>
5+
6+
Co-authored-by: OPNA2608 <[email protected]>
7+
---
8+
src/miral/external_client.cpp | 1 +
9+
src/miral/keymap.cpp | 1 +
10+
src/platform/graphics/linux_dmabuf.cpp | 1 +
11+
src/server/scene/rendering_tracker.cpp | 1 +
12+
tests/unit-tests/graphics/test_overlapping_output_grouping.cpp | 1 +
13+
5 files changed, 5 insertions(+)
14+
15+
diff --git a/src/miral/external_client.cpp b/src/miral/external_client.cpp
16+
index 0c3d176..792b962 100644
17+
--- a/src/miral/external_client.cpp
18+
+++ b/src/miral/external_client.cpp
19+
@@ -22,6 +22,7 @@
20+
#include <mir/options/option.h>
21+
#include <mir/server.h>
22+
23+
+#include <algorithm>
24+
#include <stdexcept>
25+
26+
namespace mo = mir::options;
27+
diff --git a/src/miral/keymap.cpp b/src/miral/keymap.cpp
28+
index e494a10..010cb75 100644
29+
--- a/src/miral/keymap.cpp
30+
+++ b/src/miral/keymap.cpp
31+
@@ -30,6 +30,7 @@
32+
#define MIR_LOG_COMPONENT "miral::Keymap"
33+
#include <mir/log.h>
34+
35+
+#include <algorithm>
36+
#include <mutex>
37+
#include <string>
38+
#include <vector>
39+
diff --git a/src/platform/graphics/linux_dmabuf.cpp b/src/platform/graphics/linux_dmabuf.cpp
40+
index f5a750f..840c3d0 100644
41+
--- a/src/platform/graphics/linux_dmabuf.cpp
42+
+++ b/src/platform/graphics/linux_dmabuf.cpp
43+
@@ -41,6 +41,7 @@
44+
#include <mutex>
45+
#include <vector>
46+
#include <optional>
47+
+#include <algorithm>
48+
#include <drm_fourcc.h>
49+
#include <wayland-server.h>
50+
51+
diff --git a/src/server/scene/rendering_tracker.cpp b/src/server/scene/rendering_tracker.cpp
52+
index fe4e05e..24393a3 100644
53+
--- a/src/server/scene/rendering_tracker.cpp
54+
+++ b/src/server/scene/rendering_tracker.cpp
55+
@@ -17,6 +17,7 @@
56+
#include "rendering_tracker.h"
57+
#include "mir/scene/surface.h"
58+
59+
+#include <algorithm>
60+
#include <stdexcept>
61+
#include <boost/throw_exception.hpp>
62+
63+
diff --git a/tests/unit-tests/graphics/test_overlapping_output_grouping.cpp b/tests/unit-tests/graphics/test_overlapping_output_grouping.cpp
64+
index 4478578..7167ad1 100644
65+
--- a/tests/unit-tests/graphics/test_overlapping_output_grouping.cpp
66+
+++ b/tests/unit-tests/graphics/test_overlapping_output_grouping.cpp
67+
@@ -22,6 +22,7 @@
68+
#include <gtest/gtest.h>
69+
70+
#include <vector>
71+
+#include <algorithm>
72+
73+
namespace mg = mir::graphics;
74+
namespace geom = mir::geometry;
75+
--
76+
2.47.0
77+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
From 2b3fa53f0115d73d1d515f8c839fc481ba5db46d Mon Sep 17 00:00:00 2001
2+
From: Alan Griffiths <[email protected]>
3+
Date: Thu, 26 Dec 2024 23:21:12 +0100
4+
Subject: [PATCH] calloc args in right order
5+
6+
Co-authored-by: OPNA2608 <[email protected]>
7+
---
8+
examples/client/wayland_client.c | 4 ++--
9+
1 file changed, 2 insertions(+), 2 deletions(-)
10+
11+
diff --git a/examples/client/wayland_client.c b/examples/client/wayland_client.c
12+
index a52b04c..e644a44 100644
13+
--- a/examples/client/wayland_client.c
14+
+++ b/examples/client/wayland_client.c
15+
@@ -375,7 +375,7 @@ int main(int argc, char** argv)
16+
17+
struct wl_display* display = wl_display_connect(NULL);
18+
struct globals* globals;
19+
- globals = calloc(sizeof *globals, 1);
20+
+ globals = calloc(1, sizeof *globals);
21+
22+
struct wl_registry* registry = wl_display_get_registry(display);
23+
24+
@@ -389,7 +389,7 @@ int main(int argc, char** argv)
25+
void* pool_data = NULL;
26+
struct wl_shm_pool* shm_pool = make_shm_pool(globals->shm, 400 * 400 * 4, &pool_data);
27+
28+
- struct draw_context* ctx = calloc(sizeof *ctx, 1);
29+
+ struct draw_context* ctx = calloc(1, sizeof *ctx);
30+
31+
for (int i = 0; i < 4; ++i)
32+
{
33+
--
34+
2.47.0
35+

pkgs/servers/mir/default.nix

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ in
2828
url = "https://github.com/canonical/mir/commit/0704026bd06372ea8286a46d8c939286dd8a8c68.patch";
2929
hash = "sha256-k+51piPQandbHdm+ioqpBrb+C7Aqi2kugchAehZ1aiU=";
3030
})
31+
32+
# Fix ignored return value of std::lock_guard
33+
# Remove when version > 2.15.0
34+
# Was changed as part of the big platform API change, no individual upstream commit with this fix
35+
./1001-mir-2_15-Fix-ignored-return-value-of-std-lock_guard.patch
36+
37+
# Fix missing includes for methods from algorithm
38+
# Remove when version > 2.16.4
39+
# https://github.com/canonical/mir/pull/3191 backported to 2.15
40+
./1002-mir-2_15-Add-missing-includes-for-algorithm.patch
41+
42+
# Fix order of calloc arguments
43+
# Remove when version > 2.16.4
44+
# Partially done in https://github.com/canonical/mir/pull/3192, though one of the calloc was fixed earlier
45+
# when some code was moved into that file
46+
./1003-mir-2_15-calloc-args-in-right-order.patch
3147
];
3248
};
3349
}

0 commit comments

Comments
 (0)