aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo <thinkabit.ukim@gmail.com>2020-12-13 06:02:17 -0300
committerLeo <thinkabit.ukim@gmail.com>2020-12-13 06:02:17 -0300
commit19f3b0a42f1ecd92b7894126d4d7d926b217e335 (patch)
tree4fc3e62f2d8c25fd6baf1276cb497f6b11e01245
parent38f20fccdc6384eb7acf9756568ac2200b27ad3d (diff)
community/freeglut: fix build with -fno-common
-rw-r--r--community/freeglut/APKBUILD7
-rw-r--r--community/freeglut/gcc-10.patch81
2 files changed, 86 insertions, 2 deletions
diff --git a/community/freeglut/APKBUILD b/community/freeglut/APKBUILD
index 36e29f08b70..af4e3991564 100644
--- a/community/freeglut/APKBUILD
+++ b/community/freeglut/APKBUILD
@@ -11,7 +11,9 @@ license="MIT"
depends_dev="mesa-dev libx11-dev libice-dev libxxf86vm-dev libxi-dev glu-dev"
makedepends="$depends_dev cmake"
subpackages="$pkgname-dev"
-source="https://downloads.sourceforge.net/freeglut/freeglut-$pkgver.tar.gz"
+source="https://downloads.sourceforge.net/freeglut/freeglut-$pkgver.tar.gz
+ gcc-10.patch
+ "
build() {
cmake . \
@@ -29,4 +31,5 @@ package() {
ln -s glut.pc "$pkgdir"/usr/lib/pkgconfig/freeglut.pc
}
-sha512sums="aced4bbcd36269ce6f4ee1982e0f9e3fffbf18c94f785d3215ac9f4809b992e166c7ada496ed6174e13d77c0f7ef3ca4c57d8a282e96cbbe6ff086339ade3b08 freeglut-3.2.1.tar.gz"
+sha512sums="aced4bbcd36269ce6f4ee1982e0f9e3fffbf18c94f785d3215ac9f4809b992e166c7ada496ed6174e13d77c0f7ef3ca4c57d8a282e96cbbe6ff086339ade3b08 freeglut-3.2.1.tar.gz
+0845bc4c91c6233cab8c56d15d1efa8fcdac7ae12270a089f8dd20520fc5c94078b7abceadef304f8f42cd575a61ad5b1f444f21e0bbdd3ff310bcc40192336b gcc-10.patch"
diff --git a/community/freeglut/gcc-10.patch b/community/freeglut/gcc-10.patch
new file mode 100644
index 00000000000..655c01bf94b
--- /dev/null
+++ b/community/freeglut/gcc-10.patch
@@ -0,0 +1,81 @@
+From 5791564dd934d193df771a0a7c52013e9f456aa1 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Tue, 21 Jan 2020 22:33:49 +0000
+Subject: [PATCH] fg_gl2: fix build failure against gcc-10
+
+On gcc-10 (and gcc-9 -fno-common) build fails as:
+
+```
+[ 31%] Linking C executable bin/Lorenz_static
+/usr/bin/cmake -E cmake_link_script CMakeFiles/Lorenz_static.dir/link.txt --verbose=1
+/usr/lib/ccache/bin/cc -Wall -pedantic -rdynamic CMakeFiles/Lorenz_static.dir/progs/demos/Lorenz/lorenz.c.o \
+ -o bin/Lorenz_static -lGLU -lGL -lm -lX11 -lXrandr -lXxf86vm -lXi -lm lib/libglut.a -lGL -lm -lX11 -lXrandr -lXxf86vm -lXi
+ld: lib/libglut.a(fg_gl2.c.o):(.bss+0x0):
+ multiple definition of `fghGenBuffers'; lib/libglut.a(fg_window.c.o):(.bss+0x0): first defined here
+ld: lib/libglut.a(fg_gl2.c.o):(.bss+0x8):
+ multiple definition of `fghDeleteBuffers'; lib/libglut.a(fg_window.c.o):(.bss+0x8): first defined here
+```
+
+Note: duplicate definition comes here from 'fg_gl2.h'.
+The fix is to move declaration to a 'fg_gl2.c' file.
+
+gcc-10 will change the default from -fcommon to fno-common:
+https://gcc.gnu.org/PR85678.
+
+The error also happens if CFLAGS=-fno-common passed explicitly.
+
+Bug: https://bugs.gentoo.org/705840
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+---
+ src/fg_gl2.c | 12 ++++++++++++
+ src/fg_gl2.h | 14 +++++++-------
+ 2 files changed, 19 insertions(+), 7 deletions(-)
+
+diff --git a/freeglut/freeglut/src/fg_gl2.c b/freeglut/freeglut/src/fg_gl2.c
+index 38b0acbb..f79c432a 100644
+--- a/src/fg_gl2.c
++++ b/src/fg_gl2.c
+@@ -27,6 +27,18 @@
+ #include "fg_internal.h"
+ #include "fg_gl2.h"
+
++#ifdef GL_ES_VERSION_2_0
++/* Use existing functions on GLES 2.0 */
++#else
++FGH_PFNGLGENBUFFERSPROC fghGenBuffers;
++FGH_PFNGLDELETEBUFFERSPROC fghDeleteBuffers;
++FGH_PFNGLBINDBUFFERPROC fghBindBuffer;
++FGH_PFNGLBUFFERDATAPROC fghBufferData;
++FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray;
++FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray;
++FGH_PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer;
++#endif
++
+ void FGAPIENTRY glutSetVertexAttribCoord3(GLint attrib) {
+ if (fgStructure.CurrentWindow != NULL)
+ fgStructure.CurrentWindow->Window.attribute_v_coord = attrib;
+diff --git a/freeglut/freeglut/src/fg_gl2.h b/freeglut/freeglut/src/fg_gl2.h
+index ab8ba5c7..fb3d4676 100644
+--- a/src/fg_gl2.h
++++ b/src/fg_gl2.h
+@@ -67,13 +67,13 @@ typedef void (APIENTRY *FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
+ typedef void (APIENTRY *FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint);
+ typedef void (APIENTRY *FGH_PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+
+-FGH_PFNGLGENBUFFERSPROC fghGenBuffers;
+-FGH_PFNGLDELETEBUFFERSPROC fghDeleteBuffers;
+-FGH_PFNGLBINDBUFFERPROC fghBindBuffer;
+-FGH_PFNGLBUFFERDATAPROC fghBufferData;
+-FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray;
+-FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray;
+-FGH_PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer;
++extern FGH_PFNGLGENBUFFERSPROC fghGenBuffers;
++extern FGH_PFNGLDELETEBUFFERSPROC fghDeleteBuffers;
++extern FGH_PFNGLBINDBUFFERPROC fghBindBuffer;
++extern FGH_PFNGLBUFFERDATAPROC fghBufferData;
++extern FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray;
++extern FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray;
++extern FGH_PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer;
+
+ # endif
+