Fri 21 Jul 2017 08:34:24 PM UTC, comment #4:
I forgot to follow-up on this at the time and just noticed that the problem still exists, so I looked at the patch (6fb549ddab976e9b1993c6f14fdcee07d3397016). Unfortunately it is incorrect. The crucial diff is here:
- static const unsigned char ft_adobe_glyph_list[55997L] =
+#ifndef DEFINE_PS_TABLES
+#ifdef __cplusplus
+ extern "C"
+#else
+ extern
+#endif
+#endif
+ const unsigned char ft_adobe_glyph_list[55997L]
+#ifdef DEFINE_PS_TABLES
+ =
What this means is that if DEFINE_PS_TABLES is defined then we get:
const char ft_adobe_glyph_list[3696]
= {
....
and if it isn't defined then we get:
const char ft_adobe_glyph_list[3696];
What this means is that we end up with two arrays, one of which is initialized and the other one which isn't. This is because 'const' implies static and you need to override it with "extern" to avoid that.
The diff that we want is this:
- static const char ft_adobe_glyph_list[3696] =
+#ifdef __cplusplus
+ extern "C"
+#else
+ extern
+#endif
+ const char ft_adobe_glyph_list[3696]
+#ifdef DEFINE_PS_TABLES
+ =
so that we unconditionally get extern or extern "C". That gives us:
extern "C" const char ft_adobe_glyph_list[3696]
= {
....
and:
extern "C" const char ft_adobe_glyph_list[3696];
The first one defines the array and gives it external linkage (const defaults to internal linkage). The second one declares the array instead of defining it. It's frustrating subtle, but this is the necessary magic.
The other problem is that DEFINE_PS_TABLES controls initialization of the ft_adobe_glyph_list array (and others) and generation of the ft_get_adobe_glyph_index function. The goal should be to give access to ft_get_adobe_glyph_index to all, while only defining (initializing) the arrays once. I think that a separate define, perhaps DEFINE_PS_TABLES_DATA, is needed to control whether or not the arrays are defined (and filled with data) or just declared (along with the function). I have a possible patch available. It shrinks chrome_child.dll's data segment by 67,200 bytes.
|