From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Native compiler - passing command line options to C compiler Date: Mon, 30 Aug 2021 14:42:21 +0300 Message-ID: <83bl5fkvky.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35142"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Arthur Miller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Aug 30 13:44:18 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mKfi6-0008u1-Ef for ged-emacs-devel@m.gmane-mx.org; Mon, 30 Aug 2021 13:44:18 +0200 Original-Received: from localhost ([::1]:39634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKfi4-0004bT-V7 for ged-emacs-devel@m.gmane-mx.org; Mon, 30 Aug 2021 07:44:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKfgP-0003os-D4 for emacs-devel@gnu.org; Mon, 30 Aug 2021 07:42:33 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:42832) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKfgO-00012h-Ou; Mon, 30 Aug 2021 07:42:32 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3060 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKfgO-0001wx-9N; Mon, 30 Aug 2021 07:42:32 -0400 In-Reply-To: (message from Arthur Miller on Sun, 29 Aug 2021 23:47:56 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:273475 Archived-At: > From: Arthur Miller > 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.