The Return of Revenge of Son of the Speclib Strikes Back :)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

The Return of Revenge of Son of the Speclib Strikes Back :)

Dave Korn-6
[ Let's try again in the right place, shall we? ]

  The new speclibs libraries work great, but there's one piece of
unanticipated fallout: the libtool func_win32_libid() tests can no longer
identify them as import libraries.  Which is fair enough, since they aren't,
they are now indirect references to import libraries; but we want it to treat
them the same anyway.

  Here's one possible approach: I add a dummy member to the archives just in
order to trip libtool's "nm | grep ' I '" test.  I repurposed the
as-far-as-I-can-tell currently unused "--static" option to speclib to mean
"bodily shove this object into the generated library".

  As usual, I don't speak perl good, which is why I add $static to the
%extract hash before invoking ar and remove it again afterward.  If I just
unconditionally tagged ", $static" on the end of the invocation, it would fail
if no --static option was supplied, giving ar an empty string as an argv
member, and I didn't know how to conditionally add it as an argument only when
defined, so it was either this or cut-and-paste two versions of the
invocation, one mentioning $static and the other not, with an if defined
$static to choose between them; I would welcome being shown a better way to do
this if there is one.

  I'm currently putting the attached through a full build / install/ rebuild
DLL, binutils and gcc cycle, but it already fixed the failure to build libjava
as a DLL that I've been getting on GCC HEAD with the new speclib libraries.

  What do you think?  Reasonable approach?  Reasonable implementation?
Problems with either?  Ok for head?

winsup/cygwin/ChangeLog

        * magicimportsym.s:  New file.
        * Makefile.in (speclib):  Add --static option to invocation
        naming magicimportsym.o
        (${CURDIR}/libc.a):  Add magicimportsym.o to dependencies.
        (${CURDIR}/libm.a):  Likewise.
        (libpthread.a):  Likewise.
        (libutil.a):  Likewise.
        (libdl.a):  Likewise.
        (libresolv.a):  Likewise.
        * speclib:  Repurpose --static option to add an archive member
        unconditionally.

    cheers,
      DaveK



Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/Makefile.in,v
retrieving revision 1.225
diff -p -u -r1.225 Makefile.in
--- Makefile.in 12 Apr 2009 04:14:31 -0000 1.225
+++ Makefile.in 18 Apr 2009 13:33:03 -0000
@@ -112,6 +112,7 @@ speclib=\
  --exclude='(?i:dll)' \
  --exclude='reloc' \
  --exclude='^_main$$' \
+ --static=magicimportsym.o \
  $^
 
 # Some things want these from libc, but they have their own static
@@ -439,22 +440,22 @@ shared.o: shared_info_magic.h
 $(srcdir)/devices.cc: gendevices devices.in devices.h
  ${wordlist 1,2,$^} $@
 
-${CURDIR}/libc.a: ${LIB_NAME} ./libm.a libpthread.a libutil.a
+${CURDIR}/libc.a: ${LIB_NAME} ./libm.a libpthread.a libutil.a magicimportsym.o
  ${speclib} -v ${@F}
 
-${CURDIR}/libm.a: ${LIB_NAME} $(LIBM)
+${CURDIR}/libm.a: ${LIB_NAME} $(LIBM) magicimportsym.o
  ${speclib} ${@F}
 
-libpthread.a: ${LIB_NAME} pthread.o thread.o
+libpthread.a: ${LIB_NAME} pthread.o thread.o magicimportsym.o
  ${speclib} ${@F}
 
-libutil.a: ${LIB_NAME} bsdlib.o
+libutil.a: ${LIB_NAME} bsdlib.o magicimportsym.o
  ${speclib} ${@F}
 
-libdl.a: ${LIB_NAME} dlfcn.o
+libdl.a: ${LIB_NAME} dlfcn.o magicimportsym.o
  ${speclib} ${@F}
 
-libresolv.a: ${LIB_NAME} minires.o
+libresolv.a: ${LIB_NAME} minires.o magicimportsym.o
  ${speclib} ${@F}
 
 ${EXTRALIBS}: lib%.a: %.o
Index: magicimportsym.s
===================================================================
RCS file: magicimportsym.s
diff -N magicimportsym.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ magicimportsym.s 18 Apr 2009 13:33:03 -0000
@@ -0,0 +1,21 @@
+/* magicimportsym.s
+
+   Copyright 2009 Red Hat, Inc.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+/* In order for libtool to identify the speclib-generated libraries
+   as being import libraries, (which they aren't technically, but
+   serve in the stead of import libraries for our purposes), we need
+   to ensure there is at least one symbol tagged as an import symbol
+   when they are dumped with nm.  This file adds that required import,
+   in a dummy member that we expect never to be actually pulled into
+   any final link.
+*/
+
+ .section .idata$7
+ .global ____dummy_libspecmagic_a_iname
+____dummy_libspecmagic_a_iname: .asciz "magic_speclib_import_library"
+
Index: speclib
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/speclib,v
retrieving revision 1.20
diff -p -u -r1.20 speclib
--- speclib 12 Apr 2009 05:11:08 -0000 1.20
+++ speclib 18 Apr 2009 13:33:03 -0000
@@ -12,10 +12,11 @@ my $inverse;
 my @exclude;
 
 my ($ar, $as, $nm, $objcopy);
-GetOptions('exclude=s'=>\@exclude, 'static!'=>\$static, 'v!'=>\$inverse,
+GetOptions('exclude=s'=>\@exclude, 'static=s'=>\$static, 'v!'=>\$inverse,
    'ar=s'=>\$ar, 'as=s'=>\$as,'nm=s'=>\$nm, 'objcopy=s'=>\$objcopy);
 
 $_ = File::Spec->rel2abs($_) for @ARGV;
+$static = File::Spec->rel2abs($static) if defined($static);
 
 my $libdll = shift;
 my $lib =  pop;
@@ -50,7 +51,9 @@ chdir $dir;
 my $res = system $ar, 'x', $libdll, sort keys %extract;
 die "$0: $ar extraction exited with non-zero status\n" if $res;
 unlink $lib;
+$extract{$static} = 1 if defined($static);
 $res = system $ar, 'crus', $lib, sort keys %extract;
+delete $extract{$static} if defined($static);
 unlink keys %extract;
 die "$0: ar creation of $lib exited with non-zero status\n" if $res;
 exit 0;

Reply | Threaded
Open this post in threaded view
|

Re: The Return of Revenge of Son of the Speclib Strikes Back :)

Christopher Faylor-8
On Sat, Apr 18, 2009 at 02:53:37PM +0100, Dave Korn wrote:
>[ Let's try again in the right place, shall we? ]

Now more tempest with even less teapot!

>The new speclibs libraries work great, but there's one piece of
>unanticipated fallout: the libtool func_win32_libid() tests can no
>longer identify them as import libraries.  Which is fair enough, since
>they aren't, they are now indirect references to import libraries; but
>we want it to treat them the same anyway.

I can guess why that is, but it would be nice if you didn't jump right
to a solution and provided more details.

>As usual, I don't speak perl good,

So, please don't bother sending perl patches.  I can get enough out of
the description of what is wrong and what your possible solution might
be to figure out what needs to be done without seeing your
proof-of-concept.

I checked something in which adds a dummy object custom-tailored to the
each library.

Thanks for the report.

cgf
Reply | Threaded
Open this post in threaded view
|

Re: The Return of Revenge of Son of the Speclib Strikes Back :)

Dave Korn-6
Christopher Faylor wrote:
> On Sat, Apr 18, 2009 at 02:53:37PM +0100, Dave Korn wrote:

>> The new speclibs libraries work great, but there's one piece of
>> unanticipated fallout: the libtool func_win32_libid() tests can no
>> longer identify them as import libraries.  Which is fair enough, since
>> they aren't, they are now indirect references to import libraries; but
>> we want it to treat them the same anyway.
>
> I can guess why that is, but it would be nice if you didn't jump right
> to a solution and provided more details.

  Sorry, thought that might be enough.  For the sake of the archives:  We want
to treat these as import libraries, because otherwise libtool says:

*** Warning: linker path does not have real file for library -ldl.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libdl and none of the candidates passed a file format test
*** using a file magic. Last file checked: /lib/libdl.a

  We do in fact have a shared version of the library, since anything in a
speclib library refers to a function in the Cygwin DLL.  But because the stubs
in the speclib libraries only indirect to the actual import symbol, libtool
doesn't realise this; the library itself doesn't import anything, and
libtool's test is based on grepping the output of nm to look for a symbol with
" I " in the type field.

>> As usual, I don't speak perl good,
>
> So, please don't bother sending perl patches.  I can get enough out of
> the description of what is wrong and what your possible solution might
> be to figure out what needs to be done without seeing your
> proof-of-concept.

  Well, it's either harmless extra information, or it will actually clarify
any ambiguities that might exist in my description, so it can't hurt and may
in the event that I mis-speak actually do some good.  There's certainly not
supposed to be any obligation on you to debug it or anything.

> I checked something in which adds a dummy object custom-tailored to the
> each library.
>
> Thanks for the report.

  Thanks for the fix!

    cheers,
      DaveK