Bug 50161

Summary: libXThrStub.so.6 has undefined references
Product: Ports & Packages Reporter: jimd <jimd>
Component: Individual Port(s)Assignee: Eric Anholt <anholt>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description jimd 2003-03-21 10:40:11 UTC
	Attempt to compile xlockmore failed with unresolved references:

	/usr/lib/libc.so.4: warning: tempnam() possibly used unsafely; consider using mk
	stemp()
	/usr/X11R6/lib/libXThrStub.so.6: undefined reference to `_Xthr_zero_stub_'
	/usr/X11R6/lib/libXThrStub.so.6: undefined reference to `_Xthr_self_stub_'
	*** Error code 1
	Stop in /usr/ports/x11/xlockmore/work/xlockmore-5.06/modes.
	*** Error code 1


        nm -s libXThrStub.so.6 | grep _Xthr_zero_stub_
		 U _Xthr_zero_stub_
Comment 1 Tilman Keskinoz freebsd_committer freebsd_triage 2003-03-22 20:59:11 UTC
Responsible Changed
From-To: freebsd-ports-bugs->anholt

Over to X Maintainer
Comment 2 jimd 2003-03-23 22:19:02 UTC
Removed all X430src-x.tgz files. Portupgraded XFree86-Server-4.3.0 along 
with XFree86-clients-4.3.0, and previously reported libXTHrStub.so.6 
undefined references no longer appear. There may have been a change in 
the X430 source, or perhaps not. At any rate, the problem is "fixed" and 
the report may be closed.


======= from original problem and report ==============
cc -o appres -O3 -mcpu=pentiumpro -march=pentiumpro -ansi -Dasm=__asm 
-Wall -Wpointer-arith -Wundef 
-L/usr/ports/x11/XFree86-4-clients/work/xc/exports/lib
  appres.o -lXt -lSM -lICE -lXext -lX11 -L/usr/X11R6/lib 
-Wl,-rpath,/usr/X11R6/lib
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_cond_signal'
/usr/X11R6/lib/libXThrStub.so.6: undefined reference to `_Xthr_zero_stub_'
/usr/X11R6/lib/libX11.so: undefined reference to `pthread_cond_broadcast'
/usr/X11R6/lib/libXThrStub.so.6: undefined reference to `_Xthr_self_stub_'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_cond_init'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_mutex_unlock'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_self'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_mutex_destroy'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_mutex_lock'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_cond_wait'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_cond_destroy'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_mutex_init'
*** Error code 1

Stop in /usr/ports/x11/XFree86-4-clients/work/xc/programs/appres.
*** Error code 1

=========== from portupgrade done 23 March 2003 ===============
rm -f appres
cc -o appres -O3 -mcpu=pentiumpro -march=pentiumpro -ansi -Dasm=__asm 
-Wall -Wpointer-arith -Wundef 
-L/usr/ports/x11/XFree86-4-clients/work/xc/exports/lib
  appres.o -lXt -lSM -lICE -lXext -lX11 -L/usr/X11R6/lib 
-Wl,-rpath,/usr/X11R6/lib
rm -f appres._man
/usr/bin/cpp -undef -traditional 
-D__apploaddir__=/usr/X11R6/lib/X11/app-defaults -D__filemansuffix__=5 
-D__libmansuffix__=3 -D__miscmansuffix__=7 -D__drivermansuffix__=4 
-D__projectroot__=/usr/X11R6 -D__xorgversion__='"Release 6.6" "X Version 
11"' -D__vendorversion__="`echo 4 3 0 | sed -e 's/ /./g' -e 's/^/Version 
/'` XFree86"   <appres.man | sed -e '/^#  *[0-9][0-9]*  *.*$/d' -e 
'/^XCOMM$/s//#/' -e '/^XCOMM[^a-zA-Z0-9_]/s/^XCOMM/#/' >appres._man
rm -f appres.1.html appres.1-html
rman -f HTML < appres._man  > appres.1-html && mv -f appres.1-html 
appres.1.htmlmacro "in" not recognized -- ignoring
making all in programs/bdftopcf...
Comment 3 jimd 2003-03-23 22:24:45 UTC
Whilst the previous PR update on 23 March 2003 cited build output from 
XFree86-4-clients instead of Xlockmore, the same error (undefined 
reference in libXThrStub.so.6) occured with both ports. The 23 March 
2003 portupgrade of XFree86-4-clients also included a portupgrade of 
Xlockmore which was successful.

