Page 1 of 1
Get rid of static gl_hidden_globals* glGlob = &glGlobalData;
Posted: Tue Mar 03, 2009 12:34 am
by Dwedit
Please get rid of this declaration from videogl.h:
static gl_hidden_globals* glGlob = &glGlobalData;
This is executable code in a header file, which forces the linker to include videogl.a no matter what.
I recommend you replace it with:
#define glGlob (&glGlobalData)
Re: Get rid of static gl_hidden_globals* glGlob = &glGlobalData;
Posted: Wed Mar 11, 2009 2:21 pm
by WinterMute
This is not executable code, nor does it cause the symptoms you describe.
Re: Get rid of static gl_hidden_globals* glGlob = &glGlobalData;
Posted: Mon Mar 16, 2009 7:58 pm
by Dwedit
Okay...
I am using the source code for the FCS2 DLDI driver, and I'm building it. It doesn't use any of libnds's functions, but includes nds.h anyway, probably so it can have the data types and memory region names.
Inside the ASM code generated are these lines:
Code: Select all
.section .data.rel,"aw",%progbits
.align 2
.type glGlob, %object
.size glGlob, 4
glGlob:
.word glGlobalData
glGlob or glGlobalData are never referenced anywhere else in the generated asm code.
The linker fails to link the binary unless libnds is linked in because glGlobalData is missing. If it is given libnds as a library, it includes all of videogl.a.
This is only here because of the line "static gl_hidden_globals* glGlob = &glGlobalData;" inside videogl.h. Replacing it with "#define glGlob (&glGlobalData)" eliminates the problem.
EDIT: It appears to be entirely related to using optimization level -O0. I have no idea what possessed the author of the FCS2 DLDI driver to use such an optimization level. The problem goes away at -O1, -O2, -Os.