Subject: bin/12017: how to enable multibyte locale (and problem around it)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <itojun@itojun.org>
List: netbsd-bugs
Date: 01/21/2001 03:05:22
>Number:         12017
>Category:       bin
>Synopsis:       how to enable multibyte locale (and problem around it)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 21 03:08:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Jun-ichiro itojun Hagino
>Release:        1.5Q
>Organization:
	itojun.org
>Environment:
System: NetBSD starfruit.itojun.org 1.5Q NetBSD 1.5Q (STARFRUIT) #333: Sun Jan 21 03:07:47 JST 2001 itojun@starfruit.itojun.org:/usr/home/itojun/NetBSD/src/sys/arch/i386/compile/STARFRUIT i386
Architecture: i386
Machine: i386
>Description:
	we have multibyte locale framework in our tree, however, multibyte
	locale support is not enabled by the following two obstacles.

	(a) dlopen() is not available for statically linked libraries.
	(b) ld.elf_so (or ld.aout_so) goes mad if we enable it, due to 
	    reference to dlopen() via printf().

	this is partly because multibyte locale support uses dlopen() from
	within libc.  it is unavoidable for extensibility and smaller code
	footprint.
	(if we avoid use of dlopen(), we will have locale library that is not
	future-proven, and netbsd binaries will become bigger due to unused
	locale handling code.  in the document we don't consider it an option)

	the PR tries to document workaround for the problem, to asian readers.

	http://mail-index.netbsd.org/tech-userlevel/2001/01/02/0000.html
	is related to this PR.
>How-To-Repeat:
>Fix:
	first, we need to pick a goal.
	(1) no multibyte locale.
	(2) multibyte locale available in dynamically-linked binary only.
	(3) multibyte locale available in both dynamic and staticaly-linked
	    binaries.
	(4) multibyte locale available in both dynamic and staticaly-linked
	    binaries, INCLUDING ld.{aout,elf}_so.

	(1) is the current situation.

	to do (2), we need to apply the following patch, and rebuild under
	lib/localemod, lib/libc and libexec/ld_elf.so.   the patch workarounds
	problem (b) by linking ld.elf_so with singlebyte locale code.

	to do (3), we need to properly solve problem (a), and apply the patch.

	to do (4), i'm not sure.

	i'm not sure if it is okay to take option (2) right now or not.

Index: lib/Makefile
===================================================================
RCS file: /cvsroot/basesrc/lib/Makefile,v
retrieving revision 1.69
diff -u -r1.69 Makefile
--- lib/Makefile	2001/01/05 12:10:39	1.69
+++ lib/Makefile	2001/01/21 11:05:24
@@ -37,4 +37,7 @@
 # IPv6/IPsec
 SUBDIR+=	libipsec
 
+# multibyte locale
+SUBDIR+=	localemod
+
 .include <bsd.subdir.mk>
Index: lib/localemod/Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
--- /dev/null	Sun Jan 21 03:29:34 2001
+++ Makefile	Sun Jan 21 13:05:24 2001
@@ -0,0 +1,5 @@
+#	$NetBSD$
+
+SUBDIR=	BIG5 EUC MSKanji UTF2 UTF8 EUCTW ISO2022
+
+.include <bsd.subdir.mk>
Index: lib/localemod/Makefile.inc
===================================================================
RCS file: Makefile.inc
diff -N Makefile.inc
--- /dev/null	Sun Jan 21 03:29:34 2001
+++ Makefile.inc	Sun Jan 21 13:05:24 2001
@@ -0,0 +1,23 @@
+#	$NetBSD$
+
+.include <bsd.own.mk>
+
+WARNS?=	1
+
+SHLIB_VERSION_FILE=	${.CURDIR}/../shlib_version
+SHLIBDIR=	/usr/lib/runemodule
+LIBDIR=		/usr/lib/runemodule
+INTERNALLIB=	yes
+MKPROFILE=	no
+MKPICINSTALL=	no
+MKLINT=		no
+CPPFLAGS+=	-I${.CURDIR}/../../libc/locale
+CPPFLAGS+=	-DRUNEMOD_MAJOR=${SHLIB_MAJOR}
+BASENAME!=	basename ${.CURDIR}
+LIB=		${BASENAME}
+SRCS!=		echo ${BASENAME}.c | tr A-Z a-z
+
+.PATH:	${.CURDIR}/../../libc/locale
+
+beforeinstall:
+	if [ ! -d ${SHLIBDIR} ]; then mkdir ${SHLIBDIR}; fi
Index: lib/localemod/shlib_version
===================================================================
RCS file: shlib_version
diff -N shlib_version
--- /dev/null	Sun Jan 21 03:29:34 2001
+++ shlib_version	Sun Jan 21 13:05:24 2001
@@ -0,0 +1,5 @@
+#	$NetBSD$
+#	Remember to update distrib/sets/lists/base/shl.* when changing
+#
+major=3
+minor=0
Index: lib/localemod/BIG5/Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
--- /dev/null	Sun Jan 21 03:29:34 2001
+++ Makefile	Sun Jan 21 13:05:24 2001
@@ -0,0 +1,3 @@
+#	$NetBSD$
+
+.include <bsd.lib.mk>
Index: lib/localemod/EUC/Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
--- /dev/null	Sun Jan 21 03:29:34 2001
+++ Makefile	Sun Jan 21 13:05:24 2001
@@ -0,0 +1,3 @@
+#	$NetBSD$
+
+.include <bsd.lib.mk>
Index: lib/localemod/EUCTW/Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
--- /dev/null	Sun Jan 21 03:29:34 2001
+++ Makefile	Sun Jan 21 13:05:24 2001
@@ -0,0 +1,3 @@
+#	$NetBSD$
+
+.include <bsd.lib.mk>
Index: lib/localemod/ISO2022/Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
--- /dev/null	Sun Jan 21 03:29:34 2001
+++ Makefile	Sun Jan 21 13:05:24 2001
@@ -0,0 +1,3 @@
+#	$NetBSD$
+
+.include <bsd.lib.mk>
Index: lib/localemod/MSKanji/Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
--- /dev/null	Sun Jan 21 03:29:34 2001
+++ Makefile	Sun Jan 21 13:05:24 2001
@@ -0,0 +1,3 @@
+#	$NetBSD$
+
+.include <bsd.lib.mk>
Index: lib/localemod/UTF2/Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
--- /dev/null	Sun Jan 21 03:29:34 2001
+++ Makefile	Sun Jan 21 13:05:24 2001
@@ -0,0 +1,3 @@
+#	$NetBSD$
+
+.include <bsd.lib.mk>
Index: lib/localemod/UTF8/Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
--- /dev/null	Sun Jan 21 03:29:34 2001
+++ Makefile	Sun Jan 21 13:05:24 2001
@@ -0,0 +1,3 @@
+#	$NetBSD$
+
+.include <bsd.lib.mk>
Index: lib/libc/locale/Makefile.inc
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/locale/Makefile.inc,v
retrieving revision 1.31
diff -u -r1.31 Makefile.inc
--- lib/libc/locale/Makefile.inc	2000/12/27 00:57:03	1.31
+++ lib/libc/locale/Makefile.inc	2001/01/21 11:05:24
@@ -22,9 +22,9 @@
 SRCS+=	___runetype_mb.c ___tolower_mb.c ___toupper_mb.c iswctype.c \
 	multibyte.c rune.c runeglue.c runenone.c runetable.c setrunelocale.c
 CPPFLAGS+=	-DWITH_RUNE
-#MODULE_SHLIB_MAJOR!=	. ${.CURDIR}/../localemod/shlib_version; echo $$major
-#CPPFLAGS+=	-DDLRUNE -DRUNEMOD_MAJOR=${MODULE_SHLIB_MAJOR} \
-#		-D_PATH_LOCALEMODULE=\"/usr/lib/runemodule\"
+MODULE_SHLIB_MAJOR!=	. ${.CURDIR}/../localemod/shlib_version; echo $$major
+CPPFLAGS+=	-DDLRUNE -DRUNEMOD_MAJOR=${MODULE_SHLIB_MAJOR} \
+		-D_PATH_LOCALEMODULE=\"/usr/lib/runemodule\"
 # to be dynamically loaded
 #SRCS+=	big5.c euc.c euctw.c iso2022.c mskanji.c utf2.c utf8.c
 .endif
Index: lib/libc/locale/Makefile.nolocale
===================================================================
RCS file: Makefile.nolocale
diff -N Makefile.nolocale
--- /dev/null	Sun Jan 21 03:29:34 2001
+++ Makefile.nolocale	Sun Jan 21 13:05:24 2001
@@ -0,0 +1,7 @@
+#	$NetBSD$
+
+ABSCUR!= cd ${.PARSEDIR}; pwd
+
+SRCS+=  multibyte_sb.c iswctype_sb.c setlocale.c
+CPPFLAGS+=	-UWITH_RUNE -I${ABSCUR} -I${ABSCUR}/../include
+.PATH:  ${ABSCUR}
Index: libexec/ld.elf_so/Makefile
===================================================================
RCS file: /cvsroot/basesrc/libexec/ld.elf_so/Makefile,v
retrieving revision 1.36
diff -u -r1.36 Makefile
--- libexec/ld.elf_so/Makefile	2001/01/14 09:39:26	1.36
+++ libexec/ld.elf_so/Makefile	2001/01/21 11:05:25
@@ -33,6 +33,9 @@
 #CPPFLAGS+= -DRTLD_DEBUG_RELOC
 #DBG=	-g
 
+# always use singlebyte locale.
+.include "../../lib/libc/locale/Makefile.nolocale"
+
 LDADD+=	-non_shared -L${DESTDIR}/${LIBDIR} -lc_pic
 DPADD+=	${LIBC_PIC}
 
>Release-Note:
>Audit-Trail:
>Unformatted: