From a6158ac3f6cd9e8dda97217cf8d18ec568142f33 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 27 Jan 2012 15:02:45 +0000 Subject: [PATCH] Fix building with GCC 4.6 link-time optimization. It looks like GCC doesn't honor the 'used' attribute with LTO. This is "fixed" by declaring the variables in question with external linkage (i.e. removing the 'static'). I consider such behavior a GCC bug, though. git-svn-id: https://svn.eduke32.com/eduke32@2286 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/build.h | 9 ++++++++- polymer/eduke32/build/src/engine.c | 9 ++++++++- polymer/eduke32/build/src/kplib.c | 16 +++++++++++++--- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index a3b131149..d8e57652e 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -372,7 +372,14 @@ EXTERN char show2dwall[(MAXWALLS+7)>>3]; EXTERN char show2dsprite[(MAXSPRITES+7)>>3]; //EXTERN char automapping; -EXTERN char gotpic[(MAXTILES+7)>>3]; +// GCC 4.6 LTO build fix +#ifdef USING_LTO +# define B_ATTRIBUTE_USED ATTRIBUTE((used)) +#else +# define B_ATTRIBUTE_USED +#endif + +EXTERN char B_ATTRIBUTE_USED gotpic[(MAXTILES+7)>>3]; EXTERN char gotsector[(MAXSECTORS+7)>>3]; EXTERN char editorcolors[256]; diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index ca886305d..dadb05591 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -141,8 +141,15 @@ static int32_t artsize = 0, cachesize = 0; // maximum number of ART files static char *artptrs[MAXTILEFILES]; +// GCC 4.6 LTO build fix +#ifdef USING_LTO +# define B_ENGINE_STATIC +#else +# define B_ENGINE_STATIC static +#endif + static int16_t radarang2[MAXXDIM]; -static uint16_t ATTRIBUTE((used)) sqrtable[4096], ATTRIBUTE((used)) shlookup[4096+256]; +B_ENGINE_STATIC uint16_t ATTRIBUTE((used)) sqrtable[4096], ATTRIBUTE((used)) shlookup[4096+256]; char pow2char[8] = {1,2,4,8,16,32,64,128}; int32_t pow2long[32] = { diff --git a/polymer/eduke32/build/src/kplib.c b/polymer/eduke32/build/src/kplib.c index 54f212c1b..7146ac83f 100644 --- a/polymer/eduke32/build/src/kplib.c +++ b/polymer/eduke32/build/src/kplib.c @@ -169,18 +169,28 @@ int8_t coltype, filtype, bitdepth; // * 16-bit color depth // * Some useless ancillary chunks, like: gAMA(gamma) & pHYs(aspect ratio) +// GCC 4.6 LTO build fix +#ifdef USING_LTO +# define B_KPLIB_STATIC +#else +# define B_KPLIB_STATIC static +#endif + //.PNG specific variables: static int32_t bakr = 0x80, bakg = 0x80, bakb = 0x80; //this used to be public... static int32_t gslidew = 0, gslider = 0, xm, xmn[4], xr0, xr1, xplc, yplc; static intptr_t nfplace; static int32_t clen[320], cclen[19], bitpos, filt, xsiz, ysiz; -static int32_t xsizbpl, ixsiz, ixoff, iyoff, ixstp, iystp, intlac, nbpl, ATTRIBUTE((used)) trnsrgb ASMNAME("trnsrgb"); +int32_t xsizbpl, ixsiz, ixoff, iyoff, ixstp, iystp, intlac, nbpl; +B_KPLIB_STATIC int32_t ATTRIBUTE((used)) trnsrgb ASMNAME("trnsrgb"); static int32_t ccind[19] = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; static int32_t hxbit[59][2], ibuf0[288], nbuf0[32], ibuf1[32], nbuf1[32]; static const uint8_t *filptr; static uint8_t slidebuf[32768], opixbuf0[4], opixbuf1[4]; -static uint8_t pnginited = 0, olinbuf[131072] ASMNAME("olinbuf"); //WARNING:max xres is: 131072/bpp-1 -static int32_t gotcmov = -2, ATTRIBUTE((used)) abstab10[1024] ASMNAME("abstab10"); +static uint8_t pnginited = 0; +B_KPLIB_STATIC uint8_t olinbuf[131072] ASMNAME("olinbuf"); //WARNING:max xres is: 131072/bpp-1 +static int32_t gotcmov = -2; +B_KPLIB_STATIC int32_t ATTRIBUTE((used)) abstab10[1024] ASMNAME("abstab10"); //Variables to speed up dynamic Huffman decoding: #define LOGQHUFSIZ0 9