This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: duplicate regexec/regcomp functions detected


> From: "Ralf Habacker" <Ralf.Habacker@freenet.de>
> >
> > No, only the symbols, which are defined in pthread.o, called the
> "reflib" in speclib.
>
> That will be an incomplete list of symbols then, as I've been removing
> them from pthread.o - there is (a minor) performance hit with the
> redirection, and the pthread functions tend to be part of the critical
> performance path when they are used.
>
No I'm recognized, that we are speaking about two different things. May be that I have
doesn't told clearly enough, so I like to resume.

At first I'm stumbled about the curious link line with the multiple defined main in the qt
lib, chris and I have spoken over.

After thinking about this problem a while I had an idea how to solve such problems instead of
using simple links from libcygwin.a to libpthread.a and other.
The idea was to use the cygwin1.dll as used currently, but to build only several import libs
(!) for special libs like libpthread and may me libm and libc.

The advantage of doing this is, this allows a very flexible way of using. Someone could use
the libcygwin.a for all needs functions regardless if they original belongs to libc libm or
libpthread.
Someone how like to use libpthread, libm, libc and may be other can use the belonging import
libraries (remember not the function or vars, the functions are located in cygwin1.dll) and
can link.

A second advantage of this concept is, that if there is a future need to split some functions
from cygwin1.dll to a seperate dll or static lib, the import libraries, which the users are
link to, are the same as now.  Only the backend was changed. This simplificates further
development of the whole emulation layer without and noticable changes to the user (except an
new compiling)

So the concept has a two level structure. The top level are the import libraries, the bottom
level are one or more dll's and perhaps static lib.

The task for doing so (for libpthread) is to look which functions of the pthread library are
exported (decribed in pthread.h and relating headers, but I think it is only the one). This
is done by scanning  pthread.o with nm for every exported symbol. (The consequence for this
is, that only this symbols are has to be exported)

Then search cygdll.a after those symbols and extract only the relevant d000xxx.o from
cygdll.a to a newly created import library named libpthread.a or other revelant name.

Doing like this (extraxting d000xxx-files from cygdll) has an extra advantage relating to the
auto-import feature. If cygwin1.dll perhaps contains auto-imported vars, than using the
d0000xxx files extract the import thunks too and there is no need to change this concept.

The patch I have supplied, does exactly this and seems to me ready with the on exception of
locating file dirs (identifiable on "$PWD.."), i have told about.

speclib
-----------------------------------------------------------------------------
#!/bin/sh
#
# create specific link library for libpthread using symbols from libcygwin.a
#
inlib=$1; shift		# cygdll.a
reflib=$1; shift		# pthread.o
outlib=$1; shift		# libpthread.a
nm=$1; shift
ar=$1; shift
ranlib=$1; shift

tmpdir=slibtmp.dir

# collect needed symbols
SYMBOLS=`nm $reflib | grep "[TD] _" | gawk '{ print $3 }'`

# build awk script to extract d000xxx files
SCRIPT='$1 ~ /^d00/ { file = $1; gsub(":","",file); }'

for i in $SYMBOLS; do
	SCRIPT="$SCRIPT \$3 ~ /^$i/ { print file; }"
done

# remove previous link library
rm -f $outlib

# collect all d000xxx files from $inlib (cygdll.a)
FILES=`$nm $PWD/$inlib | gawk "$SCRIPT"`

# extract related object files
mkdir $tmpdir
cd $tmpdir
$ar x $PWD/$inlib $FILES
cd ..

# create new link library for pthread
$ar cru $PWD/$outlib $tmpdir/*.o
$ranlib $PWD/$outlib

# remove temporay files
rm -fr $tmpdir
-----------------------------------------------------------------------------

I hope I have written clearly enough and I'm sorry for an confusion, I'm responsible. So if
there an questions, please let me know.

BTW: I wish you all a happy new year.

Regards
Ralf



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]