Package: icu
Version: 3.6-1
Severity: wishlist
Tags: patch

The ICU shared libraries are all linked against libpthread, but the only
pthread functions ICU actually uses are:

libicuuc.so:         U pthread_mutex_destroy
libicuuc.so:         U pthread_mutex_init
libicuuc.so:         U pthread_mutex_lock
libicuuc.so:         U pthread_mutex_unlock

On a glibc-based system, these functions are all in libc, so the ICU
libraries can safely be built without linking against libpthread.
It is desirable to avoid libpthread, because glibc attempts to ensure
that single-threaded programs are not subject to the overhead of thread
safety, and it detects multi-threadedness by checking whether libpthread
is loaded at runtime.  Thus, any single-threaded program that uses ICU
is currently subject to unnecessary overhead.

It's possible to avoid linking ICU against libpthread by a clever trick
which does not involve any modifications to the upstream source, and
this is what I have done in the appended patch.  It applies relative
to the top level of the directory you get by unpacking the source deb
(*not* to build-tree/).

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17-2-686
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=UTF-8)

-- patch:

--- debian/rules        2006-09-24 11:48:05.000000000 -0700
+++ debian/rules        2006-09-24 11:14:32.000000000 -0700
@@ -14,7 +14,8 @@
              awk '/Version:/ {print $$2}' | cut -d- -f 1)
 
 DEB_TAR_SRCDIR = icu/source
-DEB_CONFIGURE_USER_FLAGS = --disable-samples --enable-static
+DEB_CONFIGURE_USER_FLAGS = --disable-samples --enable-static \
+                           CONFIG_SITE=../../../config.site
 DEB_COMPRESS_EXCLUDE = html examples
 DEB_INSTALL_EXAMPLES_libicu36-dev = \
        build-tree/$(DEB_TAR_SRCDIR)/samples/*
--- config.site 1969-12-31 16:00:00.000000000 -0700
+++ config.site 2006-09-24 11:47:28.000000000 -0700
@@ -0,0 +1,7 @@
+# These trick the configure script into not linking anything with libpthread,
+# while still enabling thread safety (it goes on to check for
+# pthread_mutex_lock in libc, which is enough for what it actually needs).
+# Should work correctly on all glibc-based systems.
+ac_cv_lib_pthread_pthread_attr_init=no
+ac_cv_search_pthread_mutex_destroy=no
+ac_cv_lib_pthread_pthread_mutex_init=no


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to