emacs-devel
[Top][All Lists]
Advanced

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

Re: bignum branch


From: Andy Moreton
Subject: Re: bignum branch
Date: Fri, 10 Aug 2018 15:05:19 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (windows-nt)

On Fri 10 Aug 2018, Eli Zaretskii wrote:

>> From: Andy Moreton <address@hidden>
>> Date: Fri, 10 Aug 2018 12:39:33 +0100
>> 
>> >> Emacs currently links against the shared library on MSYS2 64bit, and has
>> >> a dependency on "c:/msys64/mingw64/bin/libgmp-10.dll".
>> >
>> I used the MSYS2 version of cygcheck to report the dependencies, and
>> also the Dependency Walker tool. Both show libgmp-10.dll as a direct
>> dependency of emacs.exe.
>
> And that happens no matter what version of the gmp.h header, the
> original one or the one you modified. you use during compilation?

Yes, which is expected. The API decoration with dllimport only ensures
that the symbols are linked correctly - the choice of libary is set by
the linker options.

>> The only thing I changed was the dllimport decorations, and that changed
>> the behaviour from a crash to working properly.
>
> What happens if you restore the original gmp.h, rename libgmp.dll.a to
> something the linker won't recognize, and rebuild Emacs?  (This should
> cause Emacs to be linked statically against libgmp.a.)  Does the
> problem with the test suite happen then?

Good idea. I reinstalledthe GMP package, and checked that gmp.h is
unmodified, and then tested each time as follows:
 - touch globals.h
 - rebuild emacs
 - "ldd emacs.exe | grep -i gmp" to check dependencies
 - "make -C test data-tests" to run logcount test

|   | __GMP_LIBGMP_DLL | libgmp.dll.a | dependencies  | data-tests |
|---+------------------+--------------+---------------+------------|
| 1 |                0 | libgmp.dll.a | libgmp-10.dll | crash      |
|---+------------------+--------------+---------------+------------|
| 2 |                0 | (removed)    | (none)        | pass       |
|---+------------------+--------------+---------------+------------|
| 3 |                1 | libgmp.dll.a | libgmp-10.dll | pass       |
|---+------------------+--------------+---------------+------------|
| 4 |                1 | (removed)    | (link fails)  | n/a        |
|---+------------------+--------------+---------------+------------|

Row (1) is the original bignum build with the problem.
Row (2) results in using the static lib correctly.
Row (3) with modified gmp.h shows the shared lib working correctly.
Row (4) shows that asking for dllimport APIs without the import library
fails to link:

  CCLD     temacs.exe
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
 frame.o: in function `XFLOATINT':
C:/emacs/git/emacs/bignum/src/lisp.h:2923: undefined reference to
`__imp___gmpz_get_d'
[many similar lines omitted]

I think this clearly shows that the problem is nmismatched calling
convention and library usage.

    AndyM





reply via email to

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