NetBSD Problem Report #48928

From mm_lists@pulsar-zone.net  Fri Jun 20 03:00:13 2014
Return-Path: <mm_lists@pulsar-zone.net>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 087D6A5D59
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 20 Jun 2014 03:00:13 +0000 (UTC)
Message-Id: <201406200300.s5K309Ww000406@ginseng.pulsar-zone.net>
Date: Thu, 19 Jun 2014 23:00:09 -0400
From: Matthew Mondor <mm_lists@pulsar-zone.net>
To: gnats-bugs@gnats.NetBSD.org
Subject: Issue building static X11 clients

>Number:         48928
>Category:       xsrc
>Synopsis:       Issue building static X11 clients
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    mrg
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 20 03:05:00 +0000 2014
>Closed-Date:    Thu May 25 05:39:01 +0000 2017
>Last-Modified:  Thu May 25 05:39:01 +0000 2017
>Originator:     Matthew Mondor
>Release:        NetBSD 6.1_STABLE
>Organization:
>Environment:
System: NetBSD ninja.xisop 6.1_STABLE NetBSD 6.1_STABLE (GENERIC_MM) #3: Mon Jul 1 19:08:46 EDT 2013 root@ninja.xisop:/usr/obj/sys/arch/amd64/compile/GENERIC_MM amd64
Architecture: x86_64
Machine: amd64
>Description:

Attached is a minimal X11 test executable I borrowed to demonstrate the
issue.

To compile dynamically linked:

cc -o x11-test x11-test.c -I/usr/X11R7/include -L/usr/X11R7/lib -Wl,-rpath,/usr/X11R7/lib -lX11

x11-test:
        -lX11.7 => /usr/X11R7/lib/libX11.so.7
        -lxcb.1 => /usr/X11R7/lib/libxcb.so.1
        -lXau.7 => /usr/X11R7/lib/libXau.so.7
        -lgcc_s.1 => /usr/lib/libgcc_s.so.1
        -lc.12 => /usr/lib/libc.so.12
        -lXdmcp.7 => /usr/X11R7/lib/libXdmcp.so.7


To compile statically linked:

Attempt 1:
cc -o x11-test -static x11-test.c -I/usr/X11R7/include -L/usr/X11R7/lib -Wl,-rpath,/usr/X11R7/lib -lc -lX11 -lxcb -lXau -lXdmcp

/usr/X11R7/lib/libX11.a(lcInit.o): In function `_XlcInitLoader':
/usr/xsrc/external/mit/libX11/dist/src/xlibi18n/lcInit.c:130: undefined reference to `_XlcGenericLoader'
/usr/xsrc/external/mit/libX11/dist/src/xlibi18n/lcInit.c:134: undefined reference to `_XlcDefaultLoader'
/usr/xsrc/external/mit/libX11/dist/src/xlibi18n/lcInit.c:138: undefined reference to `_XlcUtf8Loader'
/usr/X11R7/lib/libX11.a(lcInit.o): In function `_XlcDeInitLoader':
/usr/xsrc/external/mit/libX11/dist/src/xlibi18n/lcInit.c:169: undefined reference to `_XlcGenericLoader'
/usr/xsrc/external/mit/libX11/dist/src/xlibi18n/lcInit.c:173: undefined reference to `_XlcDefaultLoader'
/usr/xsrc/external/mit/libX11/dist/src/xlibi18n/lcInit.c:177: undefined reference to `_XlcUtf8Loader'

