Bill Allombert on Fri, 03 May 2019 11:41:42 +0200


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

Re: PATCH: support install() on Win: [Re: Please test pari-2.11.2 prerelease 1]


On Thu, May 02, 2019 at 03:39:56AM -0700, Ilya Zakharevich wrote:
> On Sun, Apr 28, 2019 at 04:08:23PM +0200, Bill Allombert wrote:
> > We have made available a prerelease of PARI 2.11.2 (stable).
> 
> Strangely, install() is not supported on Windows (with static
> builds).  It is so much easier on Windows than on OS/2?????????you could not
> export symbols from an exe file???

It is supported by the dynamic build, which is provided by the NSIS
installer package:
<https://pari.math.u-bordeaux.fr/pub/pari/windows/snapshots/Pari64-2-11-2-pre1.exe>

> I attach a patch to es.c.  Additionally, a def file should be linked
> to the exe.  The patch below shows one way to do it.  (I do not know
> how to modify the build environment to make this change to Makefile.)

This is done in config/Makefile.SH

> --- pari-2.11.1/src/language/es.c-pre	2018-07-25 11:00:21.000000000 -0700
> +++ pari-2.11.1/src/language/es.c	2019-05-02 03:25:45.470881300 -0700
> @@ -5200,7 +5200,6 @@ install0(const char *name, const char *l
>  #  define RTLD_GLOBAL 0
>  #endif
>    handle = gp_dlopen(lib, RTLD_LAZY|RTLD_GLOBAL);
> -
>    if (!handle)
>    {
>      const char *s = dlerror(); if (s) err_printf("%s\n\n",s);
> @@ -5236,12 +5235,24 @@ gp_LoadLibrary(const char *name)
>    }
>    return NULL;
>  }
> +static int I_m_a_DLL = -1;
> +static HMODULE hmod_exe, hmod_dll;
>  static void *
>  install0(const char *name, const char *lib)
>  {
>    HMODULE handle;
>  
> -  handle = gp_LoadLibrary(lib);
> +  if (lib == pari_library_path) {
> +    if (I_m_a_DLL < 0) {
> +      hmod_exe = hmod_dll = GetModuleHandleA(NULL);
> +      if (!hmod_exe	/* Can this happen? */
> +          || !(GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
> +          		          (LPCSTR)install0, &hmod_dll)))
> +        I_m_a_DLL = hmod_exe != hmod_dll;
> +    }
> +    handle = hmod_dll;
> +  } else
> +    handle = gp_LoadLibrary(lib);
>    if (!handle)
>    {
>      if (lib) pari_err(e_MISC,"couldn't open dynamic library '%s'",lib);

What does that do ?
Does 
install("addii",GG);
addii(2,3)
work with this patch with gp-sta ?

Cheers,
Bill