It appears that the resolution was the replacement of the XFree86 source 
distribution files.
Comment 4 jimd 2003-03-27 00:04:29 UTC
The reported problem has not been fully resolved.

On two 4.7 machines, the "remove-and-reinstall" of XFree86-4.3.0 has had 
different affects:

1) on the last reported problem, the R & R process worked as noted in 
the last, previous PR update

2) on another 4.7 machine, the R & R process failed.

Both hosts have been updated, as much as possible, with cvsup. The 
failure or success appears to depend on pth-2.0.0 (lpthread.20). In the 
success instance, pthread symbols are found in libXThrStub.so.6. In the 
failure instance, NO pthread symbols are found in libXThrStub.so.6, and 
the XFree86-4-Server build fails:

- - - - - - - - - - - - - - - - -
rm -f xf86cfg
LD_LIBRARY_PATH=/usr/ports/x11-servers/XFree86-4-Server/work/xc/exports/lib 
cc -o xf86cfg -O3 -mcpu=pentiumpro -march=pentiumpro 
-I/usr/local/include/pth -ansi -Dasm=__asm -Wall -Wpointer-arith -Wundef 
     -L/usr/ports/x11-servers/XFree86-4-Server/work/xc/exports/lib 
accessx.o        cards.o config.o        card-cfg.o      expert.o 
  help.o  interface.o     keyboard-cfg.o  libc_wrapper.o loader.o 
loadmod.o       monitor-cfg.o   mouse-cfg.o     options.o 
screen-cfg.o    screen.o        startx.o        stubs.o text-mode.o 
vidmode.o
xf86config.o -lxkbui -lxkbfile -lxf86config -lXxf86misc 
   -lXxf86vm -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11 -lXt -lSM -lICE 
            -lXpm
-L../loader -lxloader -L../dummylib -ldummy -rdynamic -lXext -lX11 -lncurses
            -lm -L/usr/X11R6/lib     -Wl,-rpath,/usr/X11R6/lib
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_cond_signal'
/usr/X11R6/lib/libXThrStub.so.6: undefined reference to `_Xthr_zero_stub_'
/usr/X11R6/lib/libX11.so: undefined reference to `__pthread_connect'
/usr/X11R6/lib/libX11.so: undefined reference to `__pthread_writev'
/usr/X11R6/lib/libX11.so: undefined reference to 
`pthread_cond_broadcast' 
                               /usr/X11R6/lib/libXThrStub.so.6: 
undefined reference to `_Xthr_self_stub_'
/usr/X11R6/lib/libX11.so: undefined reference to `__pthread_readv'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_cond_init'
/usr/X11R6/lib/libX11.so: undefined reference to `__pthread_poll'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_mutex_unlock'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_self'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_mutex_destroy'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_mutex_lock'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_cond_wait'
/usr/X11R6/lib/libX11.so: undefined reference to `__pthread_read'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_cond_destroy'
/usr/X11R6/lib/libX11.so: undefined reference to `__pthread_write'
/usr/X11R6/lib/libXt.so: undefined reference to `pthread_mutex_init'
*** Error code 1
 

Stop in 
/usr/ports/x11-servers/XFree86-4-Server/work/xc/programs/Xserver/hw/xfree86/xf86cfg.
*** Error code 1
- - - - - - - - - - - - - -

The "failing XFree86 update" /usr/X11R6/lib/libXThrStub.so.6 shows:

nm -s /usr/X11R6/lib/libXThrStub.so.6
00001590 A _DYNAMIC
00001650 A _GLOBAL_OFFSET_TABLE_
00001684 b _X_no_thread_id.3
          U _Xthr_self_stub_
          U _Xthr_zero_stub_
