[tlbuild] small portability patches for graphite and dvisvgm (static const declaration inside C++ class scope)

Vladimir Volovich vvv at vsu.ru
Fri Jun 4 17:46:38 CEST 2010


Hi Peter and Jonathan,

there were the following link errors on AIX:

==============================

1) in graphite, when linking regression-test

xlC -O2 -qmaxmem=262144 -qarch=com -qlanglvl=extended -DNDEBUG -DTRACING -O3 -DNDEBUG -o regression-test stdafx.o RegressionTest.o TestCase.o SimpleTextSrc.o GrJustifier.o  -L/usr/local/vvv/src/source/Work/libs/graphite-engine/src /usr/local/vvv/src/source/Work/libs/graphite-engine/src/.libs/libgraphite.a  
[... some warnings about duplicate symbols skipped ...]
ld: 0711-317 ERROR: Undefined symbol: TestCase::kAbsent
ld: 0711-317 ERROR: Undefined symbol: TestCase::ClickTest::fieldCnt

(this error is from last year build, but graphite sources didn't change
in this area)

2) in dvisvgm:

libtool: link: xlC -O2 -qmaxmem=262144 -qarch=com -qlanglvl=extended -o dvisvgm dvisvgm.o gzstream.o  libdvisvgm.a libpotrace.a /usr/local/vvv/src/source/Work/texk/kpathsea/.libs/libkpathsea.a /usr/local/vvv/src/source/Work/libs/freetype2/libfreetype.a /usr/local/vvv/src/source/Work/libs/zlib/libz.a -lm
[... some warnings about duplicate symbols skipped ...]
ld: 0711-317 ERROR: Undefined symbol: gzstreambuf::bufferSize
ld: 0711-317 ERROR: Undefined symbol: FontCache::VERSION
gmake[3]: *** [dvisvgm] Error 8

==============================

these errors are caused by some "static const" declarations made inside the class definitions:

libs/graphite/engine-2.3.1/test/RegressionTest/TestCase.h:
    const static int kAbsent = -100;	// not present in data
    const static int fieldCnt = 10;

texk/dvisvgm/dvisvgm-0.8.7/src/gzstream.h:
    static const int bufferSize = 47+256;    // size of data buff
texk/dvisvgm/dvisvgm-0.8.7/src/FontCache.h:
    const static UInt8 VERSION = 3;

http://publib.boulder.ibm.com/infocenter/zos/v1r9/topic/com.ibm.zos.r9.cbcdg01/cbcdg15021.htm#ks18087
has the following explanation why these errors are happening:

==============================

CCN6127

  Only static data members with const integral or const enumeration
  type can specify an initializer in the class definition.

Explanation:

  The declaration of a static data member is not a definition. The
  definition should appear in a namespace scope enclosing the class
  that contains this member. Only static data members of const
  integral or const enumeration type may be initialized inside the
  class declaration. In this case, they must still be defined in the
  enclosing scope without an initializer.

User response:

  Move the initializer to the definition in the containing scope, or
  make the type a const integral or const enumeration.

==============================

following this advice ("In this case, they must still be defined in the
enclosing scope without an initializer."), i've added declarations of
these constants in the enclosing scope:

the patches do the following:

add to libs/graphite/engine-2.3.1/test/RegressionTest/TestCase.cpp:
const int ClickTest::fieldCnt;

add to libs/graphite/engine-2.3.1/test/RegressionTest/RegressionTest.cpp:
const int TestCase::kAbsent;

add to texk/dvisvgm/dvisvgm-0.8.7/src/FontCache.cpp:
const UInt8 FontCache::VERSION;

add to texk/dvisvgm/dvisvgm-0.8.7/src/gzstream.cpp:
const int gzstreambuf::bufferSize;

they seem to be harmless for other patforms, and possibly even "strictly
correct" (i.e. there's no error on other platforms because their
compilers are more forgiving than xlC - i'm not 100% sure about this).

Best,
v.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graphite1.diff
Type: text/x-diff
Size: 679 bytes
Desc: not available
URL: <http://tug.org/pipermail/tlbuild/attachments/20100604/a2fd1f2e/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dvisvgm1.diff
Type: text/x-diff
Size: 932 bytes
Desc: not available
URL: <http://tug.org/pipermail/tlbuild/attachments/20100604/a2fd1f2e/attachment-0001.bin>


More information about the tlbuild mailing list