Bug 33281 - gfortran crt2.o not found under Vista
Summary: gfortran crt2.o not found under Vista
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.2.2
: P3 major
Target Milestone: 4.3.0
Assignee: Francois-Xavier Coudert
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: patch
: 30972 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-09-02 09:45 UTC by Daniel Heynderickx
Modified: 2008-02-23 05:14 UTC (History)
3 users (show)

See Also:
Host: i386-pc-mingw32
Target: i386-pc-mingw32
Build: i386-pc-mingw32
Known to work:
Known to fail:
Last reconfirmed: 2007-09-06 09:56:19


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Heynderickx 2007-09-02 09:45:18 UTC
I'm trying to run gfortran under Windows Vista. I ran into "ld: crt2.o: No such file". I've found several reports on this, but no solution... Is there a solution available already?
Comment 1 Francois-Xavier Coudert 2007-09-03 05:10:28 UTC
(In reply to comment #0)
> I'm trying to run gfortran under Windows Vista.

Do you compile yourself or use pre-made binaries (and which binaries)? What version of gfortran do you use? If you build the compiler yourself, do you use cygwin or mingw?

> I ran into "ld: crt2.o: No such
> file". I've found several reports on this, but no solution...

What does the compiler say when you add the -v flag? ("gfortran -v myfile.f90") What is the value of your PATH environment variable?
Comment 2 Danny Smith 2007-09-04 00:47:28 UTC
The solution is to build gcc/gfortran wiith -D__USE_MINGW_ACCESS in CFLAGS;
From mingw/include/io.h

/* Some defines for _access nAccessMode (MS doesn't define them, but
 * it doesn't seem to hurt to add them). */
#define	F_OK	0	/* Check for file existence */
/* Well maybe it does hurt.  On newer versions of MSVCRT, an access mode
   of 1 causes invalid parameter error. */   
#define	X_OK	1	/* MS access() doesn't check for execute permission. */
#define	W_OK	2	/* Check for write permission */
#define	R_OK	4	/* Check for read permission */


and later:
#ifdef __USE_MINGW_ACCESS
/*  Old versions of MSVCRT access() just ignored X_OK, while the version
    shipped with Vista, returns an error code.  This will restore the
    old behaviour  */
static inline int __mingw_access (const char* __fname, int __mode)
  { return  _access (__fname, __mode & ~X_OK); }
#define access(__f,__m)  __mingw_access (__f, __m)
#endif

Danny
Comment 3 Daniel Heynderickx 2007-09-05 06:21:27 UTC
Subject: Re:  gfortran crt2.o not found under Vista



fxcoudert at gcc dot gnu dot org wrote:
> ------- Comment #1 from fxcoudert at gcc dot gnu dot org  2007-09-03 10:40 -------
> (In reply to comment #0)
>> I'm trying to run gfortran under Windows Vista.
> 
> Do you compile yourself or use pre-made binaries (and which binaries)?
I use the binaries for version 4.2.2, native Windows version, from
http://gcc.gnu.org/wiki/GFortranBinaries


> 
> What does the compiler say when you add the -v flag? ("gfortran -v myfile.f90")
> What is the value of your PATH environment variable?
the compilation works fine, the error occurs at the link phase:
" ld: crt2.o: No such file: No such file or directory"


Comment 4 Daniel Heynderickx 2007-09-05 07:28:18 UTC
Subject: Re:  gfortran crt2.o not found under Vista

I was hoping to avoid having to do the build. If all else fails, I'll 
try it.

Thnx for your help.

dannysmith at users dot sourceforge dot net wrote:
> ------- Comment #2 from dannysmith at users dot sourceforge dot net  2007-09-04 06:17 -------
> The solution is to build gcc/gfortran wiith -D__USE_MINGW_ACCESS in CFLAGS;
>>From mingw/include/io.h
> 
> /* Some defines for _access nAccessMode (MS doesn't define them, but
>  * it doesn't seem to hurt to add them). */
> #define F_OK    0       /* Check for file existence */
> /* Well maybe it does hurt.  On newer versions of MSVCRT, an access mode
>    of 1 causes invalid parameter error. */   
> #define X_OK    1       /* MS access() doesn't check for execute permission. */
> #define W_OK    2       /* Check for write permission */
> #define R_OK    4       /* Check for read permission */
> 
> 
> and later:
> #ifdef __USE_MINGW_ACCESS
> /*  Old versions of MSVCRT access() just ignored X_OK, while the version
>     shipped with Vista, returns an error code.  This will restore the
>     old behaviour  */
> static inline int __mingw_access (const char* __fname, int __mode)
>   { return  _access (__fname, __mode & ~X_OK); }
> #define access(__f,__m)  __mingw_access (__f, __m)
> #endif
> 
> Danny
> 
> 

Comment 5 Francois-Xavier Coudert 2007-09-05 07:55:32 UTC
(In reply to comment #2)
> The solution is to build gcc/gfortran wiith -D__USE_MINGW_ACCESS in CFLAGS

It might be worth putting into the tree. Danny, would you be OK with the following?

Index: configure.ac
===================================================================
--- configure.ac        (revision 127859)
+++ configure.ac        (working copy)
@@ -974,8 +974,10 @@
     host_makefile_frag="config/mh-cygwin"
     ;;
   *-mingw32*)
+    host_makefile_frag="config/mh-mingw"
     ;;
   *-mingw64*)
+    host_makefile_frag="config/mh-mingw"
     ;;
   *-interix*)
     host_makefile_frag="config/mh-interix"
