From: Arthur Miller <arthur.miller@live.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org, akrl@sdf.org
Subject: Re: Native compiler - passing command line options to C compiler
Date: Wed, 01 Sep 2021 16:23:21 +0200 [thread overview]
Message-ID: <AM9PR09MB49779CD96BCABEB071A8334796CD9@AM9PR09MB4977.eurprd09.prod.outlook.com> (raw)
In-Reply-To: <83wno0r02e.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 01 Sep 2021 14:45:45 +0300")
[-- Attachment #1: Type: text/plain, Size: 1135 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Arthur Miller <arthur.miller@live.com>
>> Cc: akrl@sdf.org, emacs-devel@gnu.org
>> Date: Wed, 01 Sep 2021 00:53:31 +0200
>>
>> > No file. We no longer maintain ChangeLog files by hand, we generate
>> > them from Git log. So you should include in the patch the log message
>> > formatted according to ChangeLog rules, but not a patch to any
>> > specific ChangeLog file.
>>
>> Oki, guys here is one: no Windows check, but double checks left. That is what is
>> asked? Hopefully changelog works, I have tried to conform to instruction in
>> CONTRIBUTING and I have tried to keep mysef breef.
>
> Almost there: the commit log message should mention the files and
> functions where you made the changes. Look at the other log messages
> in git, and you will see the difference (feel free to ask if still
> unclear).
>
> Thanks for working on this.
See if this is ok. I don't know how to get in ` into git message. My bash is
complaining, but I see in some git log that Lars had quoted some names with `'.
Found also one check for WINDOWS I forgott to remove.
See if this one is ok:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ncomp-options.patch --]
[-- Type: text/x-patch, Size: 12749 bytes --]
From f4e7c83ce034e3ea5ae1c0fdd4d3c7872c978dcd Mon Sep 17 00:00:00 2001
From: Arthur Miller <arthur.miller@live.com>
Date: Wed, 1 Sep 2021 16:15:42 +0200
Subject: [PATCH] Native comp add/change GCC command-line options
Added support for GCC command-line options and renamed
native-comp-driver-options to native-comp-backend-options to better
reflect which options are passed to GCC.
* lisp/emacs-lisp/comp.el: add user option 'native-comp-compiler-options'
and rename 'native-comp-driver-options' to 'native-comp-backend-options'
with changes needed to implement the feature and the rename.
* list/emacs-lisp/bytecomp.el: adapt to the change in comp.el.
* src/comp.c: add support to implement 'native-comp-compiler-options' and
the rename of driver options to backend options.
---
lisp/emacs-lisp/bytecomp.el | 4 +-
lisp/emacs-lisp/comp.el | 36 +++++++++++----
src/comp.c | 90 +++++++++++++++++++++++++++++--------
3 files changed, 101 insertions(+), 29 deletions(-)
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 145cdbaa6e..c2f7b951d9 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -2257,8 +2257,8 @@ byte-compile-from-buffer
(push `(native-comp-speed . ,native-comp-speed) byte-native-qualities)
(defvar native-comp-debug)
(push `(native-comp-debug . ,native-comp-debug) byte-native-qualities)
- (defvar native-comp-driver-options)
- (push `(native-comp-driver-options . ,native-comp-driver-options)
+ (defvar native-comp-backend-options)
+ (push `(native-comp-backend-options . ,native-comp-backend-options)
byte-native-qualities)
(defvar no-native-compile)
(push `(no-native-compile . ,no-native-compile)
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 80a1da5ad8..30febaf7d8 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -166,14 +166,24 @@ native-comp-async-query-on-exit
:type 'boolean
:version "28.1")
-(defcustom native-comp-driver-options nil
+(defcustom native-comp-compiler-options nil
+ "Command line options passed verbatim to GCC compiler.
+Note that not all options are meaningful and some options might even
+break your Emacs. Use at own risk.
+
+Passing these options is only available in libgccjit version 9
+and above."
+ :type '(repeat string)
+ :version "28.1")
+
+(defcustom native-comp-backend-options nil
"Options passed verbatim to the native compiler's back-end 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 '(repeat string) ; FIXME is this right?
+ :type '(repeat string)
:version "28.1")
(defcustom comp-libgccjit-reproducer nil
@@ -755,8 +765,10 @@ comp-data-container
:documentation "Default speed for this compilation unit.")
(debug native-comp-debug :type number
:documentation "Default debug level for this compilation unit.")
- (driver-options native-comp-driver-options :type list
- :documentation "Options for the GCC driver.")
+ (compiler-options native-comp-compiler-options :type list
+ :documentation "Options for the GCC compiler.")
+ (backend-options native-comp-backend-options :type list
+ :documentation "Options for the GCC driver.")
(top-level-forms () :type list
:documentation "List of spilled top level forms.")
(funcs-h (make-hash-table :test #'equal) :type hash-table
@@ -1347,7 +1359,9 @@ comp-spill-lap-function
byte-native-qualities)
(comp-ctxt-debug comp-ctxt) (alist-get 'native-comp-debug
byte-native-qualities)
- (comp-ctxt-driver-options comp-ctxt) (alist-get 'native-comp-driver-options
+ (comp-ctxt-compiler-options comp-ctxt) (alist-get 'native-comp-compiler-options
+ byte-native-qualities)
+ (comp-ctxt-backend-options comp-ctxt) (alist-get 'native-comp-backend-options
byte-native-qualities)
(comp-ctxt-top-level-forms comp-ctxt)
(cl-loop
@@ -3663,8 +3677,10 @@ comp-final
comp-libgccjit-reproducer ,comp-libgccjit-reproducer
comp-ctxt ,comp-ctxt
native-comp-eln-load-path ',native-comp-eln-load-path
- native-comp-driver-options
- ',native-comp-driver-options
+ native-comp-backend-options
+ ',native-comp-backend-options
+ native-comp-compiler-options
+ ',native-comp-compiler-options
load-path ',load-path)
,native-comp-async-env-modifier-form
(message "Compiling %s..." ',output)
@@ -3926,8 +3942,10 @@ comp-run-async-workers
comp-libgccjit-reproducer ,comp-libgccjit-reproducer
comp-async-compilation t
native-comp-eln-load-path ',native-comp-eln-load-path
- native-comp-driver-options
- ',native-comp-driver-options
+ native-comp-backend-options
+ ',native-comp-backend-options
+ native-comp-compiler-options
+ ',native-comp-compiler-options
load-path ',load-path
warning-fill-column most-positive-fixnum)
,native-comp-async-env-modifier-form
diff --git a/src/comp.c b/src/comp.c
index 3ea2836560..7dfb4c7f23 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -509,7 +509,8 @@ #define NUM_CAST_TYPES 15
typedef struct {
EMACS_INT speed;
EMACS_INT debug;
- Lisp_Object driver_options;
+ Lisp_Object backend_options;
+ Lisp_Object compiler_options;
gcc_jit_context *ctxt;
gcc_jit_type *void_type;
gcc_jit_type *bool_type;
@@ -4361,15 +4362,14 @@ DEFUN ("comp--release-ctxt", Fcomp__release_ctxt, Scomp__release_ctxt,
}
#pragma GCC diagnostic ignored "-Waddress"
-DEFUN ("comp-native-driver-options-effective-p",
- Fcomp_native_driver_options_effective_p,
- Scomp_native_driver_options_effective_p,
+DEFUN ("comp-native-backend-options-effective-p",
+ Fcomp_native_backend_options_effective_p,
+ Scomp_native_backend_options_effective_p,
0, 0, 0,
- doc: /* Return t if `comp-native-driver-options' is effective. */)
+ doc: /* Return t if `comp-native-backend-options' is effective. */)
(void)
{
-#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_driver_option) \
- || defined (WINDOWSNT)
+#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_driver_option)
if (gcc_jit_context_add_driver_option)
return Qt;
#endif
@@ -4377,15 +4377,30 @@ DEFUN ("comp-native-driver-options-effective-p",
}
#pragma GCC diagnostic pop
+#pragma GCC diagnostic ignored "-Waddress"
+DEFUN ("comp-native-compiler-options-effective-p",
+ Fcomp_native_compiler_options_effective_p,
+ Scomp_native_compiler_options_effective_p,
+ 0, 0, 0,
+ doc: /* Return t if `comp-native-compiler-options' is effective. */)
+ (void)
+{
+#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option)
+ if (gcc_jit_context_add_command_line_option)
+ return Qt;
+#endif
+ return Qnil;
+}
+#pragma GCC diagnostic pop
+
static void
add_driver_options (void)
{
Lisp_Object options = Fsymbol_value (Qnative_comp_driver_options);
-#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_driver_option) \
- || defined (WINDOWSNT)
+#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_driver_option)
load_gccjit_if_necessary (true);
- if (!NILP (Fcomp_native_driver_options_effective_p ()))
+ if (!NILP (Fcomp_native_backend_options_effective_p ()))
FOR_EACH_TAIL (options)
gcc_jit_context_add_driver_option (comp.ctxt,
/* FIXME: Need to encode
@@ -4397,15 +4412,14 @@ add_driver_options (void)
if (CONSP (options))
xsignal1 (Qnative_compiler_error,
build_string ("Customizing native compiler options"
- " via `comp-native-driver-options' is"
+ " via `comp-native-backend-options' is"
" only available on libgccjit version 9"
" and above."));
/* Captured `comp-native-driver-options' because file-local. */
-#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_driver_option) \
- || defined (WINDOWSNT)
- options = comp.driver_options;
- if (!NILP (Fcomp_native_driver_options_effective_p ()))
+#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_driver_option)
+ options = comp.backend_options;
+ if (!NILP (Fcomp_native_backend_options_effective_p ()))
FOR_EACH_TAIL (options)
gcc_jit_context_add_driver_option (comp.ctxt,
/* FIXME: Need to encode
@@ -4416,6 +4430,43 @@ add_driver_options (void)
#endif
}
+static void
+add_compiler_options (void)
+{
+ Lisp_Object options = Fsymbol_value (Qnative_comp_compiler_options);
+
+#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option)
+ load_gccjit_if_necessary (true);
+ if (!NILP (Fcomp_native_compiler_options_effective_p ()))
+ FOR_EACH_TAIL (options)
+ gcc_jit_context_add_command_line_option (comp.ctxt,
+ /* FIXME: Need to encode
+ this, but how? either
+ ENCODE_FILE or
+ ENCODE_SYSTEM. */
+ SSDATA (XCAR (options)));
+#endif
+ if (CONSP (options))
+ xsignal1 (Qnative_compiler_error,
+ build_string ("Customizing native compiler options"
+ " via `comp-native-compiler-options' is"
+ " only available on libgccjit version 9"
+ " and above."));
+
+ /* Captured `comp-native-compiler-options' because file-local. */
+#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option)
+ options = comp.compiler_options;
+ if (!NILP (Fcomp_native_compiler_options_effective_p ()))
+ FOR_EACH_TAIL (options)
+ gcc_jit_context_add_command_line_option (comp.ctxt,
+ /* FIXME: Need to encode
+ this, but how? either
+ ENCODE_FILE or
+ ENCODE_SYSTEM. */
+ SSDATA (XCAR (options)));
+#endif
+}
+
DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file,
Scomp__compile_ctxt_to_file,
1, 1, 0,
@@ -4460,7 +4511,7 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file,
eassert (comp.speed < INT_MAX);
comp.debug = XFIXNUM (CALL1I (comp-ctxt-debug, Vcomp_ctxt));
eassert (comp.debug < INT_MAX);
- comp.driver_options = CALL1I (comp-ctxt-driver-options, Vcomp_ctxt);
+ comp.backend_options = CALL1I (comp-ctxt-backend-options, Vcomp_ctxt);
if (comp.debug)
gcc_jit_context_set_bool_option (comp.ctxt,
@@ -4536,6 +4587,7 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file,
#endif
add_driver_options ();
+ add_compiler_options ();
if (comp.debug > 1)
gcc_jit_context_dump_to_file (comp.ctxt,
@@ -5241,7 +5293,8 @@ syms_of_comp (void)
DEFSYM (Qnative_comp_speed, "native-comp-speed");
DEFSYM (Qnative_comp_debug, "native-comp-debug");
- DEFSYM (Qnative_comp_driver_options, "native-comp-driver-options");
+ DEFSYM (Qnative_comp_backend_options, "native-comp-backend-options");
+ DEFSYM (Qnative_comp_compiler_options, "native-comp-compiler-options");
DEFSYM (Qcomp_libgccjit_reproducer, "comp-libgccjit-reproducer");
/* Limple instruction set. */
@@ -5350,7 +5403,8 @@ syms_of_comp (void)
defsubr (&Scomp__subr_signature);
defsubr (&Scomp_el_to_eln_rel_filename);
defsubr (&Scomp_el_to_eln_filename);
- defsubr (&Scomp_native_driver_options_effective_p);
+ defsubr (&Scomp_native_backend_options_effective_p);
+ defsubr (&Scomp_native_compiler_options_effective_p);
defsubr (&Scomp__install_trampoline);
defsubr (&Scomp__init_ctxt);
defsubr (&Scomp__release_ctxt);
--
2.33.0
next prev parent reply other threads:[~2021-09-01 14:23 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <AM9PR09MB49778CFA83AA6697D09ED01B96CA9@AM9PR09MB4977.eurprd09.prod.outlook.com>
2021-08-30 9:36 ` Native compiler - passing command line options to C compiler Andrea Corallo via Emacs development discussions.
2021-08-30 13:56 ` Arthur Miller
2021-08-30 14:05 ` Andrea Corallo via Emacs development discussions.
2021-08-30 11:42 ` Eli Zaretskii
2021-08-30 12:59 ` Andrea Corallo via Emacs development discussions.
2021-08-30 13:28 ` Eli Zaretskii
2021-08-30 14:28 ` Andrea Corallo via Emacs development discussions.
2021-08-30 15:00 ` Arthur Miller
2021-08-30 15:38 ` Andrea Corallo via Emacs development discussions.
2021-08-31 5:36 ` Arthur Miller
2021-08-31 8:06 ` Andrea Corallo via Emacs development discussions.
2021-08-31 13:01 ` Eli Zaretskii
2021-08-31 22:53 ` Arthur Miller
2021-09-01 11:45 ` Eli Zaretskii
2021-09-01 14:23 ` Arthur Miller [this message]
2021-09-01 16:45 ` Eli Zaretskii
2021-09-01 21:06 ` Arthur Miller
2021-08-30 16:01 ` Eli Zaretskii
2021-08-30 15:50 ` Eli Zaretskii
2021-08-30 14:01 ` Arthur Miller
2021-08-30 14:03 ` Eli Zaretskii
2021-09-01 14:58 ` Alex Bennée
2021-09-01 15:10 ` Perry E. Metzger
2021-09-01 16:04 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM9PR09MB49779CD96BCABEB071A8334796CD9@AM9PR09MB4977.eurprd09.prod.outlook.com \
--to=arthur.miller@live.com \
--cc=akrl@sdf.org \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).