commit: 4c4b0e35bfcc8fca87af3686ada058bdfe1a143a Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Wed Dec 10 17:42:01 2025 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Wed Dec 10 17:42:18 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4c4b0e35
games-strategy/colobot: Fix building with gcc-15 Closes: https://bugs.gentoo.org/938227 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> games-strategy/colobot/colobot-0.2.2_alpha.ebuild | 6 +++ .../colobot/files/colobot-0.2.2_alpha-gcc15.patch | 45 ++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/games-strategy/colobot/colobot-0.2.2_alpha.ebuild b/games-strategy/colobot/colobot-0.2.2_alpha.ebuild index 27aacd807de2..037b985000b0 100644 --- a/games-strategy/colobot/colobot-0.2.2_alpha.ebuild +++ b/games-strategy/colobot/colobot-0.2.2_alpha.ebuild @@ -50,6 +50,12 @@ DEPEND+=" " src_prepare() { + local PATCHES=( + # https://bugs.gentoo.org/938227 + # https://github.com/colobot/colobot/commit/1561854b03500d39955c66971c9c98de1937d7e6 + "${FILESDIR}/${P}-gcc15.patch" + ) + cmake_src_prepare # https://bugs.gentoo.org/963468 diff --git a/games-strategy/colobot/files/colobot-0.2.2_alpha-gcc15.patch b/games-strategy/colobot/files/colobot-0.2.2_alpha-gcc15.patch new file mode 100644 index 000000000000..08b271840267 --- /dev/null +++ b/games-strategy/colobot/files/colobot-0.2.2_alpha-gcc15.patch @@ -0,0 +1,45 @@ +From 1561854b03500d39955c66971c9c98de1937d7e6 Mon Sep 17 00:00:00 2001 +From: suve <[email protected]> +Date: Thu, 16 Jan 2025 16:33:33 +0100 +Subject: [PATCH] Check if SDL_main is in use +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The main() function of colobot-app is declared as extern "C" to prevent +name mangling. This is required because on some platforms, SDL2 declares +its own main() function and defines a macro that renames the user's main +to SDL_main; in which case, name mangling may cause linking failures. + +However, when building for platforms where this is not the case, +gcc15 complains that specifying linkage for main is not allowed. +> error: cannot declare ‘::main’ with a linkage +> specification [-Wpedantic] + +This commit wraps the extern block in #ifdefs that check +if the main -> SDL_main macro is in use. +--- a/src/app/main.cpp ++++ b/src/app/main.cpp +@@ -94,10 +94,14 @@ The current layout is the following: + - src/script - link with the CBot library + */ + +-//! Entry point to the program ++// On *some* platforms, SDL declares a macro which renames main to SDL_main. ++// If that's the case, use "extern C" to prevent name mangling. ++#ifdef main + extern "C" + { ++#endif + ++//! Entry point to the program + int main(int argc, char *argv[]) + { + CLogger logger; // single instance of logger +@@ -176,4 +180,6 @@ int main(int argc, char *argv[]) + return code; + } + ++#ifdef main + } // extern "C" ++#endif
