* Re: Native compiler - passing command line options to C compiler
[not found] <AM9PR09MB49778CFA83AA6697D09ED01B96CA9@AM9PR09MB4977.eurprd09.prod.outlook.com>
@ 2021-08-30 9:36 ` Andrea Corallo via Emacs development discussions.
2021-08-30 13:56 ` Arthur Miller
2021-08-30 11:42 ` Eli Zaretskii
1 sibling, 1 reply; 24+ messages in thread
From: Andrea Corallo via Emacs development discussions. @ 2021-08-30 9:36 UTC (permalink / raw)
To: Arthur Miller; +Cc: emacs-devel
Arthur Miller <arthur.miller@live.com> writes:
> Hi again,
>
> after the few mails the other day, I wasn't really sure if Andrea is going to
> implement it and when.
Sure I was going to implent it as I said so, but thanks for taking the
task :)
> I thought it was rather a tedious manual labour and maybe
> not so important, so I took me a liberty to implement this myself in my own, so
> called, personal copy of Eamcs sources.
>
> I am not sure if I have done it correctly though, I appreciate if Andrea have
> time to take a look;
I just have a small suggestion.
> Mark set
>
> diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
> index 80a1da5ad8..58d361cf46 100644
> --- a/lisp/emacs-lisp/comp.el
> +++ b/lisp/emacs-lisp/comp.el
> @@ -166,6 +166,16 @@ native-comp-async-query-on-exit
> :type 'boolean
> :version "28.1")
>
> +(defcustom native-comp-compiler-options nil
> + "Options passed verbatim to the native compiler's c driver.
I'd just say "passed to the compiler" or "passed to GCC" as there's no C
involed.
> +#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-driver-options' because file-local. */
^^^
native-comp-compiler-options ?
Other that that the patch LGTM. Could you provide it with its
Changelog?
TIA
Andrea
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
[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 11:42 ` Eli Zaretskii
2021-08-30 12:59 ` Andrea Corallo via Emacs development discussions.
` (2 more replies)
1 sibling, 3 replies; 24+ messages in thread
From: Eli Zaretskii @ 2021-08-30 11:42 UTC (permalink / raw)
To: Arthur Miller; +Cc: emacs-devel
> From: Arthur Miller <arthur.miller@live.com>
> Date: Sun, 29 Aug 2021 23:47:56 +0200
>
> after the few mails the other day, I wasn't really sure if Andrea is going to
> implement it and when. I thought it was rather a tedious manual labour and maybe
> not so important, so I took me a liberty to implement this myself in my own, so
> called, personal copy of Eamcs sources.
Thanks.
> I am not sure if I have done it correctly though, I appreciate if Andrea have
> time to take a look; I have just mainly copied your code for backend options. It
> seems to work for me, with a minor remark: When I pass a valid option, "native",
> in place where it should go, I get an invalid option error. Gcc even lists it in
> the error message as a valid option. Another option "skylake" works just
> fine. This seems to vary between flags. I am not sure if this is some encoding
> error from Emacs to libgccjit, or if it is some bug in libgccjit, or is it just
> my brain having dumps.
I guess -march=native is something handled by GCC itself, and here we
don't have it? If you want to be sure, ask this question on the GCC
list, or report as a bug to their Bugzilla.
> +break your code. Use at own risk.
^^
Two spaces between sentences.
> +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) \
> + || defined (WINDOWSNT) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> + if (gcc_jit_context_add_command_line_option)
> + return Qt;
> +#endif
The emphasized part doesn't look right: we did that elsewhere because
the options we pass there work around bugs that happen also in
versions that don't report libgccjit version. But here this is not
needed, and the version check isn't present anyway. So the WINDOWSNT
special handling should be removed, I think.
> +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) \
> + || defined (WINDOWSNT)
> + load_gccjit_if_necessary (true);
> + if (!NILP (Fcomp_native_compiler_options_effective_p ()))
Likewise here. And since Fcomp_native_compiler_options_effective_p
already does this test, why did you need to have another test outside
it?
> + /* Captured `comp-native-driver-options' because file-local. */
> +#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option) \
> + || defined (WINDOWSNT)
> + 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
Likewise here.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
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:01 ` Arthur Miller
2021-09-01 14:58 ` Alex Bennée
2 siblings, 1 reply; 24+ messages in thread
From: Andrea Corallo via Emacs development discussions. @ 2021-08-30 12:59 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Arthur Miller, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Arthur Miller <arthur.miller@live.com>
>> Date: Sun, 29 Aug 2021 23:47:56 +0200
>>
>> after the few mails the other day, I wasn't really sure if Andrea is going to
>> implement it and when. I thought it was rather a tedious manual labour and maybe
>> not so important, so I took me a liberty to implement this myself in my own, so
>> called, personal copy of Eamcs sources.
>
> Thanks.
>
>> I am not sure if I have done it correctly though, I appreciate if Andrea have
>> time to take a look; I have just mainly copied your code for backend options. It
>> seems to work for me, with a minor remark: When I pass a valid option, "native",
>> in place where it should go, I get an invalid option error. Gcc even lists it in
>> the error message as a valid option. Another option "skylake" works just
>> fine. This seems to vary between flags. I am not sure if this is some encoding
>> error from Emacs to libgccjit, or if it is some bug in libgccjit, or is it just
>> my brain having dumps.
>
> I guess -march=native is something handled by GCC itself, and here we
> don't have it? If you want to be sure, ask this question on the GCC
> list, or report as a bug to their Bugzilla.
>
>> +break your code. Use at own risk.
> ^^
> Two spaces between sentences.
>
>> +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) \
>> + || defined (WINDOWSNT) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>> + if (gcc_jit_context_add_command_line_option)
>> + return Qt;
>> +#endif
>
> The emphasized part doesn't look right: we did that elsewhere because
> the options we pass there work around bugs that happen also in
> versions that don't report libgccjit version. But here this is not
> needed, and the version check isn't present anyway. So the WINDOWSNT
> special handling should be removed, I think.
I think this "defined (WINDOWSNT)" should be there so that compiling on
Windows the check over "gcc_jit_context_add_command_line_option" it is
always compiled even in case the libgccjit.h provided at compile time
does not define
'LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option'.
A newer version of the shared library including the entry point might be
provided later on and will be used at runtime.
This should explain also the other mentioned points.
Regards
Andrea
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
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.
0 siblings, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2021-08-30 13:28 UTC (permalink / raw)
To: Andrea Corallo; +Cc: arthur.miller, emacs-devel
> From: Andrea Corallo <akrl@sdf.org>
> Cc: Arthur Miller <arthur.miller@live.com>, emacs-devel@gnu.org
> Date: Mon, 30 Aug 2021 12:59:45 +0000
>
> I think this "defined (WINDOWSNT)" should be there so that compiling on
> Windows the check over "gcc_jit_context_add_command_line_option" it is
> always compiled even in case the libgccjit.h provided at compile time
> does not define
> 'LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option'.
>
> A newer version of the shared library including the entry point might be
> provided later on and will be used at runtime.
You cannot use a libgccjit.dll of a version for which Emacs was not
compiled, unless it is binary-compatible. If Emacs was linked against
libgccjit.dll that didn't support
gcc_jit_context_add_command_line_option, then it would not work to
install a newer version of the DLL that does.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
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.
0 siblings, 1 reply; 24+ messages in thread
From: Arthur Miller @ 2021-08-30 13:56 UTC (permalink / raw)
To: Andrea Corallo; +Cc: emacs-devel
Andrea Corallo <akrl@sdf.org> writes:
> Arthur Miller <arthur.miller@live.com> writes:
>
>> Hi again,
>>
>> after the few mails the other day, I wasn't really sure if Andrea is going to
>> implement it and when.
>
> Sure I was going to implent it as I said so, but thanks for taking the
> task :)
I just wanted to test it myself, and it looked like an easy thing to do so it
felt like I can do it, so you have time to do something more important, like
grab a beer, get on a date, or implement some more optimizations? :-)
>> I thought it was rather a tedious manual labour and maybe
>> not so important, so I took me a liberty to implement this myself in my own, so
>> called, personal copy of Eamcs sources.
>>
>> I am not sure if I have done it correctly though, I appreciate if Andrea have
>> time to take a look;
>
> I just have a small suggestion.
>
>> Mark set
>>
>> diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
>> index 80a1da5ad8..58d361cf46 100644
>> --- a/lisp/emacs-lisp/comp.el
>> +++ b/lisp/emacs-lisp/comp.el
>> @@ -166,6 +166,16 @@ native-comp-async-query-on-exit
>> :type 'boolean
>> :version "28.1")
>>
>> +(defcustom native-comp-compiler-options nil
>> + "Options passed verbatim to the native compiler's c driver.
>
> I'd just say "passed to the compiler" or "passed to GCC" as there's no C
> involed.
Yes, I'll change it. I didn't know really what to say that to be honest.
>> +#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-driver-options' because file-local. */
> ^^^
> native-comp-compiler-options ?
>
No idea, but I can change it :-).
> Other that that the patch LGTM. Could you provide it with its
> Changelog?
Yes, will do later tonight.
Do you want me to also rename the 'native-comp-driver-options' to
'native-comp-backend-options' when I am anyway at it? I can do it in the same
patch if you want.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
2021-08-30 11:42 ` Eli Zaretskii
2021-08-30 12:59 ` Andrea Corallo via Emacs development discussions.
@ 2021-08-30 14:01 ` Arthur Miller
2021-08-30 14:03 ` Eli Zaretskii
2021-09-01 14:58 ` Alex Bennée
2 siblings, 1 reply; 24+ messages in thread
From: Arthur Miller @ 2021-08-30 14:01 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Arthur Miller <arthur.miller@live.com>
>> Date: Sun, 29 Aug 2021 23:47:56 +0200
>>
>> after the few mails the other day, I wasn't really sure if Andrea is going to
>> implement it and when. I thought it was rather a tedious manual labour and maybe
>> not so important, so I took me a liberty to implement this myself in my own, so
>> called, personal copy of Eamcs sources.
>
> Thanks.
>
>> I am not sure if I have done it correctly though, I appreciate if Andrea have
>> time to take a look; I have just mainly copied your code for backend options. It
>> seems to work for me, with a minor remark: When I pass a valid option, "native",
>> in place where it should go, I get an invalid option error. Gcc even lists it in
>> the error message as a valid option. Another option "skylake" works just
>> fine. This seems to vary between flags. I am not sure if this is some encoding
>> error from Emacs to libgccjit, or if it is some bug in libgccjit, or is it just
>> my brain having dumps.
>
> I guess -march=native is something handled by GCC itself, and here we
> don't have it? If you want to be sure, ask this question on the GCC
> list, or report as a bug to their Bugzilla.
>
>> +break your code. Use at own risk.
> ^^
> Two spaces between sentences.
Ah, why did I forgott that one :).
>> +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) \
>> + || defined (WINDOWSNT) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>> + if (gcc_jit_context_add_command_line_option)
>> + return Qt;
>> +#endif
>
> The emphasized part doesn't look right: we did that elsewhere because
> the options we pass there work around bugs that happen also in
> versions that don't report libgccjit version. But here this is not
> needed, and the version check isn't present anyway. So the WINDOWSNT
> special handling should be removed, I think.
Ok. I am not familiar with the details of how and why, so I just left it. I can
remove it.
>> +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) \
>> + || defined (WINDOWSNT)
>> + load_gccjit_if_necessary (true);
>> + if (!NILP (Fcomp_native_compiler_options_effective_p ()))
>
> Likewise here. And since Fcomp_native_compiler_options_effective_p
> already does this test, why did you need to have another test outside
> it?
That was just copy pasta. I have noticed that and reflected over that, but I
didn't want to poke too much into stuff.
>> + /* Captured `comp-native-driver-options' because file-local. */
>> +#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option) \
>> + || defined (WINDOWSNT)
>> + 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
>
> Likewise here.
Yes, I'll fix Windows case. If you would like me to test it on Windows it will take
time. Maybe tomorrow or day after. I can send in patch when I tested to save
everyones time.
Thanks for the help and clarifications!
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
2021-08-30 14:01 ` Arthur Miller
@ 2021-08-30 14:03 ` Eli Zaretskii
0 siblings, 0 replies; 24+ messages in thread
From: Eli Zaretskii @ 2021-08-30 14:03 UTC (permalink / raw)
To: Arthur Miller; +Cc: emacs-devel
> From: Arthur Miller <arthur.miller@live.com>
> Cc: emacs-devel@gnu.org
> Date: Mon, 30 Aug 2021 16:01:22 +0200
>
> Yes, I'll fix Windows case.
Thanks.
> If you would like me to test it on Windows it will take time.
No need, I can do that here, but it would help if you show me a
working example (presumably some simple Lisp) to try.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
2021-08-30 13:56 ` Arthur Miller
@ 2021-08-30 14:05 ` Andrea Corallo via Emacs development discussions.
0 siblings, 0 replies; 24+ messages in thread
From: Andrea Corallo via Emacs development discussions. @ 2021-08-30 14:05 UTC (permalink / raw)
To: Arthur Miller; +Cc: emacs-devel
Arthur Miller <arthur.miller@live.com> writes:
> Andrea Corallo <akrl@sdf.org> writes:
>
>> Arthur Miller <arthur.miller@live.com> writes:
>>
>>> Hi again,
>>>
>>> after the few mails the other day, I wasn't really sure if Andrea is going to
>>> implement it and when.
>>
>> Sure I was going to implent it as I said so, but thanks for taking the
>> task :)
>
> I just wanted to test it myself, and it looked like an easy thing to do so it
> felt like I can do it, so you have time to do something more important, like
> grab a beer, get on a date, or implement some more optimizations? :-)
>
>>> I thought it was rather a tedious manual labour and maybe
>>> not so important, so I took me a liberty to implement this myself in my own, so
>>> called, personal copy of Eamcs sources.
>>>
>>> I am not sure if I have done it correctly though, I appreciate if Andrea have
>>> time to take a look;
>>
>> I just have a small suggestion.
>>
>>> Mark set
>>>
>>> diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
>>> index 80a1da5ad8..58d361cf46 100644
>>> --- a/lisp/emacs-lisp/comp.el
>>> +++ b/lisp/emacs-lisp/comp.el
>>> @@ -166,6 +166,16 @@ native-comp-async-query-on-exit
>>> :type 'boolean
>>> :version "28.1")
>>>
>>> +(defcustom native-comp-compiler-options nil
>>> + "Options passed verbatim to the native compiler's c driver.
>>
>> I'd just say "passed to the compiler" or "passed to GCC" as there's no C
>> involed.
>
> Yes, I'll change it. I didn't know really what to say that to be honest.
>
>>> +#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-driver-options' because file-local. */
>> ^^^
>> native-comp-compiler-options ?
>>
> No idea, but I can change it :-).
>
>> Other that that the patch LGTM. Could you provide it with its
>> Changelog?
>
> Yes, will do later tonight.
>
> Do you want me to also rename the 'native-comp-driver-options' to
> 'native-comp-backend-options' when I am anyway at it? I can do it in the same
> patch if you want.
Yes please, I guess a second patch would be the best.
Thanks
Andrea
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
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:50 ` Eli Zaretskii
0 siblings, 2 replies; 24+ messages in thread
From: Andrea Corallo via Emacs development discussions. @ 2021-08-30 14:28 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: arthur.miller, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Andrea Corallo <akrl@sdf.org>
>> Cc: Arthur Miller <arthur.miller@live.com>, emacs-devel@gnu.org
>> Date: Mon, 30 Aug 2021 12:59:45 +0000
>>
>> I think this "defined (WINDOWSNT)" should be there so that compiling on
>> Windows the check over "gcc_jit_context_add_command_line_option" it is
>> always compiled even in case the libgccjit.h provided at compile time
>> does not define
>> 'LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option'.
>>
>> A newer version of the shared library including the entry point might be
>> provided later on and will be used at runtime.
>
> You cannot use a libgccjit.dll of a version for which Emacs was not
> compiled, unless it is binary-compatible. If Emacs was linked against
> libgccjit.dll that didn't support
> gcc_jit_context_add_command_line_option, then it would not work to
> install a newer version of the DLL that does.
Okay, I thought on Windows worked differently and we could handle the
case of a symbol not available at compile time but at runtime. In the
light of this we can probably perform some more clean-up.
Thanks
Andrea
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
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-30 16:01 ` Eli Zaretskii
2021-08-30 15:50 ` Eli Zaretskii
1 sibling, 2 replies; 24+ messages in thread
From: Arthur Miller @ 2021-08-30 15:00 UTC (permalink / raw)
To: Andrea Corallo; +Cc: Eli Zaretskii, emacs-devel
Andrea Corallo <akrl@sdf.org> writes:
> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> From: Andrea Corallo <akrl@sdf.org>
>>> Cc: Arthur Miller <arthur.miller@live.com>, emacs-devel@gnu.org
>>> Date: Mon, 30 Aug 2021 12:59:45 +0000
>>>
>>> I think this "defined (WINDOWSNT)" should be there so that compiling on
>>> Windows the check over "gcc_jit_context_add_command_line_option" it is
>>> always compiled even in case the libgccjit.h provided at compile time
>>> does not define
>>> 'LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option'.
>>>
>>> A newer version of the shared library including the entry point might be
>>> provided later on and will be used at runtime.
>>
>> You cannot use a libgccjit.dll of a version for which Emacs was not
>> compiled, unless it is binary-compatible. If Emacs was linked against
>> libgccjit.dll that didn't support
>> gcc_jit_context_add_command_line_option, then it would not work to
>> install a newer version of the DLL that does.
>
> Okay, I thought on Windows worked differently and we could handle the
> case of a symbol not available at compile time but at runtime. In the
> light of this we can probably perform some more clean-up.
So does that mean that windows check is not needed in add_driver_options as well?
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
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-30 16:01 ` Eli Zaretskii
1 sibling, 1 reply; 24+ messages in thread
From: Andrea Corallo via Emacs development discussions. @ 2021-08-30 15:38 UTC (permalink / raw)
To: Arthur Miller; +Cc: Eli Zaretskii, emacs-devel
Arthur Miller <arthur.miller@live.com> writes:
> Andrea Corallo <akrl@sdf.org> writes:
>
>> Eli Zaretskii <eliz@gnu.org> writes:
>>
>>>> From: Andrea Corallo <akrl@sdf.org>
>>>> Cc: Arthur Miller <arthur.miller@live.com>, emacs-devel@gnu.org
>>>> Date: Mon, 30 Aug 2021 12:59:45 +0000
>>>>
>>>> I think this "defined (WINDOWSNT)" should be there so that compiling on
>>>> Windows the check over "gcc_jit_context_add_command_line_option" it is
>>>> always compiled even in case the libgccjit.h provided at compile time
>>>> does not define
>>>> 'LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option'.
>>>>
>>>> A newer version of the shared library including the entry point might be
>>>> provided later on and will be used at runtime.
>>>
>>> You cannot use a libgccjit.dll of a version for which Emacs was not
>>> compiled, unless it is binary-compatible. If Emacs was linked against
>>> libgccjit.dll that didn't support
>>> gcc_jit_context_add_command_line_option, then it would not work to
>>> install a newer version of the DLL that does.
>>
>> Okay, I thought on Windows worked differently and we could handle the
>> case of a symbol not available at compile time but at runtime. In the
>> light of this we can probably perform some more clean-up.
>
> So does that mean that windows check is not needed in add_driver_options as well?
AFAIR that was the reason for that check so yes.
Andrea
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
2021-08-30 14:28 ` Andrea Corallo via Emacs development discussions.
2021-08-30 15:00 ` Arthur Miller
@ 2021-08-30 15:50 ` Eli Zaretskii
1 sibling, 0 replies; 24+ messages in thread
From: Eli Zaretskii @ 2021-08-30 15:50 UTC (permalink / raw)
To: Andrea Corallo; +Cc: arthur.miller, emacs-devel
> From: Andrea Corallo <akrl@sdf.org>
> Cc: arthur.miller@live.com, emacs-devel@gnu.org
> Date: Mon, 30 Aug 2021 14:28:18 +0000
>
> > You cannot use a libgccjit.dll of a version for which Emacs was not
> > compiled, unless it is binary-compatible. If Emacs was linked against
> > libgccjit.dll that didn't support
> > gcc_jit_context_add_command_line_option, then it would not work to
> > install a newer version of the DLL that does.
>
> Okay, I thought on Windows worked differently and we could handle the
> case of a symbol not available at compile time but at runtime.
On Windows, we delay loading the libgccjit DLL until it is first
needed, but when it load it, we find the addresses of all the
functions we want to import from the library, and any function that is
not in the library will cause the initialization to fail. See
init_gccjit_functions, and examine the definition of the LOAD_DLL_FN
macro. So if someone has a libgccjit DLL without the
gcc_jit_context_add_command_line_option function, they will be unable
to use native-compilation.
Btw, since we already expect gcc_jit_context_add_command_line_option
to exist unconditionally on WINDOWSNT, I guess the test for
LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option is indeed not
needed on WINDOWSNT, because we implicitly assume it will always
succeed. But I'd like to avoid tricky code if possible.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
2021-08-30 15:00 ` Arthur Miller
2021-08-30 15:38 ` Andrea Corallo via Emacs development discussions.
@ 2021-08-30 16:01 ` Eli Zaretskii
1 sibling, 0 replies; 24+ messages in thread
From: Eli Zaretskii @ 2021-08-30 16:01 UTC (permalink / raw)
To: Arthur Miller; +Cc: emacs-devel, akrl
> From: Arthur Miller <arthur.miller@live.com>
> Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
> Date: Mon, 30 Aug 2021 17:00:08 +0200
>
> So does that mean that windows check is not needed in add_driver_options as well?
I wouldn't delete it from there. On Windows, we assume without
checking that gcc_jit_context_add_command_line_option exists, because
(a) Windows versions of libgccjit appeared only in GCC versions that
already supported that, and (b) without that native-compilation could
produce code that crashes on Windows.
IOW, this is an internal implementation detail, a workaround for a
nasty problem. But for a general-purpose text that will cause no
disaster if it fails, I'd like not to use tricky conditionals that
need long explanations.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
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
0 siblings, 2 replies; 24+ messages in thread
From: Arthur Miller @ 2021-08-31 5:36 UTC (permalink / raw)
To: Andrea Corallo; +Cc: Eli Zaretskii, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1883 bytes --]
Andrea Corallo <akrl@sdf.org> writes:
> Arthur Miller <arthur.miller@live.com> writes:
>
>> Andrea Corallo <akrl@sdf.org> writes:
>>
>>> Eli Zaretskii <eliz@gnu.org> writes:
>>>
>>>>> From: Andrea Corallo <akrl@sdf.org>
>>>>> Cc: Arthur Miller <arthur.miller@live.com>, emacs-devel@gnu.org
>>>>> Date: Mon, 30 Aug 2021 12:59:45 +0000
>>>>>
>>>>> I think this "defined (WINDOWSNT)" should be there so that compiling on
>>>>> Windows the check over "gcc_jit_context_add_command_line_option" it is
>>>>> always compiled even in case the libgccjit.h provided at compile time
>>>>> does not define
>>>>> 'LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option'.
>>>>>
>>>>> A newer version of the shared library including the entry point might be
>>>>> provided later on and will be used at runtime.
>>>>
>>>> You cannot use a libgccjit.dll of a version for which Emacs was not
>>>> compiled, unless it is binary-compatible. If Emacs was linked against
>>>> libgccjit.dll that didn't support
>>>> gcc_jit_context_add_command_line_option, then it would not work to
>>>> install a newer version of the DLL that does.
>>>
>>> Okay, I thought on Windows worked differently and we could handle the
>>> case of a symbol not available at compile time but at runtime. In the
>>> light of this we can probably perform some more clean-up.
>>
>> So does that mean that windows check is not needed in add_driver_options as well?
>
> AFAIR that was the reason for that check so yes.
>
> Andrea
Ok, I have made those changes. I have removed double checks from both
add_driver_options () and add_compiler_options (). If it is not OK, I can made
another one and revert back this change in add_driver_options.
I have also renamed native-comp-driver-options to native-comp-backend-options.
I forgott to ask, which Changelog are we talking about? Changelo.3 in top Emacs
dir or some other file?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ncomp-options.patch --]
[-- Type: text/x-patch, Size: 12879 bytes --]
From d0c2b4f882fc67562de6ad67f6dcfdfe6378c32b Mon Sep 17 00:00:00 2001
From: Arthur Miller <arthur.miller@live.com>
Date: Tue, 31 Aug 2021 07:15:01 +0200
Subject: [PATCH] Native comp: gcc cmdopts + rename driver-options to
backend-options.
---
lisp/emacs-lisp/bytecomp.el | 4 +-
lisp/emacs-lisp/comp.el | 36 ++++++++---
src/comp.c | 122 ++++++++++++++++++++++++++----------
3 files changed, 118 insertions(+), 44 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..dab34f89e4 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 to the 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 C 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..44cc3a7c76 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,11 +4362,11 @@ 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) \
@@ -4377,43 +4378,95 @@ 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);
+ Lisp_Object options = Fsymbol_value (Qnative_comp_backend_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 ()))
+ if (!NILP (Fcomp_native_backend_options_effective_p ()))
+ {
+ load_gccjit_if_necessary (true);
+ FOR_EACH_TAIL (options)
+ gcc_jit_context_add_driver_option (comp.ctxt,
+ /* FIXME: Need to encode
+ this, but how? either
+ ENCODE_FILE or
+ ENCODE_SYSTEM. */
+ SSDATA (XCAR (options)));
+ }
+
+ if (CONSP (options))
+ xsignal1 (Qnative_compiler_error,
+ build_string ("Customizing native compiler options"
+ " via `comp-native-backend-options' is"
+ " only available on libgccjit version 9"
+ " and above."));
+
+ /* Captured `comp-native-backend-options' because file-local. */
+ if (!NILP (Fcomp_native_backend_options_effective_p ()))
+ {
+ options = comp.backend_options;
+ FOR_EACH_TAIL (options)
+ gcc_jit_context_add_driver_option (comp.ctxt,
+ /* FIXME: Need to encode
+ this, but how? either
+ ENCODE_FILE or
+ ENCODE_SYSTEM. */
+ SSDATA (XCAR (options)));
+ }
+}
+
+static void
+add_compiler_options (void)
+{
+ Lisp_Object options = Fsymbol_value (Qnative_comp_compiler_options);
+
+ if (!NILP (Fcomp_native_compiler_options_effective_p ()))
+ {
+ load_gccjit_if_necessary (true);
FOR_EACH_TAIL (options)
- gcc_jit_context_add_driver_option (comp.ctxt,
- /* FIXME: Need to encode
- this, but how? either
- ENCODE_FILE or
- ENCODE_SYSTEM. */
- SSDATA (XCAR (options)));
-#endif
+ 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)));
+ }
if (CONSP (options))
xsignal1 (Qnative_compiler_error,
build_string ("Customizing native compiler options"
- " via `comp-native-driver-options' is"
+ " via `comp-native-compiler-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 ()))
+ /* Captured `comp-native-compiler-options' because file-local. */
+ if (!NILP (Fcomp_native_compiler_options_effective_p ()))
+ {
+ options = comp.compiler_options;
FOR_EACH_TAIL (options)
- gcc_jit_context_add_driver_option (comp.ctxt,
- /* FIXME: Need to encode
- this, but how? either
- ENCODE_FILE or
- ENCODE_SYSTEM. */
- SSDATA (XCAR (options)));
-#endif
+ 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)));
+ }
}
DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file,
@@ -4460,7 +4513,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 +4589,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 +5295,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 +5405,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
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
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
1 sibling, 0 replies; 24+ messages in thread
From: Andrea Corallo via Emacs development discussions. @ 2021-08-31 8:06 UTC (permalink / raw)
To: Arthur Miller; +Cc: Eli Zaretskii, emacs-devel
Arthur Miller <arthur.miller@live.com> writes:
[...]
>>
>> AFAIR that was the reason for that check so yes.
>>
>> Andrea
>
> Ok, I have made those changes. I have removed double checks from both
> add_driver_options () and add_compiler_options (). If it is not OK, I can made
> another one and revert back this change in add_driver_options.
>
> I have also renamed native-comp-driver-options to native-comp-backend-options.
>
> I forgott to ask, which Changelog are we talking about? Changelo.3 in top Emacs
> dir or some other file?
>
>>From d0c2b4f882fc67562de6ad67f6dcfdfe6378c32b Mon Sep 17 00:00:00 2001
> From: Arthur Miller <arthur.miller@live.com>
> Date: Tue, 31 Aug 2021 07:15:01 +0200
> Subject: [PATCH] Native comp: gcc cmdopts + rename driver-options to
> backend-options.
>
> ---
> lisp/emacs-lisp/bytecomp.el | 4 +-
> lisp/emacs-lisp/comp.el | 36 ++++++++---
> src/comp.c | 122 ++++++++++++++++++++++++++----------
> 3 files changed, 118 insertions(+), 44 deletions(-)
>
[...]
> #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) \
> @@ -4377,43 +4378,95 @@ 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);
> + Lisp_Object options = Fsymbol_value (Qnative_comp_backend_options);
>
> -#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_driver_option) \
This is still necessary to have the code compatible with old libgccjit.
> - || defined (WINDOWSNT)
> - load_gccjit_if_necessary (true);
> - if (!NILP (Fcomp_native_driver_options_effective_p ()))
> + if (!NILP (Fcomp_native_backend_options_effective_p ()))
> + {
> + load_gccjit_if_necessary (true);
> + FOR_EACH_TAIL (options)
> + gcc_jit_context_add_driver_option (comp.ctxt,
> + /* FIXME: Need to encode
> + this, but how? either
> + ENCODE_FILE or
> + ENCODE_SYSTEM. */
> + SSDATA (XCAR (options)));
> + }
> +
> + if (CONSP (options))
> + xsignal1 (Qnative_compiler_error,
> + build_string ("Customizing native compiler options"
> + " via `comp-native-backend-options' is"
> + " only available on libgccjit version 9"
> + " and above."));
> +
> + /* Captured `comp-native-backend-options' because file-local. */
> + if (!NILP (Fcomp_native_backend_options_effective_p ()))
> + {
> + options = comp.backend_options;
> + FOR_EACH_TAIL (options)
> + gcc_jit_context_add_driver_option (comp.ctxt,
> + /* FIXME: Need to encode
> + this, but how? either
> + ENCODE_FILE or
> + ENCODE_SYSTEM. */
> + SSDATA (XCAR (options)));
> + }
> +}
> +
> +static void
> +add_compiler_options (void)
> +{
> + Lisp_Object options = Fsymbol_value (Qnative_comp_compiler_options);
> +
> + if (!NILP (Fcomp_native_compiler_options_effective_p ()))
> + {
> + load_gccjit_if_necessary (true);
> FOR_EACH_TAIL (options)
> - gcc_jit_context_add_driver_option (comp.ctxt,
> - /* FIXME: Need to encode
> - this, but how? either
> - ENCODE_FILE or
> - ENCODE_SYSTEM. */
> - SSDATA (XCAR (options)));
> -#endif
> + 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)));
> + }
> if (CONSP (options))
> xsignal1 (Qnative_compiler_error,
> build_string ("Customizing native compiler options"
> - " via `comp-native-driver-options' is"
> + " via `comp-native-compiler-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) \
Same
TIA
Andrea
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
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
1 sibling, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2021-08-31 13:01 UTC (permalink / raw)
To: Arthur Miller; +Cc: emacs-devel, akrl
> From: Arthur Miller <arthur.miller@live.com>
> Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
> Date: Tue, 31 Aug 2021 07:36:47 +0200
>
> Ok, I have made those changes. I have removed double checks from both
> add_driver_options () and add_compiler_options (). If it is not OK, I can made
> another one and revert back this change in add_driver_options.
I think you should indeed do the latter.
> I forgott to ask, which Changelog are we talking about? Changelo.3 in top Emacs
> dir or some other file?
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.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
2021-08-31 13:01 ` Eli Zaretskii
@ 2021-08-31 22:53 ` Arthur Miller
2021-09-01 11:45 ` Eli Zaretskii
0 siblings, 1 reply; 24+ messages in thread
From: Arthur Miller @ 2021-08-31 22:53 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel, akrl
[-- Attachment #1: Type: text/plain, Size: 1314 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Arthur Miller <arthur.miller@live.com>
>> Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
>> Date: Tue, 31 Aug 2021 07:36:47 +0200
>>
>> Ok, I have made those changes. I have removed double checks from both
>> add_driver_options () and add_compiler_options (). If it is not OK, I can made
>> another one and revert back this change in add_driver_options.
>
> I think you should indeed do the latter.
>
>> I forgott to ask, which Changelog are we talking about? Changelo.3 in top Emacs
>> dir or some other file?
>
> 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.
I forgott to say, I have tested to sett options via Customize and it worked
fine, so I have also removed that 'FIXME' in comp.el next to '(repeat string)
option. Hope it is OK.
Since this is a user visible change, does it need to be documented in some
manual and NEWS too?
Best regards
/arthur
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ncomp-options.patch --]
[-- Type: text/x-patch, Size: 12274 bytes --]
From 52cc5d113bcb3b8c1b0654cc855c0857b2c0bb95 Mon Sep 17 00:00:00 2001
From: Arthur Miller <arthur.miller@live.com>
Date: Wed, 1 Sep 2021 00:50:49 +0200
Subject: [PATCH] Native comp add/change GCC command-line options
Added support for GCC command-line options via 'native-comp-compiler-options'.
Renamed 'native-comp-driver-options' to 'native-comp-backend-options'.
---
lisp/emacs-lisp/bytecomp.el | 4 +-
lisp/emacs-lisp/comp.el | 36 +++++++++++----
src/comp.c | 87 ++++++++++++++++++++++++++++++-------
3 files changed, 100 insertions(+), 27 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..7fb74c88d2 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,15 @@ 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 ()))
+ 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 +4431,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 +4512,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 +4588,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 +5294,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 +5404,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
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
2021-08-31 22:53 ` Arthur Miller
@ 2021-09-01 11:45 ` Eli Zaretskii
2021-09-01 14:23 ` Arthur Miller
0 siblings, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2021-09-01 11:45 UTC (permalink / raw)
To: Arthur Miller; +Cc: emacs-devel, akrl
> 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.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
2021-09-01 11:45 ` Eli Zaretskii
@ 2021-09-01 14:23 ` Arthur Miller
2021-09-01 16:45 ` Eli Zaretskii
0 siblings, 1 reply; 24+ messages in thread
From: Arthur Miller @ 2021-09-01 14:23 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel, akrl
[-- 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
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
2021-08-30 11:42 ` Eli Zaretskii
2021-08-30 12:59 ` Andrea Corallo via Emacs development discussions.
2021-08-30 14:01 ` Arthur Miller
@ 2021-09-01 14:58 ` Alex Bennée
2021-09-01 15:10 ` Perry E. Metzger
2021-09-01 16:04 ` Eli Zaretskii
2 siblings, 2 replies; 24+ messages in thread
From: Alex Bennée @ 2021-09-01 14:58 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Arthur Miller, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Arthur Miller <arthur.miller@live.com>
>> Date: Sun, 29 Aug 2021 23:47:56 +0200
>>
>> after the few mails the other day, I wasn't really sure if Andrea is going to
>> implement it and when. I thought it was rather a tedious manual labour and maybe
>> not so important, so I took me a liberty to implement this myself in my own, so
>> called, personal copy of Eamcs sources.
>
> Thanks.
>
>> I am not sure if I have done it correctly though, I appreciate if Andrea have
>> time to take a look; I have just mainly copied your code for backend options. It
>> seems to work for me, with a minor remark: When I pass a valid option, "native",
>> in place where it should go, I get an invalid option error. Gcc even lists it in
>> the error message as a valid option. Another option "skylake" works just
>> fine. This seems to vary between flags. I am not sure if this is some encoding
>> error from Emacs to libgccjit, or if it is some bug in libgccjit, or is it just
>> my brain having dumps.
>
> I guess -march=native is something handled by GCC itself, and here we
> don't have it? If you want to be sure, ask this question on the GCC
> list, or report as a bug to their Bugzilla.
Shouldn't we be ensuring -march=native for all JIT code anyway? Are the
native eln files ever considered portable/packagable or will they always
be a product of the users current system?
--
Alex Bennée
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
2021-09-01 14:58 ` Alex Bennée
@ 2021-09-01 15:10 ` Perry E. Metzger
2021-09-01 16:04 ` Eli Zaretskii
1 sibling, 0 replies; 24+ messages in thread
From: Perry E. Metzger @ 2021-09-01 15:10 UTC (permalink / raw)
To: emacs-devel
On 9/1/21 10:58, Alex Bennée wrote:
>
> Shouldn't we be ensuring -march=native for all JIT code anyway? Are the
> native eln files ever considered portable/packagable or will they always
> be a product of the users current system?
>
I believe the emacs binary itself contains native code in the new way of
doing things, though I believe most eln files are considered user specific.
Perry
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
2021-09-01 14:58 ` Alex Bennée
2021-09-01 15:10 ` Perry E. Metzger
@ 2021-09-01 16:04 ` Eli Zaretskii
1 sibling, 0 replies; 24+ messages in thread
From: Eli Zaretskii @ 2021-09-01 16:04 UTC (permalink / raw)
To: Alex Bennée; +Cc: arthur.miller, emacs-devel
> From: Alex Bennée <alex.bennee@linaro.org>
> Cc: Arthur Miller <arthur.miller@live.com>, emacs-devel@gnu.org
> Date: Wed, 01 Sep 2021 15:58:19 +0100
>
> > I guess -march=native is something handled by GCC itself, and here we
> > don't have it? If you want to be sure, ask this question on the GCC
> > list, or report as a bug to their Bugzilla.
>
> Shouldn't we be ensuring -march=native for all JIT code anyway? Are the
> native eln files ever considered portable/packagable or will they always
> be a product of the users current system?
I'm not sure it's the best default. GCC defaults are better, IMO,
certainly for the first release of this feature. GCC doesn't use some
default without a reason.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
2021-09-01 14:23 ` Arthur Miller
@ 2021-09-01 16:45 ` Eli Zaretskii
2021-09-01 21:06 ` Arthur Miller
0 siblings, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2021-09-01 16:45 UTC (permalink / raw)
To: Arthur Miller; +Cc: emacs-devel, akrl
> From: Arthur Miller <arthur.miller@live.com>
> Cc: akrl@sdf.org, emacs-devel@gnu.org
> Date: Wed, 01 Sep 2021 16:23:21 +0200
>
> > 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:
> * 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.
This part should look like this:
* lisp/emacs-lisp/comp.el ('native-comp-compiler-options): New option.
(native-comp-driver-options): Rename to 'native-comp-backend-options'.
* list/emacs-lisp/bytecomp.el: All users of 'native-comp-driver-options'
changed.
* src/comp.c (Fcomp_native_backend_options_effective_p): Renamed
from 'Fcomp_native_driver_options_effective_p'; all callers changed.
(Fcomp_native_compiler_options_effective_p): New function.
(add_driver_options): Remove WINDOWSNT condition.
(add_compiler_options): New function.
(Fcomp__compile_ctxt_to_file): Call 'add_compiler_options'.
IOW, you need to list not only the files, but also the functions and
global variables that you change.
This will be much easier if you use "C-x 4 a" or "C-c C-d" (the latter
in the VC log buffer): they will generate the skeleton with file name
and function name for you, so you need just add the description of the
change itself, what's after the colon.
(I can fix the log message for you this time, if you are exhausted ;-)
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Native compiler - passing command line options to C compiler
2021-09-01 16:45 ` Eli Zaretskii
@ 2021-09-01 21:06 ` Arthur Miller
0 siblings, 0 replies; 24+ messages in thread
From: Arthur Miller @ 2021-09-01 21:06 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel, akrl
[-- Attachment #1: Type: text/plain, Size: 3057 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 16:23:21 +0200
>>
>> > 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:
>> * 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.
>
> This part should look like this:
>
> * lisp/emacs-lisp/comp.el ('native-comp-compiler-options): New option.
> (native-comp-driver-options): Rename to 'native-comp-backend-options'.
> * list/emacs-lisp/bytecomp.el: All users of 'native-comp-driver-options'
> changed.
>
> * src/comp.c (Fcomp_native_backend_options_effective_p): Renamed
> from 'Fcomp_native_driver_options_effective_p'; all callers changed.
> (Fcomp_native_compiler_options_effective_p): New function.
> (add_driver_options): Remove WINDOWSNT condition.
> (add_compiler_options): New function.
> (Fcomp__compile_ctxt_to_file): Call 'add_compiler_options'.
>
> IOW, you need to list not only the files, but also the functions and
> global variables that you change.
And I who tried to be brief for once.
> This will be much easier if you use "C-x 4 a" or "C-c C-d" (the latter
> in the VC log buffer): they will generate the skeleton with file name
> and function name for you, so you need just add the description of the
> change itself, what's after the colon.
Aha. I never used Emacs vc functions, I just did everything from command line in
ansi-term. I have my bash aliases I am used to and most of my git interaction is
thru them.
I now have read about vc in the manual and looked around after you wrote this,
but I seem to be missing something in setup. I opened some vc log and C-c C-d
opened diff view as if I did a git format-patch which was nice, but then when I
actually run vc-register followed by vc-next-action, the opened log said that
diff something wasn't registered. I will try to read more and see if I can get
it to work, it seems useful to get skeleton with functions auto generated.
> (I can fix the log message for you this time, if you are exhausted ;-)
No worries, I have at least mastered git reset --soft HEAD~1. I did took your
text this time se we get over with it.
Thank you for your kind help and guidance.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ncomp-options.patch --]
[-- Type: text/x-patch, Size: 12921 bytes --]
From 22ba2fe39d17f264799263605d2a2bb5bc22bb7b Mon Sep 17 00:00:00 2001
From: Arthur Miller <arthur.miller@live.com>
Date: Wed, 1 Sep 2021 22:52:25 +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 ('native-comp-compiler-options): New option.
(native-comp-driver-options): Rename to 'native-comp-backend-options'.
* list/emacs-lisp/bytecomp.el: All users of 'native-comp-driver-options'
changed.
* src/comp.c (Fcomp_native_backend_options_effective_p): Renamed
from 'Fcomp_native_driver_options_effective_p'; all callers changed.
(Fcomp_native_compiler_options_effective_p): New function.
(add_driver_options): Remove WINDOWSNT condition.
(add_compiler_options): New function.
(Fcomp__compile_ctxt_to_file): Call 'add_compiler_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
^ permalink raw reply related [flat|nested] 24+ messages in thread
end of thread, other threads:[~2021-09-01 21:06 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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
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
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).