Mail Archives: cygwin/2001/12/29/14:02:07
------=_NextPart_000_002D_01C190A3.3B9F5010
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
> -----Original Message-----
> From: cygwin-owner AT cygwin DOT com [mailto:cygwin-owner AT cygwin DOT com]On Behalf
> Of Christopher Faylor
> Sent: Friday, December 28, 2001 6:50 PM
> To: cygwin AT cygwin DOT com
> Subject: Re: duplicate regexec/regcomp functions detected
>
>
> On Fri, Dec 28, 2001 at 12:14:04PM +0100, Ralf Habacker wrote:
> >> >gcc -o test -lpthread main.o [-lcygwin]
> >> >
> >> >This will result in multiple defined symbols for WinMain (expected that
> >> >main.o contains a main function). You can say don't do this, but what
> >> >about bigger packages like qt. The qt configuring process does only
> >> >allow like the above link line.
> >>
> >> The above link line makes no sense. It is wrong. It should be
> >> corrected.
> >
> >May be, but I think you know some combinations that are real. what is
> >with this ?
>
> The above command line is just bogus. The -lpthread before the main.o
> is wrong. If you are going to choose an example choose one that makes
> sense.
This was a real example, I've found in the qt library and has the intention to show that
>
> >Assume main.o needs to be linked to the pcreposix lib.
> >
> >gcc -o test main.o -lpthread -lpcreposix
> >
> >or this if main needs to be linked to the regex lib.
> >
> >gcc -o test main.o -lpthread -lregex
> >
> >This will fail and the users have to figure out deeply why this does
> >not work. Isn't it ?
>
> I assume that by "fail" you mean that the functions from the regex
> library will not be used. Well, the good news is that this won't be an
> issue for cygwin 1.3.7. The newer regex functions will be part of
> the cygwin DLL. libregex.a will either be nonexistent or it will
> be an empty stub.
>
> The inclusion of the pthread library in the cygwin distribution was
> recent. It solved some configuration issues. It is no different
> from the libm.a "problem". I'm not going to remove libpthread.a any
> more than I am going to remove libm.a.
>
> If you want to implement your idea of a libpthread.a with specific
> pthread imports, then I'm willing to look at a patch. Otherwise, there
> will be no changes in cygwin 1.3.7.
>
> >The result of this is, that the packager of the pcre and the regex
> >package have to add a note in their documentation that their lib must
> >be the first lib before -lg or -lpthread and perhaps more libs in the
> >future. Make this sense ?
>
> That people should document system dependencies? Sure.
>
> Why do you think libm.a, libg.a, libc.a, libpthread.a are even in the
> cygwin distribution? Does it make sense to *you* that they are there to
> solve some problems?
> There are many many compromises in cygwin. Every single time we make
> a decision to do something one way, someone will step forward to tell
> us how it screwed them up and suggest that we revert to the previous
> behavior. Rarely is there any indication that anyone is thinking about
> the big picture, however. Is your problem more generic than the problem
> that the inclusion of libpthread.a was meant to solve? I don't think
> it is.
>
> I could be wrong, but I think this is the first complaint I've heard
> about libpthread.a. The same complaint could be levelled at libm.a.
> The simple fact of life is that library inclusion order does matter.
> Cygwin is not the only system that suffers from issues like this.
>
Of course, but it should be kept easy as it is possible.
But remember the above example
gcc -o test -lpthread main.o [-lcygwin]
This isn't a good example, but it causes linkage errors seeming without any logic.
When I'm linking to libpthread, than I don't expect to have multiple "main" symbols and this
"don't do that", if have often heard in the past.
I think robust software, as this I have experienced open software, should as much as possible
should produc
predictable results and especially error messages.
> However, luckily, if this matters to you, you can submit a patch to fix
> it. I think that the place to start would be winsup/Makefile.in.
>
The patch for creating libpthread.a is appended. It contains a script names "speclib" and an
additional rule in the src/winsup/cygwin/Makefile.in.
The script exports symbols from an object file or lib and lookup the cygwin import library
for the related
object files, which are be extracted and are used to build the new archive.
The script allows to create any special lib like libc or libm, but I haven't checked this,
because currently I does not know enough about libc/m integration in cygwin to say, if this
work.
A snippet of the Makefile.in show how the script is called:
$(LIBPTHREAD_A): speclib new-$(DLL_NAME)
/bin/sh ${word 1,$^} cygdll.a pthread.o $@ "$(NM)" "$(AR)" "$(RANLIB)" || exit 0
@echo create $(LIBPTHREAD_A)
speclib <cygwinlib> <used lib or objectfile> <outputlib> <nm tool> <ar tool> <ranlib tool>
cygwinlib
- name of the basic cygwin import library, of which the nessesary objectfiles are used to
create the new import library
used lib or objectfile
- name of the library or objectfile of which the symbols (T or D) are used
outputlib
- the name of the created lib
nm tool - like rmsym script
ar tool - like rmsym script
ranlib tool - like rmsym script
Regards
Ralf
------=_NextPart_000_002D_01C190A3.3B9F5010
Content-Type: application/octet-stream;
name="Makefile.in.dif"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="Makefile.in.dif"
Index: Makefile.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/src/src/winsup/cygwin/Makefile.in,v
retrieving revision 1.75
diff -u -b -B -p -r1.75 Makefile.in
--- Makefile.in 2001/12/26 05:02:07 1.75
+++ Makefile.in 2001/12/29 18:54:24
@@ -100,6 +100,9 @@ DLL_ENTRY:=3D AT DLL_ENTRY@
LIBGMON_A:=3Dlibgmon.a
GMON_START:=3Dgcrt0.o
+LIBPTHREAD_A:=3Dlibpthread.a
+
+
# Some things want these from libc, but they have their own static
# data which apps can get to, which is a pain in the dll, so we
# include them directly into the library.
@@ -152,7 +155,7 @@ install_host=3D AT install_host@
all: all_target $(all_host)
-all_target: $(LIB_NAME) automode.o binmode.o textmode.o $(LIBGMON_A)
+all_target: $(LIB_NAME) automode.o binmode.o textmode.o $(LIBGMON_A) =
$(LIBPTHREAD_A)
all_host: new-$(LIB_NAME) cygrun.exe
@@ -160,9 +163,9 @@ force:
install: install-libs install-headers install-man $(install_host) =
$(install_target)
-install-libs: $(LIB_NAME)
+install-libs: $(LIB_NAME) $(LIBPTHREAD_A)
$(INSTALL_DATA) new-$(DLL_NAME) $(bindir)/$(DLL_NAME); \
- for i in $(LIB_NAME) $(GMON_START) $(LIBGMON_A) automode.o =
binmode.o textmode.o ; do \
+ for i in $(LIB_NAME) $(LIBPTHREAD_A) $(GMON_START) $(LIBGMON_A) =
automode.o binmode.o textmode.o; do \
$(INSTALL_DATA) $$i $(tooldir)/lib/$$i ; \
done
@@ -202,7 +205,8 @@ maintainer-clean realclean: clean
# Rule to build cygwin.dll
-new-$(DLL_NAME): $(LDSCRIPT) $(DLL_OFILES) $(DEF_FILE) $(DLL_IMPORTS) =
$(LIBC) $(LIBM) Makefile winver_stamp
+new-$(DLL_NAME): $(LDSCRIPT) $(DLL_OFILES) $(DEF_FILE) $(DLL_IMPORTS) =
$(LIBC) $(LIBM) winver_stamp
+#new-$(DLL_NAME): $(LDSCRIPT) $(DLL_OFILES) $(DEF_FILE) $(DLL_IMPORTS) =
$(LIBC) $(LIBM) Makefile winver_stamp
$(CXX) $(CXXFLAGS) -nostdlib -Wl,-T$(firstword $^) =
-Wl,--out-implib,cygdll.a -shared -o $@ \
-e $(DLL_ENTRY) $(DEF_FILE) $(DLL_OFILES) version.o winver.o \
$(DLL_IMPORTS) $(MALLOC_OBJ) $(LIBM) $(LIBC) \
@@ -213,6 +217,11 @@ $(LIB_NAME): rmsym newsym new-$(DLL_NAME
/bin/sh ${word 1,$^} ./cygdll.a "$(NM)" "$(AR)" "$(RANLIB)" =
$(OBSOLETE_FUNCTIONS) || exit 0
/bin/sh ${word 2,$^} ./cygdll.a "$(AS)" "$(AR)" "$(RANLIB)" =
$(NEW_FUNCTIONS) || exit 0
(echo create $(LIB_NAME); echo addmod $(LIBCOS); echo addlib =
cygdll.a; echo save) | $(AR) -M
+
+# Rule to build lib_pthread.a
+$(LIBPTHREAD_A): speclib new-$(DLL_NAME)
+ /bin/sh ${word 1,$^} cygdll.a pthread.o $@ "$(NM)" "$(AR)" =
"$(RANLIB)" || exit 0
+ @echo create $(LIBPTHREAD_A)
# Rule to make stub library used by testsuite
# dependency set to $(LIB_NAME) to accommodate make -j2.
------=_NextPart_000_002D_01C190A3.3B9F5010
Content-Type: application/octet-stream;
name="speclib"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="speclib"
#!/bin/sh
#
# create specific link library for libpthread using symbols from libcygwin.a
#
inlib=$1; shift
reflib=$1; shift
outlib=$1; shift
nm=$1; shift
ar=$1; shift
ranlib=$1; shift
tmpdir=slibtmp.dir
# awk script for extracing related object files
SYMBOLS=`nm $reflib | grep "[TD] _" | gawk '{ print $3 }'`
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
# extract related object files
FILES=`$nm $PWD/$inlib | gawk "$SCRIPT"`
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
------=_NextPart_000_002D_01C190A3.3B9F5010
Content-Type: text/plain; charset=us-ascii
--
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/
------=_NextPart_000_002D_01C190A3.3B9F5010--
- Raw text -