After noticing that the libraries satisfying these symbols are located
at /usr/X11R7/lib/X11/locale/lib/common/ I realized that no statically
linkable versions existed either.  However, these seemed to be part of
the build, at /usr/obj/external/mit/xorg/lib/libX11/*/_pic.a so I
ensured their symbols were indexed with ranlib, and copied them
manually under names which can be statically linked.  Then the
following:

Attempt 2:

cc -o x11-test -static x11-test.c -I/usr/X11R7/include -L/usr/X11R7/lib -L/usr/X11R7/lib/X11/locale/lib/common/ -lxlibi18n -lximcp -lxlcDef -lxlcUTF8Load -lxlocale -lxomGeneric -lc -lX11 -lxcb -lXau -lXdmcp

/usr/X11R7/lib/libX11.a(lcInit.o): In function `_XlcInitLoader':
/usr/xsrc/external/mit/libX11/dist/src/xlibi18n/lcInit.c:130: undefined reference to `_XlcGenericLoader'
/usr/xsrc/external/mit/libX11/dist/src/xlibi18n/lcInit.c:134: undefined reference to `_XlcDefaultLoader'
/usr/xsrc/external/mit/libX11/dist/src/xlibi18n/lcInit.c:138: undefined reference to `_XlcUtf8Loader'
/usr/X11R7/lib/libX11.a(lcInit.o): In function `_XlcDeInitLoader':
/usr/xsrc/external/mit/libX11/dist/src/xlibi18n/lcInit.c:169: undefined reference to `_XlcGenericLoader'
/usr/xsrc/external/mit/libX11/dist/src/xlibi18n/lcInit.c:173: undefined reference to `_XlcDefaultLoader'
/usr/xsrc/external/mit/libX11/dist/src/xlibi18n/lcInit.c:177: undefined reference to `_XlcUtf8Loader'

I might be missing something obvious, and would be glad to know what.

I've only investigated a bit, but it seems that the i18n support can
dlopen(3) dynamic vendor-specific code.  In my impression, that is
fine, as long as it can keep working with the default behavior when
those modules are unused or absent.  I'm not sure yet why the code
cannot be statically built despite this design.

This is only a minimal x11 test program, but the goal would be to be
able to distribute an application binary which is easy to distribute,
to use without installation and which does not break easily with OS
updates.  Ideally, I'd like to release it and not have to touch it,
potentially for years.

Using a standard package, it'd have to be released/updated regularily,
at pkgsrc and NetBSD releases, and a user would need root access to
upgrade it.  An alternative would be to provide all necessary library
dependencies in a custom tree, with a binary RPATH designed to load
them from the current location, which is probably what I'll end up
doing for now.  This however requires more work, and for the user it
means more movable/breakable parts.  There's also more user work
involved like extracting an archive, or more work involved for the
issuer like providing an installer.

>How-To-Repeat:

An attached minimal X11 test client is included below, and build
instructions are included in the above description.

>Fix:

Unknown


--MP_/io1OMq/_/BiTiAEp7u+UNey
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=x11-test.c

/* 
	Brian Hammond 2/9/96.    Feel free to do with this as you will!
*/

/* include the X library headers */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>

/* include some silly stuff */
#include <stdio.h>
#include <stdlib.h>

/* here are our X variables */
Display *dis;
int screen;
Window win;
GC gc;

/* here are our X routines declared! */
void init_x();
void close_x();
void redraw();

main () {
	XEvent event;		/* the XEvent declaration !!! */
	KeySym key;		/* a dealie-bob to handle KeyPress Events */	
	char text[255];		/* a char buffer for KeyPress Events */

	init_x();

	/* look for events forever... */
	while(1) {		
		/* get the next event and stuff it into our event variable.
		   Note:  only events we set the mask for are detected!
		*/
		XNextEvent(dis, &event);

		if (event.type==Expose && event.xexpose.count==0) {
		/* the window was exposed redraw it! */
			redraw();
		}
		if (event.type==KeyPress&&
		    XLookupString(&event.xkey,text,255,&key,0)==1) {
		/* use the XLookupString routine to convert the invent
		   KeyPress data into regular text.  Weird but necessary...
		*/
			if (text[0]=='q') {
				close_x();
			}
			printf("You pressed the %c key!\n",text[0]);
		}
		if (event.type==ButtonPress) {
		/* tell where the mouse Button was Pressed */
			int x=event.xbutton.x,
			    y=event.xbutton.y;

			strcpy(text,"X is FUN!");
			XSetForeground(dis,gc,rand()%event.xbutton.x%255);
			XDrawString(dis,win,gc,x,y, text, strlen(text));
		}
	}
}

void init_x() {
/* get the colors black and white (see section for details) */        
	unsigned long black,white;

	dis=XOpenDisplay((char *)0);
   	screen=DefaultScreen(dis);
	black=BlackPixel(dis,screen),
	white=WhitePixel(dis, screen);
   	win=XCreateSimpleWindow(dis,DefaultRootWindow(dis),0,0,	
		300, 300, 5,black, white);
	XSetStandardProperties(dis,win,"Howdy","Hi",None,NULL,0,NULL);
	XSelectInput(dis, win, ExposureMask|ButtonPressMask|KeyPressMask);
        gc=XCreateGC(dis, win, 0,0);        
	XSetBackground(dis,gc,white);
	XSetForeground(dis,gc,black);
	XClearWindow(dis, win);
	XMapRaised(dis, win);
};

void close_x() {
	XFreeGC(dis, gc);
	XDestroyWindow(dis,win);
	XCloseDisplay(dis);	
	exit(1);				
};

