bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#41242: Port feature/native-comp to Windows - Reduce the number of fi


From: Andrea Corallo
Subject: bug#41242: Port feature/native-comp to Windows - Reduce the number of files probed when finding a lisp file.
Date: Tue, 02 Jun 2020 23:08:16 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Nicolas Bértolo <nicolasbertolo@gmail.com> writes:

> Hi,
>
> The recent patches broke the Windows build. There is one patch that
> fixes it and another one that improves the way to check for the gccjit version
> functions.

I've pushed "Fix DLL imports of gccjit version functions." on the second
I've some perplexity.

> Nico.
> From 8aa7673f626bfa2c12e6f9c8bbec102ce2fb72d1 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Nicol=C3=A1s=20B=C3=A9rtolo?= <nicolasbertolo@gmail.com>
> Date: Mon, 1 Jun 2020 19:56:37 -0300
> Subject: [PATCH 2/2] Remove kludge for detecting if gcc_jit_version_major can
>  be called.
>
> * src/comp.c (comp-libgccjit-version): Use 'dlsym' in Posix and the
> normal function loading mechanism in Windows.
> ---
>  src/comp.c | 23 ++++++++++++++---------
>  1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/src/comp.c b/src/comp.c
> index 8e7582b3e65..084d0b6745b 100644
> --- a/src/comp.c
> +++ b/src/comp.c
> @@ -365,6 +365,8 @@ #define gcc_jit_version_major fn_gcc_jit_version_major
>  #define gcc_jit_version_minor fn_gcc_jit_version_minor
>  #define gcc_jit_version_patchlevel fn_gcc_jit_version_patchlevel
>  
> +#else
> +#include <dlfcn.h>
>  #endif
>  
>  static bool
> @@ -3999,15 +4001,18 @@ DEFUN ("comp-libgccjit-version", 
> Fcomp_libgccjit_version,
>  #if defined (LIBGCCJIT_HAVE_gcc_jit_version) || defined (WINDOWSNT)
>    load_gccjit_if_necessary (true);
>  
> -  /* FIXME this kludge is quite bad.  Can we dynamically load on all
> -     operating systems?  */
> -#pragma GCC diagnostic ignored "-Waddress"
> -  return gcc_jit_version_major
> -    ? list3 (make_fixnum (gcc_jit_version_major ()),
> -          make_fixnum (gcc_jit_version_minor ()),
> -          make_fixnum (gcc_jit_version_patchlevel ()))
> -    : Qnil;
> -#pragma GCC diagnostic pop
> +  bool ok_to_call;
> +
> +#if defined (WINDOWSNT)
> +  ok_to_call = !!fn_gcc_jit_version_major;
> +#else
> +  ok_to_call = !!dlsym (RTLD_DEFAULT, "gcc_jit_version_major");
> +#endif
> +
> +  return ok_to_call ? list3 (make_fixnum (gcc_jit_version_major ()),
> +                             make_fixnum (gcc_jit_version_minor ()),
> +                             make_fixnum (gcc_jit_version_patchlevel ()))
> +                    : Qnil;
>  #else
>    return Qnil;
>  #endif

First given is giving away two pragmas for adding three preprocessor
directives I'd say it is adding more kludge then what is removing.

Second this code would fail both link time and load time if the linker
cannot resolve one of these three functions making the test on the
result of dlsym in the run time pointless.  To work one needs to go
through function pointers as you are doing in Window, but some macrology
is requested otherwise would be a kludge^2.

  Andrea

-- 
akrl@sdf.org





reply via email to

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