Debian Codegraph @

README.solaris

raw
1 Special Notes for Sun Solaris
2 =============================
3
4 Recent versions of Solaris ship with a libintl that is mostly compatible
5 with GNU gettext. Even the plural handling functions (ngettext,
6 dngettext, dcngettext, ...) and output character conversion functions
7 (bind_textdomain_codeset) are included.
8
9 On my test system, the behavior of the Solaris version differs in one
10 important point from the pure Perl version or the GNU gettext version:
11 In a locale environment that is a regional variant of another locale
12 (for example "fr_CA" is a regional variant of "fr"), both the pure Perl
13 version from libintl-perl and the C version from GNU gettext will fall
14 back to translations for the superordinate message catalog ("fr") if
15 no special translation for the selected locale ("fr_CA") can be found.
16 This fallback mechanism is missing in the Solaris implementation.
17
18 This could be considered harmless, because Solaris users are probably
19 used to this behavior. On the other hand, the pure Perl version of
20 gettext in libintl-perl aims to be as compatible as possible to the
21 GNU gettext implementation. Furthermore, if the pure Perl and the
22 C/XS version behave differently, users may be unnecessarily confused.
23
24 If you think you can live with that little inconsistence, you are not
25 completely lost: Edit the toplevel Makefile.PL, in the function
26 WriteMakefile(), change the value for the hash slot "DIR" from
27 the value depending on "$result" to simply "['gettext_xs']". If you
28 have a look at the source code of Makefile.PL, you will see that this
29 has already been prepared.
30
31 If you do this, the test suite will fail, because the above described
32 behavior ("fr_CA" vs. "fr" ...) is checked by the tests. In this case,
33 expect the following failures:
34
35 Failed Test Stat Wstat Total Fail Failed List of Failed
36 -------------------------------------------------------------------------------
37 ./tests/03bind_textdomain_codeset_xs.t 9 2 22.22% 5 9
38 ./tests/03dcgettext_xs.t 9 2 22.22% 3 7
39 ./tests/03dcngettext_xs.t 83 51 61.45% 22-31 43-83
40 ./tests/03dgettext_xs.t 9 2 22.22% 3 7
41 ./tests/03dngettext_xs.t 83 51 61.45% 22-31 43-83
42 ./tests/03gettext_xs.t 6 1 16.67% 3
43 ./tests/03ngettext_xs.t 85 51 60.00% 23-32 45-85
44
45 But even if you have installed GNU gettext, you may run into this error
46 when trying to compile the XS version:
47
48 "gettext_xs.xs", line 32: #error: "<libintl.h> is not GNU gettext. Maybe you have to adjust your include path."
49 cc: acomp failed for gettext_xs.c
50 make[1]: *** [gettext_xs.o] Error 2
51 make[1]: Leaving directory `/root/libintl-perl-1.15/gettext_xs'
52 make: *** [subdirs] Error 2
53
54 What has happened here? Have a look at the source code of <libintl.h>
55 that ships with GNU gettext:
56
57 /* We define an additional symbol to signal that we use the GNU
58 implementation of gettext. */
59 #define __USE_GNU_GETTEXT 1
60
61 ...
62
63 /* We redirect the functions to those prefixed with "libintl_". This is
64 necessary, because some systems define gettext/textdomain/... in the C
65 library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
66 If we used the unprefixed names, there would be cases where the
67 definition in the C library would override the one in the libintl.so
68 shared library. Recall that on ELF systems, the symbols are looked
69 up in the following order:
70 1. in the executable,
71 2. in the shared libraries specified on the link command line, in order,
72 3. in the dependencies of the shared libraries specified on the link
73 command line,
74 4. in the dlopen()ed shared libraries, in the order in which they were
75 dlopen()ed.
76 The definition in the C library would override the one in libintl.so if
77 either
78 * -lc is given on the link command line and -lintl isn't, or
79 * -lc is given on the link command line before -lintl, or
80 * libintl.so is a dependency of a dlopen()ed shared library but not
81 linked to the executable at link time.
82 Since Solaris gettext() behaves differently than GNU gettext(), this
83 would be unacceptable.
84
85 The redirection happens by default through macros in C, so that &gettext
86 is independent of the compilation unit, but through inline functions in
87 C++, in order not to interfere with the name mangling of class fields or
88 class methods called 'gettext'. */
89
90 In brief: The GNU libraries libintl.so and libintl.a prefix all functions
91 with "libintl_" in order to avoid symbol name conflicts with the vanilla
92 Solaris verssion. These precautions still give room to a popular
93 misconfiguration: If you install GNU gettext with the default prefix
94 "/usr/local", libraries will get installed in "/usr/local/lib", the
95 header files - notably <libintl.h> - will get installed in
96 "/usr/local/include", so far so good. Now set the environment variable
97 LD_LIBRARY_PATH to "/usr/local/lib", so that the GNU version of libintl.so
98 will be found by the dynamic loader at runtime. Yet, if
99 "/usr/local/include" comes after "/usr/include" in your C compiler's
100 include path, the above described trick does not work, the functions
101 like "gettext", "dgettext" etc. will not get re-defined to "libintl_gettext",
102 "libintl_dgettext" and so on. Remember, the preprocessor trick used by
103 GNU gettext will change every reference to the function gettext() into
104 a reference to libintl_gettext() for gettext() into a definition for
105 libintl_gettext(). If your C compiler includes the "wrong" include file
106 (/usr/include/libintl.h) instead of the "correct" one
107 (/usr/local/include/libintl.h), your C sources will still reference
108 gettext() instead of libintl_gettext(). At run-time, even if the dynamic
109 loader considers the GNU version of libintl.so (in "/usr/local/lib"), it
110 will not use it, because it looks for the "wrong" symbol gettext()
111 instead of libintl_gettext().
112
113 Too complicated? Okay: The order for C header files for the C compiler
114 (actually the preprocessor) differs from the inclusion order for
115 libraries and this must lead to trouble. If you understand WHY, you
116 will find a way to fix it. If not, ignore the problem: Do not
117 build the problem, and be assured, that the pure Perl version is
118 fast enough. It is very, very unlikely that using the pure Perl
119 instead of the XS version of will be the bottleneck of any application
120 you use.
121
122 Life is complicated under the sun, ain't it? ;-)
123
124 Guido
125