void redraw() {
	XClearWindow(dis, win);
};

--MP_/io1OMq/_/BiTiAEp7u+UNey--

>Release-Note:

>Audit-Trail:

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/48928 Issue building static X11 clients
Date: Sun, 12 Jun 2016 03:24:14 +0000

 this wasn't sent to gnats

    ------

 from: matthew green <mrg@eterna.com.au>
 to: Matthew Mondor <mm_lists@pulsar-zone.net>, gnats-admin@netbsd.org,
 	netbsd-bugs@netbsd.org
 subject: Re: bin/48928 Issue building static X11 clients
 Date: Thu, 02 Jun 2016 02:46:09 +1000

 this is almost certainly this chunk of code i apparently never got back
 to fixing in the original native-xorg port from native-x11 (which does
 include these files.)

 external/mit/xorg/lib/libX11/static/Makefile:

   9 .if 0
  10 SRCS+=  imCallbk.c imDefFlt.c imDefIc.c imDefIm.c imDefLkup.c imDispch.c \
  11         imEvToWire.c imExten.c imImSw.c imInsClbk.c imInt.c imLcFlt.c \
  12         imLcGIc.c imLcIc.c imLcIm.c imLcLkup.c imLcPrs.c imLcSIc.c imRm.c \
  13         imRmAttr.c imThaiFlt.c imThaiIc.c imThaiIm.c imTrX.c imTrans.c \
  14         imTransR.c lcEuc.c lcGenConv.c lcJis.c lcSjis.c lcUTF8Load.c \
  15         omDefault.c omGeneric.c omImText.c omText.c omTextEsc.c omTextExt.c \
  16         omTextPer.c omXChar.c
  17 .endif

From: "matthew green" <mrg@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48928 CVS commit: src/external/mit/xorg/lib/libX11
Date: Thu, 2 Jun 2016 22:41:27 +0000

 Module Name:	src
 Committed By:	mrg
 Date:		Thu Jun  2 22:41:27 UTC 2016

 Modified Files:
 	src/external/mit/xorg/lib/libX11: Makefile.ximcp Makefile.xlcDef
 	    Makefile.xlcUTF8Load Makefile.xlibi18n Makefile.xomGeneric
 	src/external/mit/xorg/lib/libX11/static: Makefile
 	src/external/mit/xorg/lib/libX11/ximcp: Makefile
 	src/external/mit/xorg/lib/libX11/xlcDef: Makefile
 	src/external/mit/xorg/lib/libX11/xlcUTF8Load: Makefile
 	src/external/mit/xorg/lib/libX11/xlibi18n: Makefile
 	src/external/mit/xorg/lib/libX11/xomGeneric: Makefile

 Log Message:
 fix PR 48928:  build the static libX11 properly.  pull in the
 ximcp, xlcDef, xlcUTF8Load, xlibi18n, and xomGeneric modules
 directly.

 also, don't include bsd.lib.mk in the fragment parts for these
 modules, but in the module build itself.  otherwise, bsd.lib.mk
 is included before SRCS is complete and the build strangely
 seems to miss parts listed.

 tested using the example in the PR.


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.3 src/external/mit/xorg/lib/libX11/Makefile.ximcp
 cvs rdiff -u -r1.1 -r1.2 src/external/mit/xorg/lib/libX11/Makefile.xlcDef \
     src/external/mit/xorg/lib/libX11/Makefile.xlcUTF8Load \
     src/external/mit/xorg/lib/libX11/Makefile.xlibi18n \
     src/external/mit/xorg/lib/libX11/Makefile.xomGeneric
 cvs rdiff -u -r1.2 -r1.3 src/external/mit/xorg/lib/libX11/static/Makefile
 cvs rdiff -u -r1.3 -r1.4 src/external/mit/xorg/lib/libX11/ximcp/Makefile
 cvs rdiff -u -r1.1 -r1.2 src/external/mit/xorg/lib/libX11/xlcDef/Makefile
 cvs rdiff -u -r1.1 -r1.2 \
     src/external/mit/xorg/lib/libX11/xlcUTF8Load/Makefile
 cvs rdiff -u -r1.1 -r1.2 src/external/mit/xorg/lib/libX11/xlibi18n/Makefile
 cvs rdiff -u -r1.1 -r1.2 src/external/mit/xorg/lib/libX11/xomGeneric/Makefile

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