Index: config/mh-mingw
===================================================================
--- config/mh-mingw     (revision 0)
+++ config/mh-mingw     (revision 0)
@@ -0,0 +1,3 @@
+# Add -D__USE_MINGW_ACCESS to enable the built compiler to work on Windows
+# Vista (see PR33281 for details).
+BOOT_CFLAGS += -D__USE_MINGW_ACCESS
Comment 6 Francois-Xavier Coudert 2007-09-05 10:28:03 UTC
Daniel,

Can you try the updated binaries at http://quatramaran.ens.fr/~coudert/gfortran/gfortran-windows.exe ? They are built with the patch in comment #5.
Comment 7 Daniel Heynderickx 2007-09-06 02:15:49 UTC
Subject: Re:  gfortran crt2.o not found under Vista

It works!

Thank you very much for this quick response!

Daniel

fxcoudert at gcc dot gnu dot org wrote:
> ------- Comment #6 from fxcoudert at gcc dot gnu dot org  2007-09-05 15:58 -------
> Daniel,
> 
> Can you try the updated binaries at
> http://quatramaran.ens.fr/~coudert/gfortran/gfortran-windows.exe ? They are
> built with the patch in comment #5.
> 
> 

Comment 8 Francois-Xavier Coudert 2007-09-06 10:12:15 UTC
Subject: Bug 33281

Author: fxcoudert
Date: Thu Sep  6 15:42:02 2007
New Revision: 128188

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128188
Log:
	PR target/33281
	* configure.ac: Use config/mh-mingw on mingw.
	* configure: Regenerate.
	* config/mh-mingw: New host makefile fragment.

Added:
    trunk/config/mh-mingw
Modified:
    trunk/ChangeLog
    trunk/configure
    trunk/configure.ac

Comment 9 Francois-Xavier Coudert 2007-09-06 10:17:36 UTC
Fix committed to mainline.
Comment 10 Francois-Xavier Coudert 2007-09-06 12:09:33 UTC
*** Bug 30972 has been marked as a duplicate of this bug. ***
Comment 11 Keith Marshall 2008-01-14 06:45:53 UTC
(In reply to comment #9)
> Fix committed to mainline.
> 

As a MinGW administrator, I am dismayed that you consider this __USE_MINGW_ACCESS kludge as a solution to this bug; I would like this particularly nasty kludge to go away, from the MinGW code base, as soon as is practicably possible.

My own view on this is, that since X_OK has no meaning on any platform supported by MinGW, our headers simply should not define it.  Danny Smith has advised me that I cannot do that, since GCC needs it, if I don't define it, GCC will give an arbitrary value of one, which will simply reintroduce the old broken behaviour; IMO, that is wrong: if I don't define it, then it is because it should not be used, and GCC should respect that.

Danny has further advised me that, if I were to adopt the next best compromise, and define X_OK with a value of zero, that that too would break GCC, because it uses X_OK in other contexts than the mode argument to access(), and in those contexts the value of zero would not work.  If this is indeed the case, then I would respectfully suggest that such usage is a violation of IEEE-1003.1, which explicitly defines F_OK, R_OK, W_OK and X_OK for use as values for composing the mode argument to access(), (and for no other purpose).

Regards,
Keith.
Comment 12 Francois-Xavier Coudert 2008-02-23 05:14:57 UTC
(In reply to comment #11)
> As a MinGW administrator, I am dismayed that you consider this
> __USE_MINGW_ACCESS kludge as a solution to this bug; I would like this
> particularly nasty kludge to go away, from the MinGW code base, as soon as is
> practicably possible.

You're welcome to contribute and provide a patch that implements your idea of what would we the Right Thing To Do, as long as it doesn't break support of existing MinGW versions. Post your patch to the gcc-patches mailing-list and it will be reviewed.

Thanks for helping,
FX