neuromancer / avp

Aliens vs Predator Linux enhanced with cutscene support and new screen resolutions
Other
42 stars 7 forks source link

Failed to compile with GCC 10 #7

Open runlevel5 opened 4 years ago

runlevel5 commented 4 years ago
$ gcc --version
gcc (GCC) 10.2.1 20200723 (Red Hat 10.2.1-1)

$ make -j128
/usr/bin/ld: CMakeFiles/avp.dir/src/opengl.c.o:(.bss+0x1703c): multiple definition of `WaterFallBase'; CMakeFiles/avp.dir/src/stubs.c.o:(.bss+0x10): first defined here
collect2: error: ld returned 1 exit status

GCC 10 now enforces:

GCC now defaults to -fno-common. As a result, global variable accesses are more efficient on various targets. In C, global variables with multiple tentative definitions now result in linker errors. With -fcommon such definitions are silently merged during linking.

Example on how to address this GCC10 issue: https://github.com/rednex/rgbds/pull/504

cc @neuromancer

runlevel5 commented 4 years ago
diff --git a/src/opengl.h b/src/opengl.h
index c5262be..cdbfb6d 100644
--- a/src/opengl.h
+++ b/src/opengl.h
@@ -14,6 +14,8 @@
 #define OPENGL_COLOR0_ATTRIB_BITINDEX (1 << OPENGL_COLOR0_ATTRIB_INDEX)
 #define OPENGL_COLOR1_ATTRIB_BITINDEX (1 << OPENGL_COLOR1_ATTRIB_INDEX)

+extern int WaterFallBase;
+
 enum AVP_SHADER_PROGRAM {
        AVP_SHADER_PROGRAM_DEFAULT,
        AVP_SHADER_PROGRAM_NO_SECONDARY,
diff --git a/src/stubs.c b/src/stubs.c
index 714fd7f..0ebc338 100644
--- a/src/stubs.c
+++ b/src/stubs.c
@@ -109,7 +109,6 @@ void ReloadImageIntoD3DImmediateSurface(IMAGEHEADER* iheader)
 int NumberOfLandscapePolygons;
 int FMVParticleColour;
 int WireFrameMode;
-int WaterFallBase;

 void InitDrawTest()
 {
frostworx commented 4 years ago

thx for the small patch, I can confirm it fixes the glitch. also pinged https://aur.archlinux.org/packages/avp/ as icculus upstream has the same problem.