From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: MS-Windows build using Posix configury Date: Fri, 17 May 2013 21:43:47 +0300 Message-ID: <83zjvtqwf0.fsf@gnu.org> References: <83d2tu49lu.fsf@gnu.org> <837gjhnowi.fsf@gnu.org> <8338u4o39r.fsf@gnu.org> <83zjwbkmt2.fsf@gnu.org> <83wqrfkjvo.fsf@gnu.org> <838v3qebns.fsf@gnu.org> <83wqr9csah.fsf@gnu.org> <83wqr297da.fsf@gnu.org> <83txm34g6k.fsf@gnu.org> <83d2srt645.fsf@gnu.org> <87y5bfkmsz.fsf@yandex.ru> <834ne3sziw.fsf@gnu.org> <519504DD.1030004@yandex.ru> <8338tmu9m0.fsf@gnu.org> <83hai2rlm0.fsf@gnu.org> <51961D09.7030502@yandex.ru> <83d2spsqa1.fsf@gnu.org> <519638A0.70807@[87.69.4.28]> <837gixsmwh.fsf@gnu.org> <51964CD3.1010106@yandex.ru> <8338tlsibr.fsf@gnu.org> <831u95sdwi.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1368816293 7969 80.91.229.3 (17 May 2013 18:44:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 17 May 2013 18:44:53 +0000 (UTC) Cc: emacs-devel@gnu.org To: dgutov@yandex.ru Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 17 20:44:52 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UdPe7-0001qp-I2 for ged-emacs-devel@m.gmane.org; Fri, 17 May 2013 20:44:51 +0200 Original-Received: from localhost ([::1]:43797 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdPe7-0000k6-65 for ged-emacs-devel@m.gmane.org; Fri, 17 May 2013 14:44:51 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdPe2-0000jr-Qf for emacs-devel@gnu.org; Fri, 17 May 2013 14:44:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UdPe1-0003v9-JI for emacs-devel@gnu.org; Fri, 17 May 2013 14:44:46 -0400 Original-Received: from mtaout21.012.net.il ([80.179.55.169]:57332) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdPe1-0003uv-9S for emacs-devel@gnu.org; Fri, 17 May 2013 14:44:45 -0400 Original-Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0MMY00G00HCOON00@a-mtaout21.012.net.il> for emacs-devel@gnu.org; Fri, 17 May 2013 21:44:04 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MMY00GNHHDFFLJ0@a-mtaout21.012.net.il>; Fri, 17 May 2013 21:44:04 +0300 (IDT) In-reply-to: <831u95sdwi.fsf@gnu.org> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.169 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:159651 Archived-At: > Date: Fri, 17 May 2013 20:40:45 +0300 > Sun-Java-System-SMTP-Warning: Lines longer than SMTP allows found and > truncated. > From: Eli Zaretskii > Cc: emacs-devel@gnu.org > > > Looks like another good candidate for mentioning in INSTALL.MSYS. > > I'd rather we unload all the DLLs before we exit, to avoid such > problems in the first place. Like in the patch below. Can you try that? (I hope you still have that libintl-8.dll somewhere which required libgcc_s_dw2-1.dll, and can reinstate it at least for the purposes of testing this patch.) === modified file 'src/w32.c' --- src/w32.c 2013-04-15 13:39:41 +0000 +++ src/w32.c 2013-05-17 18:39:41 +0000 @@ -7404,13 +7404,9 @@ sys_localtime (const time_t *t) /* Try loading LIBRARY_ID from the file(s) specified in Vdynamic_library_alist. If the library is loaded successfully, - return the handle of the DLL, and record the filename in the - property :loaded-from of LIBRARY_ID. If the library could not be - found, or when it was already loaded (because the handle is not - recorded anywhere, and so is lost after use), return NULL. - - We could also save the handle in :loaded-from, but currently - there's no use case for it. */ + return the handle of the DLL, and record the filename and the + handle in the property :loaded-from of LIBRARY_ID. If the library + could not be found, or when it was already loaded, return NULL. */ HMODULE w32_delayed_load (Lisp_Object library_id) { @@ -7434,11 +7430,12 @@ w32_delayed_load (Lisp_Object library_id DWORD len; len = GetModuleFileNameA (library_dll, name, sizeof (name)); - found = Fcons (XCAR (dlls), - (len > 0) - /* Possibly truncated */ - ? make_specified_string (name, -1, len, 1) - : Qnil); + found = list3 (XCAR (dlls), + ((len > 0) + /* Possibly truncated */ + ? make_specified_string (name, -1, len, 1) + : Qnil), + XIL ((EMACS_INT)library_dll)); break; } } @@ -7449,6 +7446,36 @@ w32_delayed_load (Lisp_Object library_id return library_dll; } +/* Unload any dynamic libraries we loaded. Called at exit. */ +static void +unload_dlls (void) +{ + Lisp_Object dyn_alist = Vdynamic_library_alist; + + while (CONSP (dyn_alist)) + { + Lisp_Object elt = XCAR (dyn_alist), sym = Qnil; + Lisp_Object loaded_from = Qnil; + + if (CONSP (elt)) + { + sym = XCAR (elt); + if (SYMBOLP (sym)) + loaded_from = Fget (sym, QCloaded_from); + } + + if (CONSP (loaded_from) + && CONSP (XCDR (XCDR (loaded_from))) + && INTEGERP (XCAR (XCDR (XCDR (loaded_from))))) + { + HANDLE lh = (HANDLE)XLI (XCAR (XCDR (XCDR (loaded_from)))); + + FreeLibrary (lh); + } + dyn_alist = XCDR (dyn_alist); + } +} + void check_windows_init_file (void) @@ -7505,6 +7532,8 @@ term_ntproc (int ignored) { (void)ignored; + unload_dlls (); + term_timers (); /* shutdown the socket interface if necessary */