Responsible-Changed-From-To: xsrc-manager->mrg
Responsible-Changed-By: mrg@NetBSD.org
Responsible-Changed-When: Fri, 03 Jun 2016 01:14:16 +0000
Responsible-Changed-Why:
i think i fixed it in -current.  can you test there?  i'll prepare pullups
for -6 and -7.  (i think both need different versions..)


State-Changed-From-To: open->feedback
State-Changed-By: mrg@NetBSD.org
State-Changed-When: Fri, 03 Jun 2016 01:14:16 +0000
State-Changed-Why:
please test, if possible.


From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48928 CVS commit: [netbsd-7] src/external/mit/xorg/lib/libX11
Date: Fri, 23 Dec 2016 08:04:05 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Fri Dec 23 08:04:05 UTC 2016

 Modified Files:
 	src/external/mit/xorg/lib/libX11 [netbsd-7]: Makefile.ximcp
 	    Makefile.xlcDef Makefile.xlcUTF8Load Makefile.xlibi18n
 	    Makefile.xomGeneric
 	src/external/mit/xorg/lib/libX11/static [netbsd-7]: Makefile
 	src/external/mit/xorg/lib/libX11/ximcp [netbsd-7]: Makefile
 	src/external/mit/xorg/lib/libX11/xlcDef [netbsd-7]: Makefile
 	src/external/mit/xorg/lib/libX11/xlcUTF8Load [netbsd-7]: Makefile
 	src/external/mit/xorg/lib/libX11/xlibi18n [netbsd-7]: Makefile
 	src/external/mit/xorg/lib/libX11/xomGeneric [netbsd-7]: Makefile

 Log Message:
 Pull up following revision(s) (requested by mrg in ticket #1336):
 	external/mit/xorg/lib/libX11/Makefile.xlibi18n: revision 1.2
 	external/mit/xorg/lib/libX11/xlcUTF8Load/Makefile: revision 1.2
 	external/mit/xorg/lib/libX11/xlcDef/Makefile: revision 1.2
 	external/mit/xorg/lib/libX11/Makefile.xomGeneric: revision 1.2
 	external/mit/xorg/lib/libX11/xomGeneric/Makefile: revision 1.2
 	external/mit/xorg/lib/libX11/Makefile.xlcDef: revision 1.2
 	external/mit/xorg/lib/libX11/xlibi18n/Makefile: revision 1.2
 	external/mit/xorg/lib/libX11/ximcp/Makefile: revision 1.4
 	external/mit/xorg/lib/libX11/static/Makefile: revision 1.3
 	external/mit/xorg/lib/libX11/Makefile.ximcp: revision 1.3
 	external/mit/xorg/lib/libX11/Makefile.xlcUTF8Load: revision 1.2
 fix PR 48928:  build the static libX11 properly.  pull in the
 ximcp, xlcDef, xlcUTF8Load, xlibi18n, and xomGeneric modules
 directly.
 also, don't include bsd.lib.mk in the fragment parts for these
 modules, but in the module build itself.  otherwise, bsd.lib.mk
 is included before SRCS is complete and the build strangely
 seems to miss parts listed.
 tested using the example in the PR.


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.2.40.1 src/external/mit/xorg/lib/libX11/Makefile.ximcp
 cvs rdiff -u -r1.1 -r1.1.42.1 \
     src/external/mit/xorg/lib/libX11/Makefile.xlcDef \
     src/external/mit/xorg/lib/libX11/Makefile.xlcUTF8Load \
     src/external/mit/xorg/lib/libX11/Makefile.xlibi18n \
     src/external/mit/xorg/lib/libX11/Makefile.xomGeneric
 cvs rdiff -u -r1.2 -r1.2.20.1 \
     src/external/mit/xorg/lib/libX11/static/Makefile
 cvs rdiff -u -r1.3 -r1.3.6.1 src/external/mit/xorg/lib/libX11/ximcp/Makefile
 cvs rdiff -u -r1.1 -r1.1.42.1 \
     src/external/mit/xorg/lib/libX11/xlcDef/Makefile
 cvs rdiff -u -r1.1 -r1.1.42.1 \
     src/external/mit/xorg/lib/libX11/xlcUTF8Load/Makefile
 cvs rdiff -u -r1.1 -r1.1.42.1 \
     src/external/mit/xorg/lib/libX11/xlibi18n/Makefile
 cvs rdiff -u -r1.1 -r1.1.42.1 \
     src/external/mit/xorg/lib/libX11/xomGeneric/Makefile

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Thu, 25 May 2017 05:39:01 +0000
State-Changed-Why:
feedback timeout


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.