How to switch to scim on Solaris/OpenSolaris snv_99

At first, install scim and your favorite input-method engines from pkg.opensolaris.org, you could list the available scim packages, by $ pkg list -a SUNWscim*. For nevada users, you need select the scim metacluster in installer.

Then, edit your $HOME/.profile to export the GTK_IM_MODULE to scim, and re-login


$ cat >> ~/.profile << EOF
> GTK_IM_MODULE=scim
> export GTK_IM_MODULE
> EOF

To switch back to iiim, you could simply comment out the above lines in your $HOME/.profile, and re-login.

scim packages are available on pkg.opensolaris.org

Just enjoy it :)

pkg:/SUNWscim-anthy@1.2.4,5.11-0.96:20080825T192330Z Info Manifest
pkg:/SUNWscim-chewing@0.3.1,5.11-0.96:20080825T192330Z Info Manifest
pkg:/SUNWscim-hangul@0.3.2,5.11-0.96:20080825T192331Z Info Manifest
pkg:/SUNWscim-pinyin@0.5.91,5.11-0.96:20080825T192331Z Info Manifest
pkg:/SUNWscim-sunpinyin@1.0,5.11-0.96:20080825T192335Z Info Manifest
pkg:/SUNWscim-tables-chinese@0.5.7,5.11-0.96:20080825T192355Z Info Manifest
pkg:/SUNWscim-tables-extra@0.5.7,5.11-0.96:20080825T192401Z Info Manifest
pkg:/SUNWscim-tables-india@0.5.7,5.11-0.96:20080825T192401Z Info Manifest
pkg:/SUNWscim-tables-japanese@0.5.7,5.11-0.96:20080825T192401Z Info Manifest
pkg:/SUNWscim-tables-korean@0.5.7,5.11-0.96:20080825T192402Z Info Manifest
pkg:/SUNWscim-tables@0.5.7,5.11-0.96:20080825T192354Z Info Manifest
pkg:/SUNWscim-thai@0.1.0,5.11-0.96:20080825T192402Z Info Manifest
pkg:/SUNWscim@1.4.7,5.11-0.96:20080825T192322Z Info Manifest

Our next plan is to integrate libm17n and scim-m17n. Stay tuned.

SCIM and UIM packages for Solaris Nevada (or SDX) are available on OS.o

The scim-1.4.6 and uim-1.4.1 packages for Solaris nevada (or Solaris Developer Express) x86 are available on OpenSolaris.org Input Method project.

Download the following archives from http://www.opensolaris.org/os/project/input-method/files:

im-libs-nv-x86.tar.bz2
scim-base-nv-x86.tar.bz2
scim-imes-nv-x86.tar.bz2
scim-tables-nv-x86.tar.bz2
uim-nv-x86.tar.bz2

Extract the archived files, then install the packages:

$ for i in `ls *.bz2`; do bzcat $i | tar xvf -; done
# pkgadd -d . OSIM*

To use scim or uim, for gnome applications, in the text edit area, right click your mouse, and from the popup context menu, slip your pointer to "Input Methods", and select "SCIM Input Method" or "uim". However, in this way, after you application is closed, the scim daemons also exit, and starting scim daemons really requires some time.

