Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building fails with GCC 10 #162

Open
OldShatterham opened this issue May 18, 2020 · 5 comments
Open

Building fails with GCC 10 #162

OldShatterham opened this issue May 18, 2020 · 5 comments

Comments

@OldShatterham
Copy link

Building on Arch Linux with GCC 10.1.0 fails due to compiler and linker errors.

Following the compilation instructions from README.md, ninja produces the following output before failing:
gcc10_build.log

I was able to fix some of these errors by including missing libraries in the corresponding files:

  • <stdexcept> in glfft_wisdom.cpp
  • <cstdio> and <cerrno> in glfft_gl_interface.hpp
  • <cstdio> in glfft_gl_interface.cpp

Even then, building fails due to linker errors:

/usr/bin/ld: glava@sha/glava_xwin.c.o: in function `glava_abort':
xwin.c:(.text+0xf0): multiple definition of `glava_abort'; glava@sha/glava_glava.c.o:glava.c:(.text+0x0): first defined here
/usr/bin/ld: glava@sha/glava_xwin.c.o: in function `glava_return':
xwin.c:(.text+0x100): multiple definition of `glava_return'; glava@sha/glava_glava.c.o:glava.c:(.text+0x10): first defined here
/usr/bin/ld: glava@sha/glava_glx_wcb.c.o: in function `glava_abort':
glx_wcb.c:(.text+0x830): multiple definition of `glava_abort'; glava@sha/glava_glava.c.o:glava.c:(.text+0x0): first defined here
/usr/bin/ld: glava@sha/glava_glx_wcb.c.o: in function `glava_return':
glx_wcb.c:(.text+0x1340): multiple definition of `glava_return'; glava@sha/glava_glava.c.o:glava.c:(.text+0x10): first defined here
/usr/bin/ld: glava@sha/glava_render.c.o: in function `glava_abort':
render.c:(.text+0x10e0): multiple definition of `glava_abort'; glava@sha/glava_glava.c.o:glava.c:(.text+0x0): first defined here
/usr/bin/ld: glava@sha/glava_render.c.o: in function `glava_return':
render.c:(.text+0x2510): multiple definition of `glava_return'; glava@sha/glava_glava.c.o:glava.c:(.text+0x10): first defined here
/usr/bin/ld: glava@sha/glava_glsl_ext.c.o: in function `glava_abort':
glsl_ext.c:(.text+0x80): multiple definition of `glava_abort'; glava@sha/glava_glava.c.o:glava.c:(.text+0x0): first defined here
/usr/bin/ld: glava@sha/glava_glsl_ext.c.o: in function `glava_return':
glsl_ext.c:(.text+0x1b0): multiple definition of `glava_return'; glava@sha/glava_glava.c.o:glava.c:(.text+0x10): first defined here

None of these errors occured when building with GCC 9.3.0 or when using gcc-8 by manually editing build.ninja.

@LunarLambda
Copy link

Same problem here, no idea what the fix is, aside from downgrading compilers.

@sniff122
Copy link

Im having this issue with ubuntu 20.10, not sure what to set in build.ninja to make it use gcc-8 though

@jwakely
Copy link

jwakely commented Dec 10, 2021

See the changes for -fno-common in the GCC 10 release notes and Porting to GCC 10 page.

@jwakely
Copy link

jwakely commented Dec 10, 2021

The problem is due to all the global variables defined in the glava.h header. Those get defined in every .c file that includes the header, and you get multiple definitions. That's not valid C.

The header should declare them as extern variables, and then there should be a non-extern definition in exactly one .c file.

Or the definitions in the header can be decorated with __attribute__((__common__)) so that multiple definitions are allowed, or just compile everything with -fcommon to use the same behaviour as gcc-9 and earlier (but it will be slightly slower to access those variables).

It's better to just fix the code to be correct C.

@jwakely
Copy link

jwakely commented Dec 10, 2021

There's already a pull request to fix this, somebody just needs to merge it: #185

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants