unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: Issues with Windows gcc -mno-cygwin (Mingw)
@ 2003-03-19  7:39 David PONCE
  2003-03-19  8:41 ` Jason Rumney
  2003-03-19 23:40 ` Benjamin Riefenstahl
  0 siblings, 2 replies; 14+ messages in thread
From: David PONCE @ 2003-03-19  7:39 UTC (permalink / raw)
  Cc: emacs-devel

Hi Jason,

>>- Problem with _fmode (global MSC variable set to O_BINARY as the
>>  default file mode).  For a simple patch see below.  Strictly
>>  speaking I think the real problem is that this is not handled
>>  without the _fmode hack.  The code should just use its own global
>>  variable (or even more simply just add O_BINARY everywhere) instead
>>  of using this brittle compiler/runtime dependent solution.
> 
> 
> I don't understand what problem this is fixing. Can you explain some
> more?

I use latest versions of native mingw tools (not through cygwin):

- gcc 3.2.2 (mingw special 20030208-1)
- binutils 2.13.90-20030111-1
- mingw-runtime 2.4
- w32api 2.2

I also encountered that problem, with latest versions of the
mingw-runtime (2.3, 2.4).

Since these versions, the default runtime _fmode is text mode.
Because of that, I noticed that Emacs incorrectly reads some data,
and I got runtime errors, particularly in the function
"get_doc_string" in doc.c.

I followed the examples given by the mingw team, and did the
following patch, that I put in sysdep.c.  Since that, my Emacs works
like a charm!

Notice that I had to do the same thing with the latest pretest
21.2.95, to fix similar problems.

Hope it will help.
David

Index: src/sysdep.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/sysdep.c,v
retrieving revision 1.248
diff -c -r1.248 sysdep.c
*** src/sysdep.c	4 Feb 2003 14:03:13 -0000	1.248
--- src/sysdep.c	19 Mar 2003 07:29:14 -0000
***************
*** 3231,3236 ****
--- 3231,3248 ----
  #endif /* not WINDOWSNT */
  #endif /* ! HAVE_STRERROR */
  \f
+ /*
+   Since version 2.3 mingw-runtime default IO mode is textmode.
+   That causes invalid data to be read by Emacs, which in turn causes
+   various execution failures.  Changing default runtime IO mode to
+   binary, when mingw-runtime is > 2.2, avoid that.
+ */
+ #if defined(WINDOWSNT) && defined (__MINGW32__) \
+   && __MINGW32_MAJOR_VERSION >= 2 && __MINGW32_MINOR_VERSION > 2
+ #include <fcntl.h>              /* _O_BINARY */
+ int _CRT_fmode = _O_BINARY;
+ #endif
+ 
  int
  emacs_open (path, oflag, mode)
       const char *path;

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Issues with Windows gcc -mno-cygwin (Mingw)
@ 2003-05-14  7:27 David PONCE
  0 siblings, 0 replies; 14+ messages in thread
From: David PONCE @ 2003-05-14  7:27 UTC (permalink / raw)


Hi All,

Would it be possible to commit this patch from Benjamin Riefenstahl:

<http://mail.gnu.org/archive/html/emacs-devel/2003-03/msg00440.html>

that fixes errors in NTEmacs when run with latest versions of mingw
runtime?

Notice that I had to apply a similar patch to 21.3 for the same
reason:

<http://mail.gnu.org/archive/html/help-emacs-windows/2003-03/msg00067.html>

Sincerely,
David

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Issues with Windows gcc -mno-cygwin (Mingw)
@ 2003-03-19  9:29 David PONCE
  0 siblings, 0 replies; 14+ messages in thread
From: David PONCE @ 2003-03-19  9:29 UTC (permalink / raw)
  Cc: emacs-devel

> The default runtime _fmode is text with all Windows compilers. Why is
> this a problem only for mingw32's 20030208 build of GCC 3.2.2?

I am sorry, it seems my messages wasn't clear enough.  The problem is
not related to the compiler (I got the same results with gcc 3.1 and
3.2).  It is related to changes made in mingw-runtime between version
2.2 and 2.3.  With mingw-runtime 2.2, Emacs compiles and run OOTB.
With runtime 2.3 and 2.4, Emacs compiles OOTB, but fails at execution
time with random errors, because of invalid data read.

