commit:     4dadfc6e58f9c4176b84b36992103b9cb5ba7f5d
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 27 16:00:21 2022 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed Jul 27 16:00:26 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4dadfc6e

media-libs/freeglut: Fix build with -Werror=lto-type-mismatch

Closes: https://bugs.gentoo.org/859847
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 .../files/3.2.2-Fix-aliasing-violation.patch       | 65 ++++++++++++++++++++++
 media-libs/freeglut/freeglut-3.2.2.ebuild          |  4 ++
 2 files changed, 69 insertions(+)

diff --git a/media-libs/freeglut/files/3.2.2-Fix-aliasing-violation.patch 
b/media-libs/freeglut/files/3.2.2-Fix-aliasing-violation.patch
new file mode 100644
index 000000000000..d6544578bcf1
--- /dev/null
+++ b/media-libs/freeglut/files/3.2.2-Fix-aliasing-violation.patch
@@ -0,0 +1,65 @@
+https://bugs.gentoo.org/859847
+
+From 8c6f6bf3ad2fd33d15de6ee96175cd29bf804d9f Mon Sep 17 00:00:00 2001
+From: Matt Turner <matts...@gmail.com>
+Date: Tue, 26 Jul 2022 15:47:02 -0400
+Subject: [PATCH] Fix aliasing violation
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Noticed when compiling with link-time optimizations.
+
+include/GL/freeglut_std.h:240:18: error: type of ‘glutBitmapHelvetica18’ does 
not match original declaration [-Werror=lto-type-mismatch]
+  240 |     extern void* glutBitmapHelvetica18;
+      |                  ^
+src/x11/fg_glutfont_definitions_x11.c:103:27: note: ‘glutBitmapHelvetica18’ 
was previously declared here
+  103 | struct freeglutBitmapFont glutBitmapHelvetica18 ;
+      |                           ^
+src/x11/fg_glutfont_definitions_x11.c:103:27: note: code may be misoptimized 
unless ‘-fno-strict-aliasing’ is used
+---
+ src/x11/fg_glutfont_definitions_x11.c | 29 ++++++++++++++++++---------
+ 1 file changed, 20 insertions(+), 9 deletions(-)
+
+diff --git a/src/x11/fg_glutfont_definitions_x11.c 
b/src/x11/fg_glutfont_definitions_x11.c
+index bec20371..d086a990 100644
+--- a/src/x11/fg_glutfont_definitions_x11.c
++++ b/src/x11/fg_glutfont_definitions_x11.c
+@@ -91,14 +91,25 @@ struct freeglutBitmapFont
+ };
+ 
+ 
+-struct freeglutStrokeFont glutStrokeRoman ;
+-struct freeglutStrokeFont glutStrokeMonoRoman ;
++static struct freeglutStrokeFont glutStrokeRoman_ ;
++static struct freeglutStrokeFont glutStrokeMonoRoman_ ;
+ 
+-struct freeglutBitmapFont glutBitmap9By15 ;
+-struct freeglutBitmapFont glutBitmap8By13 ;
+-struct freeglutBitmapFont glutBitmapTimesRoman10 ;
+-struct freeglutBitmapFont glutBitmapTimesRoman24 ;
+-struct freeglutBitmapFont glutBitmapHelvetica10 ;
+-struct freeglutBitmapFont glutBitmapHelvetica12 ;
+-struct freeglutBitmapFont glutBitmapHelvetica18 ;
++static struct freeglutBitmapFont glutBitmap9By15_ ;
++static struct freeglutBitmapFont glutBitmap8By13_ ;
++static struct freeglutBitmapFont glutBitmapTimesRoman10_ ;
++static struct freeglutBitmapFont glutBitmapTimesRoman24_ ;
++static struct freeglutBitmapFont glutBitmapHelvetica10_ ;
++static struct freeglutBitmapFont glutBitmapHelvetica12_ ;
++static struct freeglutBitmapFont glutBitmapHelvetica18_ ;
+ 
++
++void *glutStrokeRoman = &glutStrokeRoman_ ;
++void *glutStrokeMonoRoman = &glutStrokeMonoRoman_ ;
++
++void *glutBitmap9By15 = &glutBitmap9By15_ ;
++void *glutBitmap8By13 = &glutBitmap8By13_ ;
++void *glutBitmapTimesRoman10 = &glutBitmapTimesRoman10_ ;
++void *glutBitmapTimesRoman24 = &glutBitmapTimesRoman24_ ;
++void *glutBitmapHelvetica10 = &glutBitmapHelvetica10_ ;
++void *glutBitmapHelvetica12 = &glutBitmapHelvetica12_ ;
++void *glutBitmapHelvetica18 = &glutBitmapHelvetica18_ ;
+-- 
+2.35.1
+

diff --git a/media-libs/freeglut/freeglut-3.2.2.ebuild 
b/media-libs/freeglut/freeglut-3.2.2.ebuild
index d8fb60843cac..0a46c30d469d 100644
--- a/media-libs/freeglut/freeglut-3.2.2.ebuild
+++ b/media-libs/freeglut/freeglut-3.2.2.ebuild
@@ -28,6 +28,10 @@ DEPEND="${RDEPEND}
        x11-base/xorg-proto"
 BDEPEND="virtual/pkgconfig"
 
+PATCHES=(
+       "${FILESDIR}"/${PV}-Fix-aliasing-violation.patch
+)
+
 src_configure() {
        local mycmakeargs=(
 #              "-DOpenGL_GL_PREFERENCE=GLVND" # bug 721006

Reply via email to