[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/native-comp aa526c9 8/8: Merge branch 'add_driver_option' into H
From: |
Andrea Corallo |
Subject: |
feature/native-comp aa526c9 8/8: Merge branch 'add_driver_option' into HEAD |
Date: |
Wed, 26 Aug 2020 15:49:59 -0400 (EDT) |
branch: feature/native-comp
commit aa526c9470d679e9144af55d9e56928a111d2ceb
Merge: 337367a 51acfee
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>
Merge branch 'add_driver_option' into HEAD
---
lisp/emacs-lisp/comp.el | 12 ++++++++++++
src/comp.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+)
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 28dbd56..238bdcd 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -134,6 +134,16 @@ before compilation. Usable to modify the compiler
environment."
:type 'list
:group 'comp)
+(defcustom comp-native-driver-options nil
+ "Options passed verbatim to the native compiler's backend driver.
+Note that not all options are meaningful; typically only the options
+affecting the assembler and linker are likely to be useful.
+
+Passing these options is only available in libgccjit version 9
+and above."
+ :type 'list
+ :group 'comp)
+
(defvar comp-dry-run nil
"When non nil run everything but the C back-end.")
@@ -2581,6 +2591,8 @@ display a message."
comp-debug ,comp-debug
comp-verbose ,comp-verbose
comp-eln-load-path ',comp-eln-load-path
+ comp-native-driver-options
+ ',comp-native-driver-options
load-path ',load-path)
,comp-async-env-modifier-form
(message "Compiling %s..." ,source-file)
diff --git a/src/comp.c b/src/comp.c
index 5f1257f..fa5ffad 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -56,6 +56,7 @@ along with GNU Emacs. If not, see
<https://www.gnu.org/licenses/>. */
#undef gcc_jit_block_end_with_return
#undef gcc_jit_block_end_with_void_return
#undef gcc_jit_context_acquire
+#undef gcc_jit_context_add_driver_option
#undef gcc_jit_context_compile_to_file
#undef gcc_jit_context_dump_reproducer_to_file
#undef gcc_jit_context_dump_to_file
@@ -121,6 +122,8 @@ DEF_DLL_FN (const char *, gcc_jit_context_get_first_error,
DEF_DLL_FN (gcc_jit_block *, gcc_jit_function_new_block,
(gcc_jit_function *func, const char *name));
DEF_DLL_FN (gcc_jit_context *, gcc_jit_context_acquire, (void));
+DEF_DLL_FN (void, gcc_jit_context_add_driver_option,
+ (gcc_jit_context *ctxt, const char *optname));
DEF_DLL_FN (gcc_jit_field *, gcc_jit_context_new_field,
(gcc_jit_context *ctxt, gcc_jit_location *loc, gcc_jit_type *type,
const char *name));
@@ -303,6 +306,7 @@ init_gccjit_functions (void)
LOAD_DLL_FN (library, gcc_jit_struct_as_type);
LOAD_DLL_FN (library, gcc_jit_struct_set_fields);
LOAD_DLL_FN (library, gcc_jit_type_get_pointer);
+ LOAD_DLL_FN_OPT (library, gcc_jit_context_add_driver_option);
LOAD_DLL_FN_OPT (library, gcc_jit_version_major);
LOAD_DLL_FN_OPT (library, gcc_jit_version_minor);
LOAD_DLL_FN_OPT (library, gcc_jit_version_patchlevel);
@@ -319,6 +323,7 @@ init_gccjit_functions (void)
#define gcc_jit_block_end_with_return fn_gcc_jit_block_end_with_return
#define gcc_jit_block_end_with_void_return
fn_gcc_jit_block_end_with_void_return
#define gcc_jit_context_acquire fn_gcc_jit_context_acquire
+#define gcc_jit_context_add_driver_option fn_gcc_jit_context_add_driver_option
#define gcc_jit_context_compile_to_file fn_gcc_jit_context_compile_to_file
#define gcc_jit_context_dump_reproducer_to_file
fn_gcc_jit_context_dump_reproducer_to_file
#define gcc_jit_context_dump_to_file fn_gcc_jit_context_dump_to_file
@@ -4231,6 +4236,47 @@ DEFUN ("comp--release-ctxt", Fcomp__release_ctxt,
Scomp__release_ctxt,
return Qt;
}
+DEFUN ("comp-native-driver-options-effective-p",
+ Fcomp_native_driver_options_effective_p,
+ Scomp_native_driver_options_effective_p,
+ 0, 0, 0,
+ doc: /* Return t if `comp-native-driver-options' is
+ effective nil otherwise. */)
+ (void)
+{
+#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_driver_option) \
+ || defined (WINDOWSNT)
+#pragma GCC diagnostic ignored "-Waddress"
+ if (gcc_jit_context_add_driver_option)
+ return Qt;
+#pragma GCC diagnostic pop
+#endif
+ return Qnil;
+}
+
+
+static void
+add_driver_options (void)
+{
+ Lisp_Object options = Fsymbol_value (Qcomp_native_driver_options);
+
+#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_driver_option) \
+ || defined (WINDOWSNT)
+ load_gccjit_if_necessary (true);
+ if (!NILP (Fcomp_native_driver_options_effective_p ()))
+ FOR_EACH_TAIL (options)
+ gcc_jit_context_add_driver_option (comp.ctxt,
+ SSDATA (XCAR (options)));
+ return;
+#endif
+ if (CONSP (options))
+ xsignal1 (Qnative_compiler_error,
+ build_string ("Customizing native compiler options"
+ " via `comp-native-driver-options' is"
+ " only available on libgccjit version 9"
+ " and above."));
+}
+
static void
restore_sigmask (void)
{
@@ -4300,6 +4346,8 @@ DEFUN ("comp--compile-ctxt-to-file",
Fcomp__compile_ctxt_to_file,
for (ptrdiff_t i = 0; i < func_h->count; i++)
compile_function (HASH_VALUE (func_h, i));
+ add_driver_options ();
+
if (COMP_DEBUG)
gcc_jit_context_dump_to_file (comp.ctxt,
format_string ("%s.c", SSDATA (base_name)),
@@ -5106,6 +5154,7 @@ native compiled one. */);
DEFSYM (Qcomp_speed, "comp-speed");
DEFSYM (Qcomp_debug, "comp-debug");
+ DEFSYM (Qcomp_native_driver_options, "comp-native-driver-options");
/* Limple instruction set. */
DEFSYM (Qcomment, "comment");
@@ -5206,6 +5255,7 @@ native compiled one. */);
"configuration, please recompile"));
defsubr (&Scomp_el_to_eln_filename);
+ defsubr (&Scomp_native_driver_options_effective_p);
defsubr (&Scomp__init_ctxt);
defsubr (&Scomp__release_ctxt);
defsubr (&Scomp__compile_ctxt_to_file);
- feature/native-comp updated (337367a -> aa526c9), Andrea Corallo, 2020/08/26
- feature/native-comp c00aedb 2/8: Fix windows NT handling for [...]_add_driver_options, Andrea Corallo, 2020/08/26
- feature/native-comp 51acfee 7/8: * Init gcc_jit_context_add_driver_option as optional, Andrea Corallo, 2020/08/26
- feature/native-comp 1f105d5 3/8: * Improve 'add_driver_options', Andrea Corallo, 2020/08/26
- feature/native-comp f8321f0 5/8: * src/comp.c (add_driver_options): Fix missing condition + clean-up pragma, Andrea Corallo, 2020/08/26
- feature/native-comp 2772e83 1/8: Set native driver options in async compiles, also, Andrea Corallo, 2020/08/26
- feature/native-comp c17013a 4/8: * Add 'comp-native-driver-options-available-p', Andrea Corallo, 2020/08/26
- feature/native-comp 63f041c 6/8: * Rename comp-native-driver-options-available-p, Andrea Corallo, 2020/08/26
- feature/native-comp aa526c9 8/8: Merge branch 'add_driver_option' into HEAD,
Andrea Corallo <=