gentoo-ebuilds/sci-libs/gdal/files/gdal-3.11.3-java-no-strict-aliasing.patch
Alfred Wingate e2e0bbbc68
sci-libs/gdal: add 3.11.3
* muparser enabled by default as recommended by upstream.
* headless java fixed upstream.
* Remove automagic and add new use flags.
* Correctly use mysql-connector-c instead of virtual/mysql
* Build shapelib support unconditionally with the internal
implementation (external implementation discouraged upstream).
* Use PEP517 backend for python bindings.

Bug: https://bugs.gentoo.org/666056
Bug: https://bugs.gentoo.org/926500
Bug: https://bugs.gentoo.org/935567
Bug: https://bugs.gentoo.org/938364
Bug: https://bugs.gentoo.org/959583
Closes: https://bugs.gentoo.org/957887
Signed-off-by: Alfred Wingate <parona@protonmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/43244
Signed-off-by: Sam James <sam@gentoo.org>
2025-07-31 08:11:38 +01:00

38 lines
1.5 KiB
Diff

https://bugs.gentoo.org/948810
https://github.com/OSGeo/gdal/pull/12773
https://github.com/OSGeo/gdal/commit/66f9bf01cfcb58499f69df2670a3ec9d7b77ad5a
From 66f9bf01cfcb58499f69df2670a3ec9d7b77ad5a Mon Sep 17 00:00:00 2001
From: Alfred Wingate <parona@protonmail.com>
Date: Tue, 22 Jul 2025 17:04:59 +0300
Subject: [PATCH] CMake Java: restore -fno-strict-aliasing
This was dropped with the move to cmake.
But swig still struggles with this in java.
> If you are going to use optimisations turned on with gcc (for example -O2),
> ensure you also compile with -fno-strict-aliasing. The GCC optimisations have
> become more aggressive from gcc-4.0 onwards and will result in code that fails
> with strict aliasing optimisations turned on.
Bug: https://bugs.gentoo.org/948810
See-Also: cd39be5322d5731ae6327b1cec1e54015ab6bc1e
See-Also: 211263036085ddb44663137d359e3d99fee77bd7
--- a/swig/java/CMakeLists.txt
+++ b/swig/java/CMakeLists.txt
@@ -5,6 +5,14 @@ if (CMAKE_CXX_FLAGS)
string(REPLACE "/WX " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ")
endif ()
+# Do not remove -fno-strict-aliasing while SWIG generates weird code in upcast methods
+# http://trac.osgeo.org/gdal/changeset/16006
+#
+# https://swig.org//Doc4.3/Java.html#Java_compiling_dynamic
+if (NOT MSVC)
+ add_compile_options("-fno-strict-aliasing")
+endif()
+
list(APPEND GDAL_SWIG_COMMON_INTERFACE_FILES
${PROJECT_SOURCE_DIR}/swig/include/java/callback.i
${PROJECT_SOURCE_DIR}/swig/include/java/gdalconst_java.i