logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git

freeglut-3.2.1-gcc10-fno-common.patch (3500B)


  1. From 5791564dd934d193df771a0a7c52013e9f456aa1 Mon Sep 17 00:00:00 2001
  2. From: Sergei Trofimovich <slyfox@gentoo.org>
  3. Date: Tue, 21 Jan 2020 22:33:49 +0000
  4. Subject: [PATCH] fg_gl2: fix build failure against gcc-10
  5. On gcc-10 (and gcc-9 -fno-common) build fails as:
  6. ```
  7. [ 31%] Linking C executable bin/Lorenz_static
  8. /usr/bin/cmake -E cmake_link_script CMakeFiles/Lorenz_static.dir/link.txt --verbose=1
  9. /usr/lib/ccache/bin/cc -Wall -pedantic -rdynamic CMakeFiles/Lorenz_static.dir/progs/demos/Lorenz/lorenz.c.o \
  10. -o bin/Lorenz_static -lGLU -lGL -lm -lX11 -lXrandr -lXxf86vm -lXi -lm lib/libglut.a -lGL -lm -lX11 -lXrandr -lXxf86vm -lXi
  11. ld: lib/libglut.a(fg_gl2.c.o):(.bss+0x0):
  12. multiple definition of `fghGenBuffers'; lib/libglut.a(fg_window.c.o):(.bss+0x0): first defined here
  13. ld: lib/libglut.a(fg_gl2.c.o):(.bss+0x8):
  14. multiple definition of `fghDeleteBuffers'; lib/libglut.a(fg_window.c.o):(.bss+0x8): first defined here
  15. ```
  16. Note: duplicate definition comes here from 'fg_gl2.h'.
  17. The fix is to move declaration to a 'fg_gl2.c' file.
  18. gcc-10 will change the default from -fcommon to fno-common:
  19. https://gcc.gnu.org/PR85678.
  20. The error also happens if CFLAGS=-fno-common passed explicitly.
  21. Bug: https://bugs.gentoo.org/705840
  22. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
  23. ---
  24. src/fg_gl2.c | 12 ++++++++++++
  25. src/fg_gl2.h | 14 +++++++-------
  26. 2 files changed, 19 insertions(+), 7 deletions(-)
  27. diff --git a/freeglut/freeglut/src/fg_gl2.c b/freeglut/freeglut/src/fg_gl2.c
  28. index 38b0acbb..f79c432a 100644
  29. --- a/src/fg_gl2.c
  30. +++ b/src/fg_gl2.c
  31. @@ -27,6 +27,18 @@
  32. #include "fg_internal.h"
  33. #include "fg_gl2.h"
  34. +#ifdef GL_ES_VERSION_2_0
  35. +/* Use existing functions on GLES 2.0 */
  36. +#else
  37. +FGH_PFNGLGENBUFFERSPROC fghGenBuffers;
  38. +FGH_PFNGLDELETEBUFFERSPROC fghDeleteBuffers;
  39. +FGH_PFNGLBINDBUFFERPROC fghBindBuffer;
  40. +FGH_PFNGLBUFFERDATAPROC fghBufferData;
  41. +FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray;
  42. +FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray;
  43. +FGH_PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer;
  44. +#endif
  45. +
  46. void FGAPIENTRY glutSetVertexAttribCoord3(GLint attrib) {
  47. if (fgStructure.CurrentWindow != NULL)
  48. fgStructure.CurrentWindow->Window.attribute_v_coord = attrib;
  49. diff --git a/freeglut/freeglut/src/fg_gl2.h b/freeglut/freeglut/src/fg_gl2.h
  50. index ab8ba5c7..fb3d4676 100644
  51. --- a/src/fg_gl2.h
  52. +++ b/src/fg_gl2.h
  53. @@ -67,13 +67,13 @@ typedef void (APIENTRY *FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
  54. typedef void (APIENTRY *FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint);
  55. typedef void (APIENTRY *FGH_PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
  56. -FGH_PFNGLGENBUFFERSPROC fghGenBuffers;
  57. -FGH_PFNGLDELETEBUFFERSPROC fghDeleteBuffers;
  58. -FGH_PFNGLBINDBUFFERPROC fghBindBuffer;
  59. -FGH_PFNGLBUFFERDATAPROC fghBufferData;
  60. -FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray;
  61. -FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray;
  62. -FGH_PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer;
  63. +extern FGH_PFNGLGENBUFFERSPROC fghGenBuffers;
  64. +extern FGH_PFNGLDELETEBUFFERSPROC fghDeleteBuffers;
  65. +extern FGH_PFNGLBINDBUFFERPROC fghBindBuffer;
  66. +extern FGH_PFNGLBUFFERDATAPROC fghBufferData;
  67. +extern FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray;
  68. +extern FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray;
  69. +extern FGH_PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer;
  70. # endif