Here is an excerpt of the change log of mingw-runtime 2.3, which I
think is related to IO mode change:

2002-10-19  Danny Smith  

	* crt1.c: Define new macro __IN_MINGW_RUNTIME before including
	stdlib.h.
	Define WIN32_MEAN_AND_LEAN before including windows.h
	* include/stdlib.h (_fmode): Protect declaration as dllimported
	variable with __IN_MINGW_RUNTIME.

2002-10-19  Igor Pechtchanski  

	* crt1.c: Include stdlib.h.

2002-10-19  Danny Smith  

	* Makefile.in (CRT0S): Add txtmode.o binmode.o.
	(MINGW_OBJS): Add txtmode.o.
	(SRCDIST_FILES): Add txtmode.c binmode.c.
	crt1.c: Don't include fcntrl.h, stdlib.h.
	(_fmode): Declare, without dllimport attribute.
	(__p__fmode): Declare access function for dll's _fmode.
	(_mingw32_init_fmode): Sync dll _fmode with staticly linked
	_fmode for app.
	* txtmode.c: New file.
	* binmode.c: New file.
	* samples/fmode/test2.c: New file.
	* samples/fmode/jamfile: Add test2.exe target.

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Issues with Windows gcc -mno-cygwin (Mingw)
@ 2003-03-18 17:14 Benjamin Riefenstahl
  2003-03-18 17:54 ` Eli Zaretskii
  2003-03-18 18:26 ` Jason Rumney
  0 siblings, 2 replies; 14+ messages in thread
From: Benjamin Riefenstahl @ 2003-03-18 17:14 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 978 bytes --]

Hi all,


I have compiled the CVS HEAD with the Cygwin Mingw cross-environment
(gcc -mno-cygwin).  I have had two problems:

- The cygpath issue.  The Makefiles have the necessary code to use the
  Cygwin cygpath utility, but it's commented out.  I appreciate that
  the situation is not very stable in that area, but could we consider
  a conditional and a configure item for this?  We do need that code
  as long as we want Emacs to support Cygwin at compile-time, but not
  at run-time, because without that code the Makefile will provide
  Cygwin paths to ELisp.

- Problem with _fmode (global MSC variable set to O_BINARY as the
  default file mode).  For a simple patch see below.  Strictly
  speaking I think the real problem is that this is not handled
  without the _fmode hack.  The code should just use its own global
  variable (or even more simply just add O_BINARY everywhere) instead
  of using this brittle compiler/runtime dependent solution.


so long, benny


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fmode.diff --]
[-- Type: text/x-patch, Size: 600 bytes --]

Index: unexw32.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/unexw32.c,v
retrieving revision 1.22
diff -c -r1.22 unexw32.c
*** unexw32.c	4 Feb 2003 14:03:13 -0000	1.22
--- unexw32.c	18 Mar 2003 16:19:04 -0000
***************
*** 83,88 ****
--- 83,92 ----
  
  PIMAGE_SECTION_HEADER heap_section;
  
+ /* Needed by the Mingw CRT to override _fmode, setting down in _start
+    doesn't work, it gets reset somewhere in mainCRTStartup() */
+ int _fmode = O_BINARY;
+ 
  #ifdef HAVE_NTGUI
  HINSTANCE hinst = NULL;
  HINSTANCE hprevinst = NULL;

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2003-05-14  7:27 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-19  7:39 Issues with Windows gcc -mno-cygwin (Mingw) David PONCE
2003-03-19  8:41 ` Jason Rumney
2003-03-19 23:44   ` Benjamin Riefenstahl
2003-03-19 23:40 ` Benjamin Riefenstahl
  -- strict thread matches above, loose matches on Subject: below --
2003-05-14  7:27 David PONCE
2003-03-19  9:29 David PONCE
2003-03-18 17:14 Benjamin Riefenstahl
2003-03-18 17:54 ` Eli Zaretskii
2003-03-19 23:31   ` Benjamin Riefenstahl
2003-03-20  4:30     ` Eli Zaretskii
2003-03-20  8:29     ` Jason Rumney
2003-03-20 16:21       ` Benjamin Riefenstahl
2003-03-18 18:26 ` Jason Rumney
2003-03-19 23:36   ` Benjamin Riefenstahl

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).