00001644 ? __CTOR_END__
00001640 ? __CTOR_LIST__
0000164c ? __DTOR_END__
00001648 ? __DTOR_LIST__
0000158c ? __EH_FRAME_BEGIN__
0000158c ? __FRAME_END__
0000166c A __bss_start
          w __deregister_frame_info
00000530 t __do_global_ctors_aux
00000464 t __do_global_dtors_aux
          w __register_frame_info
0000166c A _edata
00001688 A _end
0000057c T _fini
00000428 T _init
00001588 d completed.4
000004c8 t fini_dummy
0000158c d force_to_data
0000158c d force_to_data
000004e0 t frame_dummy
00000530 t gcc2_compiled.
00000464 t gcc2_compiled.
00000530 t gcc2_compiled.
00000518 t init_dummy
00000564 t init_dummy
0000166c b object.11
00001584 d p.3


Whereas the "successful R & R" update shows the pthread symbols for 
/usr/X11R6/lib/libXThrStub.so.6:

  nm -s /usr/X11R6/lib/libXThrStub.so.6
000017b8 A _DYNAMIC
00001878 A _GLOBAL_OFFSET_TABLE_
000018ac b _X_no_thread_id.3
00000734 t _Xthr_self_stub_
00000750 t _Xthr_zero_stub_
0000186c ? __CTOR_END__
00001868 ? __CTOR_LIST__
00001874 ? __DTOR_END__
00001870 ? __DTOR_LIST__
000017b4 ? __EH_FRAME_BEGIN__
000017b4 ? __FRAME_END__
00001894 A __bss_start
          w __deregister_frame_info
00000758 t __do_global_ctors_aux
00000668 t __do_global_dtors_aux
          w __register_frame_info
00001894 A _edata
000018b0 A _end
000007a4 T _fini
0000062c T _init
000017b0 d completed.4
000006cc t fini_dummy
000017b4 d force_to_data
000017b4 d force_to_data
000006e4 t frame_dummy
00000734 t gcc2_compiled.
00000758 t gcc2_compiled.
00000668 t gcc2_compiled.
0000078c t init_dummy
0000071c t init_dummy
00001894 b object.11
000017ac d p.3
00000750 W pthread_cond_broadcast
00000750 W pthread_cond_destroy
00000750 W pthread_cond_init
00000750 W pthread_cond_signal
00000750 W pthread_cond_wait
00000750 W pthread_getspecific
00000750 W pthread_key_create
00000750 W pthread_mutex_destroy
00000750 W pthread_mutex_init
00000750 W pthread_mutex_lock
00000750 W pthread_mutex_unlock
00000734 W pthread_self
00000750 W pthread_setspecific

I have tried both portupgrade and manual make multiple times, but the 
result is the same in the "failing situation". In both cases, I have the 
  same version of pth-2.0.0 installed, but I can't seem to find 
where/how  /usr/X11R6/lib/libXThrStub.so.6 gets linked with 
/usr/local/lib/pth/libpthread.so.20.
Comment 5 jimd.NOSPAM 2003-03-27 03:08:39 UTC
I just did an XFree86-4-library recompile on the host without the pthread
references in libXThrStub.so.6, and said library NOW has the pthread symbols!

ALL that I did was:

ln -s /usr/local/lib/libgthread-2.0.so.200 /usr/local/lib/libgthread-2.0.so.0


Here is what I had beforehand:

ll /usr/local/lib/libgthread*
-rw-r--r--  1 root  wheel  12824 Feb 15 13:26 /usr/local/lib/libgthread-2.0.a
lrwxrwxr-x  1 root  wheel     21 Feb 15 13:26 /usr/local/lib/libgthread-2.0.so -> libgthread-2.0.so.200
-rwxr-xr-x  1 root  wheel  17766 Feb 15 13:26 /usr/local/lib/libgthread-2.0.so.200
-rw-r--r--  1 root  wheel   5526 Jan 23 10:46 /usr/local/lib/libgthread12.a
lrwxr-xr-x  1 root  wheel     17 Jan 23 10:46 /usr/local/lib/libgthread12.so ->
libgthread12.so.3
-rwxr-xr-x  1 root  wheel   9712 Jan 23 10:46 /usr/local/lib/libgthread12.so.3