To enable scim as the default IM service, modify the im startup script for you login locale, e.g., for zh_CN.UTF-8,
/usr/openwin/lib/locale/zh_CN.UTF-8/imsscript/S505multi (it's actually a symbol link to common/imsscript/S505multi, and all UTF-8 locale use the same file). Then apply the following patch

--- S505multi.orig      Mon Jun 25 09:39:35 2007
+++ S505multi           Mon Jun 25 09:40:04 2007
@@ -4,8 +4,8 @@
# Start iiimx for each desktop.
if [ -x /usr/bin/iiimx ]; then
-    GTK_IM_MODULE=iiim
+    GTK_IM_MODULE=scim
export GTK_IM_MODULE
-    /usr/bin/iiimx -iiimd
+    /usr/bin/scim -d
unset DTSTARTIMS
fi

Then re-login your desktop session.

Note:

currently, the XIM client does not work well with scim XIM front-end. And firefox/thunderbird would start another panel instance with scim im module, therefore I recommend you to use the scim-bridge im module. If you want to use uim, I'd recommend you to start uim-toolbar-gtk (or uim-toolbar-gtk-systray) to show the current IME status, add it to the "Startup Programs" by gnome-session-properties.

Here are some screenshots:

static constructors and symbol bindings in ld.so (2)

Rod Evans suggested me NOT to use "-Bdirect" for a C++ library. And thanks a lot to Stephen Clamage (ANSI C++ chairman), taught me to use "-instlib" option of CC. 

$ CC -flags
... ...
-instlib=<library>    Inhibit generation of instances already in <library>
... ...

The option causes the the compiler to scan the named library for template instances (and inline functions generated out of line), then omit generating them in the current .o file. Therefore, by specifying -instlib=./libbase.so when building libtest.so, the instantiated template "std::basic_string<unsigned int> str" would not be linked into libtest.so. So that the cyclic dependencies would not happen.

I added this option in the Makefile.am of im-scim.so, and it worked as expected.

-im_scim_la_CXXFLAGS=@GTK2_CFLAGS@
+im_scim_la_CXXFLAGS=@GTK2_CFLAGS@ \
+                   -instlib=$(top_builddir)/src/.libs/libscim-1.0.so

You could refer to [osol-tools-linking] thread for details.

static constructors and symbol bindings in ld.so

libbase.cpp:

#include <stdio.h>
#include <stdlib.h>
#include <string>

class Bar
{
public:
        std::basic_string<unsigned int> name;
        char *buf;
        Bar ()  { buf = new char[10]; buf[9] = '';}
        ~Bar () { delete [] buf; }

};

static Bar bar;

void __initialize_libbase ()
{
        printf ("%s\n", bar.buf);
}

libtest.cpp: 

#include <string>
#include "libbase.h"

class Foo {
public:
        std::basic_string<unsigned int> str;
        Foo () { __initialize_libbase (); }
        void test () { printf ("test ()!\n"); }
};

static Foo foo;

test.c:

#include <dlfcn.h>
#include <link.h>

int main (int argc, char **argv)
{
        dlopen ("./libtest.so", RTLD_LAZY|RTLD_GLOBAL);
}

When the main program call dlopen ("libtest.so"), it resolves the dependencies, then adds libbase.so in the initialization sequence ahead of libtest.so (the order is reversed). And the static constructors in a shared library are in the .init routine.

In our case, while it's trying to initialize the static object "bar", it finds there is a symbol "xxx::__null_string_ref_rep<xxx>" (introduced by std::basic_string<unsigned int>), then looks up this symbol in loaded libraries. Firstly, it looks up the symbol in main program, then in libc.so, then finds matched one in libtest.so, and stops to move on (actually, libbase.so also has this symbol). Then it tries to initialize libtest.so, and initializes the static object "foo". Unfortunately, the constructor of Foo calls a external function in libbase, and this function accesses the static instance "bar", which is not initialized yet (the "buf" is not allocated).

So, it cores. That's the root cause why Scim GtkIMModule makes applications core.

While, if you added a main() in libtest.cpp, and compile it to an executable program, this problem would not happen. If you changed the flag from RTLD_LAZY to RTLD_NOW, this problem would not happen either. To resolve this, add -Bdirect option when you link the library. Refer to the new "Direct Binding" chapter of "Linker and Libraries guide".

And I need thank Rod Evans, he taught me to set LD_DEBUG env variable to show the debug informations. You could refer to [osol-tools-linking] thread for details.

Scim GtkIMModule makes applications core on Nevada 66

When I build the scim-1.4.6 packages on Solaris Nevada build 66 with SunStudio 12 (or 11) and CBE 1.6. I found gtk-query-immodules-2.0 would core after loading im-scim.so. In dbx, it reports "no mapping at the fault address", as following:

signal SEGV (no mapping at the fault address) in __rwstd::__rb_tree<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::pair<const std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,__rwstd::__select1st<std::pair<const std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<const std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > >::begin at line 741 in file "tree"

It's really a nightmare to tell what's wrong from the error message :( I thought it's a STL problem at the beginning.

It took me 1 day to find the real reason, which is fairly simple: the static object instance initializations are not in proper order.

In im-scim.so, there is a static
object instance, and it calls a global function in libscim-1.0.so, in
that global function, it accesses another static object instance which is not initialized yet. I
wrote a small test program, it just uses dlopen() to load im-scim.so. From
the debugger, I could see, the static constructor in im-scim.so is
called before the static constructor in libscim-1.0.so. Therefore, the test
program cores. I don't know if it is a bug of libCrun or ld.so?

I also asked this question in SunStudio C++ forum as well as [osol-tools-linking]. Here is an workaround patch, please note, it leaves an un-finalized heap object,  __config_repository, so your configuration may not be saved.

P.S., when I am using snv_62, the shared objects works fine, but failed on snv_66.

Has your type already been registered in GObject type system?

Because both scim-chewing-0.3.1 and scim-anthy-1.2.3 include the same code from scim_color_button.cpp, and registered the same type name -- "ScimColorButton", when their setup UI modules are installed together, scim-helper-launcher would crash when loading them, since the later one would get an error and an invalid GType id (NULL).

Create a share object for "ScimColorButton"? I think for such a small class, it's not worth to do so.

To resolve this, one trick is to use g_type_from_name () (thanks the guys in #gtk+ on irc.gnome.org) to query, if the "ScimColorButton" is registered, if the GType returned is valid, stop to register. As following patch:

Index: src/scim_color_button.cpp
===================================================================
--- src/scim_color_button.cpp   (revision 794)
+++ src/scim_color_button.cpp   (working copy)
@@ -99,6 +99,9 @@
             (GInstanceInitFunc) scim_color_button_init,
         };

+        type = g_type_from_name ("ScimColorButton");
+
+        if (!type)
         type = g_type_register_static (GTK_TYPE_DRAWING_AREA,
                                        "ScimColorButton",
                                        &info, (GTypeFlags) 0);

The risk is if the 1st shared object is un-loaded, the 2nd module would fail to create the instance. If these two modules have same lifecycle, it's OK to use that method. Otherwise, name mangling would be better solution.

Build scim 1.4.6 packages on nevada with SunStudio 11 and CBE 1.6

$ . /opt/jdsbld/bin/env.sh #or
$ source /opt/jdsbld/bin/env.csh
$ mkdir -p ~/packages/SOURCES ~/packages/SPECS

If you like to use your own account rather than gbuild, add the "Software Installation" profile in /etc/user_attr, e.g.,

# echo "yongsun::::type=normal;profiles=Software Installation" \
>> /etc/user_attr
  • Checkout the source code of scim and its IMEs
Repository Module Branch/Tag
scim.cvs.sourceforge.net:/cvsroot/scim scim scim_1_4_6
scim-bridge stable-0_4_10
scim-pinyin scim_pinyin_0_5_91
scim-hangul scim_hangul_0_3_1
scim-tables scim_tables_0_5_7
scim-m17n scim_m17n_0_2_2
cvs.sourceforge.jp:/cvsroot/scim-imengine scim-anthy RELEASE_1_2_3
svn.csie.net/chewing scim-chewing 0.3.1

Rename the modules to append the version number, and archive them to
tar.gz files, e.g., scim-1.4.6.tar.gz, scim-bridge-0.4.10.tar.gz etc.

Or, download the corresponding tar.gz files directly from http://www.scim-im.org/downloads/scim_download, and http://www.scim-im.org/downloads/imengines_download

Copy them to ~/packages/SOURCES

  • Download the following libraries

anthy-8700b.tar.gz
libchewing-0.3.0.tar.gz
libhangul-0.4.0.tar.gz
m17n-lib-1.3.4.tar.gz
m17n-db-1.3.4.tar.gz
glibc-2.3.2.tar.bz2

Copy them to ~/packages/SOURCES

  • Download the patches and spec files , extract the archive file, and copy them to ~/packages/SOURCES and ~/packages/SPECS separately.
  • Change directory to ~/packages/SPECS, build and install the packages with pkgtool
$ pkgtool build *.spec

Note: Please do NOT install both OSIMscim-anthy and OSIMscim-chewing, there is a bug that both of them register a static type "ScimColorButton", so that the setup GUI modules will fail to initialize.

Build scim-1.4.6 on Solaris nevada with SunStudio 11

To build scim and its IME modules on Solaris nevada (build 62), please download and install SunStudio 11 as well as CBE 1.6,

Build scim-1.4.6 

1. checkout scim_1_4_6 branch of scim from scim.cvs.sourceforge.net, and apply the patch
2. $ export LDFLAGS=-lsocket, then execute ./bootstrap
3. $./bootstrap; $ ./configure --prefix=/usr; make
4. # make install (or $ sudo make install)

Note, after make install, you may need modify the /etc/gtk-2.0/gtk.immodules to add the following stuff (returned by gtk-query-immodules-2.0)

"/usr/lib/gtk-2.0/immodules/im-scim.so"
"scim" "SCIM Input Method" "scim" "/usr/share/locale" "ja:ko:zh"

Build scim-pinyin-0.5.91

1. checkout  scim_pinyin_0_5_91 branch of scim-pinyin from scim.cvs.sourceforge.net, and apply the patch
2. $./bootstrap; $ ./configure --prefix=/usr; make
3. # make install (or $ sudo make install)

Build scim-hangul-0.3.1

0. download libhangul 0.4.0, configure it and run make (the test/hangul.c would fail, just ignore it)
1. checkout scim_hangul_0_3_1 branch of scim-hangul from scim.cvs.sourceforge.net, and apply the patch
2. $./bootstrap; $ ./configure --prefix=/usr; make
3. # make install (or $ sudo make install)

Build scim-tables-0.5.7

1. checkout scim_tables_0_5_7 branch of scim-tables from  scim.cvs.sourceforge.net, and apply the patch
2. $./bootstrap; $ ./configure --prefix=/usr; make
3. # make install (or $ sudo make install)

Build scim-anthy-1.2.3

1. download anthy-8700b source tar file from http://sourceforge.jp/projects/anthy, and apply the patch
2. build anthy-8700b and install
3. check out RELEASE_1_2_3 branch of scim-anthy from cvs.sourceforge.jp, and apply the patch
4. build scim-anthy and install.

Build scim-m17n-0.2.2

1. download m17n-lib-1.3.4 and m17n-db-1.3.4 from http://www.m17n.org/m17n-lib-en/download.html
2. To build m17n-lib-core, ./configure --prefix=/usr --with-gui=no, make and make install.
3. To build m17n-db, download glibc-2.3.2.tar.gz from http://ftp.gnu.org/gnu/glibc, extract the tgz file, and ./configure --prefix=/usr --with-charmaps=glibc-2.3.2/localedata/charmaps/, make and make install
4. checkout scim_m17n_0_2_2 branch of scim-m17n from scim.cvs.sourceforge.net, build and install

Build scim-chewing-0.3.1

1. download libchewing-0.3.0 and scim-chewing-0.3.1 from http://chewing.csie.net/download/
2. extract libchewing-0.3.0 and apply the patch, make and make install
3. extract scim-chewing and apply the patch, make and make install

Build scim-bridge-0.4.10

1. checkout stable-0_4_10 branch of scim-bridge from scim.cvs.sourceforge.net, and apply the patch
2. ./configure --prefix=/usr --disable-debug --disable-documents CFLAGS=-DMSG_NOSIGNAL=0 CPPFLAGS=-DMSG_NOSIGNAL=0
3. make and make install

Note, after make install, you may need modify the
/etc/gtk-2.0/gtk.immodules to add the following stuff (returned by
gtk-query-immodules-2.0)

"/usr/lib/gtk-2.0/immodules/im-scim-bridge.so"
"scim-bridge" "SCIM Bridge Input Method" "" "" ""

I will try to build solaris packages, and deliver to our input-method OS.o project.