From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?=C3=93scar_Fuentes?= Newsgroups: gmane.emacs.help Subject: Re: clang fails to compile emacs in Microsoft Windows Date: Fri, 12 May 2023 17:47:25 +0200 Message-ID: <87mt29blgy.fsf@telefonica.net> References: <83v8gxbnd8.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34060"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:ifGAzfm4bKfNdbtzbACQLJ30HJ0= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 12 17:48:20 2023 Return-path: Envelope-to: geh-help-gnu-emacs@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 1pxV0G-0008fs-KY for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 12 May 2023 17:48:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxUzq-0004aN-Dm; Fri, 12 May 2023 11:47:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pxUzp-0004XF-A2 for help-gnu-emacs@gnu.org; Fri, 12 May 2023 11:47:53 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pxUzZ-0008Se-VX for help-gnu-emacs@gnu.org; Fri, 12 May 2023 11:47:52 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1pxUzV-0007YD-Qc for help-gnu-emacs@gnu.org; Fri, 12 May 2023 17:47:33 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=geh-help-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:143572 Archived-At: Eli Zaretskii writes: >> From: Biswapriyo Nath >> Date: Fri, 12 May 2023 19:41:17 +0530 >> >> * compiler: >> clang version 16.0.2 >> Target: x86_64-w64-windows-gnu >> Thread model: posix >> >> * compiler error: >> >> ../../src/sysdep.c:472:13: error: call to undeclared function >> 'waitpid'; ISO C99 and later do not support implicit function >> declarations [-Wimplicit-function-declaration] >> ../../src/sysdep.c:518:43: error: use of undeclared identifier 'WNOHANG' >> >> * Probable reason: >> >> AC_HEADER_SYS_WAIT fails to check sys/wait.h file. It tests with >> wait() function which is undefined in nt/inc/sys/wait.h file. Here is >> the error message from config.log >> >> configure:11452: checking for sys/wait.h that is POSIX.1 compatible >> configure:11479: x86_64-w64-mingw32-cc -I ../nt/inc -c -g3 -O2 >> -gdwarf-2 -mtune=generic -D__USE_MINGW_ANSI_STDIO=1 conftest.c >&5 >> conftest.c:70:3: error: call to undeclared function 'wait'; ISO C99 >> and later do not support implicit function declarations >> [-Wimplicit-function-declaration] >> >> I can provide further information if required. Thank you. > > Thanks, but Clang is not supported for building Emacs on MS-Windows. > We only support MinGW GCC. Unless someone steps up and takes upon > themselves the job of supporting the Clang build, this will remain so. > Supporting the MS-Windows build is hard and thankless job as it is; > adding another compiler on top of that is just too much. > > Sorry. I think that the problem reported by the OP was introduced recently (and, by the looks of it, it is problematic not just because of Clang, but as a C construct, because it seems to rely on an implicit function declaration. Yes, I've seen the thread on gcc-devel, so no need to explain things further). Emacs 28.2 compiles with Clang on Windows with this simple patch: diff -aur emacs-28.2-orig/configure.ac emacs-28.2/configure.ac --- emacs-28.2-orig/configure.ac 2022-09-07 06:24:51.000000000 +0800 +++ emacs-28.2/configure.ac 2022-10-09 20:40:07.436552500 +0800 @@ -147,7 +147,7 @@ fi cc_target=`$cc -v 2>&1 | sed -n 's/Target: //p'` case "$cc_target" in - *-*) host=$cc_target + *-*) host=$target_alias ;; "") AC_MSG_ERROR([Impossible to obtain $cc compiler target. Please explicitly provide --host.]) @@ -5765,8 +5765,8 @@ mingw32) ## Is it any better under MinGW64 to relocate emacs into higher addresses? case "$canonical" in - x86_64-*-*) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x400000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;; - *) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;; + x86_64-*-*) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-image-base,0x400000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;; + *) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-image-base,0x01000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;; esac ## If they want unexec, disable Windows ASLR for the Emacs binary if test "$with_dumping" = "unexec"; then and this one for UCRT in general: --- emacs-28.1/nt/cmdproxy.c.orig 2022-06-23 19:24:10.845481100 +0200 +++ emacs-28.1/nt/cmdproxy.c 2022-06-23 19:24:19.271132900 +0200 @@ -35,6 +35,10 @@ #include /* strlen */ #include /* isspace, isalpha */ +#ifdef _UCRT +#define _snprintf snprintf +#endif + /* We don't want to include stdio.h because we are already duplicating lots of it here */ extern int _snprintf (char *buffer, size_t count, const char *format, ...); --- emacs-28.1/src/sysdep.c.orig 2022-06-23 20:59:02.252891700 +0200 +++ emacs-28.1/src/sysdep.c 2022-06-23 21:05:31.998322600 +0200 @@ -2693,7 +2693,9 @@ if (close_stream (stdout) != 0) { +#ifndef _UCRT // XXX: close_stream(stdout) fails for some reason emacs_perror ("Write error to standard output"); _exit (EXIT_FAILURE); +#endif } /* Do not close stderr if addresses are being sanitized, as the @@ -2702,7 +2704,11 @@ if (err | (ADDRESS_SANITIZER ? fflush (stderr) != 0 || ferror (stderr) : close_stream (stderr) != 0)) +#ifndef _UCRT // XXX: close_stream(stderr) fails for some reason _exit (EXIT_FAILURE); +#else + ; +#endif } #ifndef DOS_NT Those patches are kept in the MSYS2/Mingw-packages repository and we provide clang-built Emacs 28.x binary packages. I think that the OP was not requesting support from the Emacs maintainers specifically, that's why he posted under -help and not under -devel or -bugs.