The newly compiled libXThrStub.so.6 now shows a larger filesize:

pwd
/usr/ports/x11/XFree86-4-libraries/work/xc/lib/XThrStub
xxxxx/root: ll
total 100
-rw-rw-r--  1 root  wheel    661 Mar 27 02:58 .depend
-rw-r--r--  1 root  wheel    759 Dec 20  1998 Imakefile
-rw-rw-r--  1 root  wheel  28872 Mar 27 02:57 Makefile
-rw-r--r--  1 root  wheel   6398 Jan 14 20:55 UIThrStubs.c
-rw-rw-r--  1 root  wheel   1384 Mar 27 02:58 UIThrStubs.o
lrwxrwxr-x  1 root  wheel     18 Mar 27 02:58 libXThrStub.so -> libXThrStub.so.6.1
lrwxrwxr-x  1 root  wheel     18 Mar 27 02:58 libXThrStub.so.6 -> libXThrStub.so.6.1
-rwxrwxr-x  1 root  wheel   5243 Mar 27 02:58 libXThrStub.so.6.1


and the library now contains pthread symbols:

nm -s libXThrStub.so.6.1
000017b8 A _DYNAMIC
00001878 A _GLOBAL_OFFSET_TABLE_
000018ac b _X_no_thread_id.3
00000734 t _Xthr_self_stub_
00000750 t _Xthr_zero_stub_
0000186c ? __CTOR_END__
00001868 ? __CTOR_LIST__
00001874 ? __DTOR_END__
00001870 ? __DTOR_LIST__
000017b4 ? __EH_FRAME_BEGIN__
000017b4 ? __FRAME_END__
00001894 A __bss_start
         w __deregister_frame_info
00000758 t __do_global_ctors_aux
00000668 t __do_global_dtors_aux
         w __register_frame_info
00001894 A _edata
000018b0 A _end
000007a4 T _fini
0000062c T _init
000017b0 d completed.4
000006cc t fini_dummy
000017b4 d force_to_data
000017b4 d force_to_data
000006e4 t frame_dummy
00000734 t gcc2_compiled.
00000758 t gcc2_compiled.
00000668 t gcc2_compiled.
0000078c t init_dummy
0000071c t init_dummy
00001894 b object.11
000017ac d p.3
00000750 W pthread_cond_broadcast
00000750 W pthread_cond_destroy
00000750 W pthread_cond_init
00000750 W pthread_cond_signal
00000750 W pthread_cond_wait
00000750 W pthread_getspecific
00000750 W pthread_key_create
00000750 W pthread_mutex_destroy
00000750 W pthread_mutex_init
00000750 W pthread_mutex_lock
00000750 W pthread_mutex_unlock
00000734 W pthread_self
00000750 W pthread_setspecific
Comment 6 J.D. 2003-04-02 05:23:52 UTC
On Wed, 02 Apr 2003 04:06:27 +0000, none wrote:

> It may be that you have an X11 installation that is missing some pthread
> linkage. If your /usr/X11R6/lib/libXThrStub.so.6 file is about 4230 bytes
> then it may not include pthread symbols such as:
> 
> 00001894 b object.11
> 000017ac d p.3
> 00000750 W pthread_cond_broadcast
> 00000750 W pthread_cond_destroy
> 00000750 W pthread_cond_init
> 00000750 W pthread_cond_signal
> 00000750 W pthread_cond_wait
> 00000750 W pthread_getspecific
> 00000750 W pthread_key_create
> 00000750 W pthread_mutex_destroy
> 00000750 W pthread_mutex_init
> 00000750 W pthread_mutex_lock
> 00000750 W pthread_mutex_unlock
> 00000734 W pthread_self
> 00000750 W pthread_setspecific
> 
> An nm -s on the library will confirm this. If the results end with "d
> p.3", then something failed to link in the appropriate pthread symbols
> (which results in a library file size of about 5243 bytes from what I have
> seen).
> 
> IF this is the case, of incomplete thread linkage, THEN Configure test
> compiles which request "-lX11" may/will probably fail NOT because the
> X11.so file can't be found, BUT because the linker step in the test
> compile fails as a result of missing thread symbols in
> /usr/X11R6/lib/libXThrStub.so.6 (or another library). This can be
> confirmed by looking at the "config.log" file in a port's work (build)
> directory.
> 
> For reasons that I have yet to figure out, I have had beaucoup problems
> with /usr/X11R6/lib/libXThrStub.so.6 in XFree86-4.3.0 ports. In one X11
> port compile, I did get the thread linkage, but in over a dozen other port
> compiles, I did not. On one system, I finally gave in and went out and
> found a pre-compiled binary of the 4.3.0 XFree86 libraries, clients, and
> server, and installed them. They had thread linkage in
> /usr/X11R6/lib/libXThrStub.so.6, and further port compiles would then
> succeed.
> 
> 
> On Tue, 01 Apr 2003 13:14:35 +0000, Mike B wrote:
> 
>> Yes I have x11 in stalled and it works quite well. I was thinking that
>> perhaps it should be '-l X11'. The only problem is grepping that line
>> out, as I have no clue which source file it belongs to. Thanks.
>> 
>> Mike
>> 
>> Thierry Herbelot wrote:
>>> Hello,
>>> 
>>> Mike B wrote:
>>> 
>>> 
>>>>I'm having a bit of trouble building jdk1.4.1 on FreeBSD 4.8RC. After
>>>>compiling for about 6-8 hrs on my old machine in stops with this error
>>>>message.
>>>>
>>>>6/lib -lX11    -pthread -pthread
>>>>/usr/libexec/elf/ld: cannot find -lX11
>>> 
>>> 
>>> -lX11 is most likely a linker command used to link the jdk witk an X11
>>> (X-Windows / XFrre86) library. have you installed the XFree ports ?
>>> 
>>>         TfH
Comment 7 Eric Anholt freebsd_committer freebsd_triage 2003-04-06 10:04:02 UTC
State Changed
From-To: open->closed

Submitter had unsupported -O3 optimizations in compiling XFree86, which is  
known to cause this problem.
Comment 8 jimd 2003-04-06 13:35:08 UTC
May I ask whether it is XFree86 that doesn't support -O3 or something else.
GCC-2.95.4 does support this option and other ports/independent applications
have been compiled with -O3 and execute without any noticable problem.

Thank you.


On  6 Apr, Eric Anholt wrote:
> Synopsis: libXThrStub.so.6 has undefined references
> 
> State-Changed-From-To: open->closed
> State-Changed-By: anholt
> State-Changed-When: Sun Apr 6 01:04:02 PST 2003
> State-Changed-Why: 
> Submitter had unsupported -O3 optimizations in compiling XFree86, which is 
> known to cause this problem.
> 
> http://www.freebsd.org/cgi/query-pr.cgi?pr=50161
Comment 9 Eric Anholt freebsd_committer freebsd_triage 2003-04-06 20:40:12 UTC
On Sun, 2003-04-06 at 05:35, jimd@siu.edu wrote:
> May I ask whether it is XFree86 that doesn't support -O3 or something else.
> GCC-2.95.4 does support this option and other ports/independent applications
> have been compiled with -O3 and execute without any noticable problem.
> 
> Thank you.

I mean that we do not offer support (in terms of fixing things for you)
for higher optimization levels.  make.conf says it for kernel+world but
that should apply even more so to ports:

# CFLAGS controls the compiler settings used when compiling C code.
# Note that optimization settings above -O (-O2, ...) are not recommended
# or supported for compiling the world or the kernel - please revert any
# nonstandard optimization settings to "-O" before submitting bug reports
# to the developers.
# Note also that at this time the -O2 setting is known to produce BROKEN
# CODE on the Alpha platform.
#
#CFLAGS= -O -pipe

If you submitted a patch that fixed the problem and explained why the
fix was correct, I would probably apply it.

-- 
Eric Anholt                                eta@lclark.edu          
http://people.freebsd.org/~anholt/         anholt@FreeBSD.org