Get rid of static gl_hidden_globals* glGlob = &glGlobalData;

Post Reply
Dwedit
Posts: 43
Joined: Sun Jan 06, 2008 4:06 am

Get rid of static gl_hidden_globals* glGlob = &glGlobalData;

Post by Dwedit » Tue Mar 03, 2009 12:34 am

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)

WinterMute
Site Admin
Posts: 1861
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Get rid of static gl_hidden_globals* glGlob = &glGlobalData;

Post by WinterMute » Wed Mar 11, 2009 2:21 pm

This is not executable code, nor does it cause the symptoms you describe.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Dwedit
Posts: 43
Joined: Sun Jan 06, 2008 4:06 am

Re: Get rid of static gl_hidden_globals* glGlob = &glGlobalData;

Post by Dwedit » Mon Mar 16, 2009 7:58 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests