bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: texinfo-6.0.91 pretest


From: Eli Zaretskii
Subject: Re: texinfo-6.0.91 pretest
Date: Fri, 01 Jan 2016 16:36:42 +0200

> Date: Fri, 1 Jan 2016 12:31:15 +0000
> From: Gavin Smith <address@hidden>
> Cc: Texinfo <address@hidden>
> 
> > When linking a shared library on MS-Windows, one needs to pass the
> > '-no-undefined' switch to libtool.  I hacked
> > tp/Texinfo/Convert/XSParagraph/Makefile.in to add -no-undefined to
> > LDFLAGS to solve that.
> 
> I see we had this problem before
> (https://lists.gnu.org/archive/html/texinfo-devel/2015-07/msg00054.html).

Right.

> Is this the right fix? -
> 
> Index: Makefile.am
> ===================================================================
> --- Makefile.am (revision 6893)
> +++ Makefile.am (working copy)
> @@ -78,14 +78,14 @@
> 
>  XSParagraph_la_CFLAGS += -DVERSION=\"$(VERSION)\"
> -DXS_VERSION=\"$(XSPARAGRAPH_INTERFACE_VERSION)\"  "-I$(PERL_INC)"
> 
> -XSParagraph_la_LDFLAGS=-avoid-version -module $(PERL_CONF_cccdlflags)
> +XSParagraph_la_LDFLAGS=-no-undefined -avoid-version -module
> $(PERL_CONF_cccdlflags)
> 
> 
>  TestXS_la_CFLAGS = $(PERL_CONF_ccflags)
> 
>  TestXS_la_CFLAGS += -DVERSION=\"$(VERSION)\"
> -DXS_VERSION=\"$(VERSION)\"  "-I$(PERL_INC)"
> 
> -TestXS_la_LDFLAGS=-module $(PERL_CONF_cccdlflags)
> +TestXS_la_LDFLAGS=-no-undefined -module $(PERL_CONF_cccdlflags)

Looks OK, thanks.

> > The next problem was with linking TestXS as a shared library.  Because
> > no undefined references are allowed when linking a shared library on
> > MS-Windows, the linker needs to see an import library which tells it
> > where to find the Perl functions at run time.  This library is found
> > like this:
> >
> >     perl -V:libperl
> >
> > The result is a file name, like libperl520.a, with no leading
> > directories, so one needs also the suitable linker flags before that,
> > which can be obtained with
> >
> >     perl -V:ldflags
> >
> > The result (after converting it in fetch_conf) should be added to the
> > value of PERL_CONF_cccdlflags.
> >
> > Finally, libperl520.a should be converted into -lperl520, otherwise
> > libtool claims that it is being told to link against a static library,
> > and refuses to create a shared library for TestXS again.
> 
> When I do perl -V:libperl, I get:
> 
> libperl='libperl.so';
> 
> which is a dynamic library. I take it that the "import library" should
> indeed be a static library?

Yes, it's a static library.  I think this change should be Windows
specific.

> Is the conversion just to stop libtool from quitting, and
> libperl520.a is in fact the library file that is linked to?

Yes.  Libtool is trying to be too smart here, IMO.

> The Perl API has an "IV" typedef which I expect is 64 bits on your
> system. Maybe it needs to be used instead of "int" somewhere. The two
> source files XSParagraph.xs and xspara.c use some of the Perl API
> functions (hv_fetch, SvIV in xspara.c, more in XSParagraph.xs). I
> looked through both of those source files but couldn't see where it
> could go wrong. I would expect the Perl header files that those files
> include would include prototypes that would check that the right types
> were being passed in and/or take care of type conversions. For
> example, a line like
> 
>        RETVAL = newSVpv (retval, 0);
> 
> The second argument 0 is of type 'int' in the code, and there should
> be a header saying that the type of the argument is STRLEN (another
> Perl typedef), and there should be an automatic conversion (likely
> from a 32-bit int to a 64-bit unsigned int).

There is indeed a definition of STRLEN, but my reading of the headers
is that it's eventually defined to size_t, which is a 32-bit type with
a 32-bit GCC.

> Did you get any compiler warnings about "implicit function declarations"?

No, none.  But should I expect any, given the compiler flags?

> Perhaps try loading the module without using any of its functions
> (e.g. put "use Texinfo::Convert::Paragraph" in texi2any.pl to load the
> module unconditionally) and then run "./texi2any.pl --version"). If
> that works, maybe try running a function like
> 
>  my $para = Texinfo::Convert::Paragraph->new();
> 
> to see which function it's crashing in.
> 
> Also, setting the TEXINFO_XS environment variable to "debug" may be
> informative, e.g. I get:
> 
> $TEXINFO_XS=debug ./texi2any.pl  ../doc/info-stnd.texi
> checking ../tp/Texinfo/Convert/XSParagraph/XSParagraph.la
> found ../tp/Texinfo/Convert/XSParagraph/XSParagraph.la
> ../tp/Texinfo/Convert/XSParagraph/.libs/XSParagraph.so loaded
> looking for boot_Texinfo__Convert__XSParagraph__XSParagraph
> 
> Maybe try hacking the t/paragraph.t test (run with "perl -w
> t/paragraph.t") to see how far you can get, like this:

Thanks, I will try these and see what can I come up with.

Can you tell a few words about the design of the XSParagraph code and
how it's supposed to work?  (If there's an explanation available
somewhere, please just point to it.)  I'd like to have a high-level
view of this stuff when I dig into this.  (Please note that I know
next to nothing about Perl.)

Thanks.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]