View Issue Details

IDProjectCategoryView StatusLast Update
0000531GCC - GNU C CompilerBugpublic2020-08-24 03:13
Reporterkomh Assigned Topsmedley  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Summary0000531: gcc 4.4.6 treat a non-option argument as a output file
DescriptionHi/2.

gcc 4.4.6 does not generate the executable unless -o is specified.

For examples,

    gcc -lpthread test.c

The above generate -lpthread.exe instead of test.exe. Of course, pthread.a should exist.

    gcc -Zomf -lpthread test.c

this is also true.

Steps To Reproducegcc -lpthread test.c

gcc -Zomf -lpthread test.c
TagsNo tags attached.
Attached Files
0001-OS-2-Use-the-first-file-that-a-compiler-to-compile-i.patch (1,195 bytes)   
From 4b41d498be392a4489dd4d35c8df7b0212e24b8e Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh@chollian.net>
Date: Sun, 29 Apr 2012 18:09:01 +0900
Subject: [PATCH] OS/2: Use the first file that a compiler to compile it as an input file

---
 gcc/gcc.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/gcc/gcc.c b/gcc/gcc.c
index c113e90..939d616 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -6823,22 +6823,21 @@ main (int argc, char **argv)
      with %b in LINK_SPEC. We use the first input file that we can find
      a compiler to compile it instead of using infiles.language since for
      languages other than C we use aliases that we then lookup later.  */
-#ifndef __EMX__ /* This code fails on OS/2 - revert to the GCC 3.4.6 code */
   if (n_infiles > 0)
     {
       int i;
 
       for (i = 0; i < n_infiles ; i++)
+#ifndef __EMX__
 	if (infiles[i].language && infiles[i].language[0] != '*')
+#else
+	if (!infiles[i].language || infiles[i].language[0] != '*')
+#endif
 	  {
 	    set_input (infiles[i].name);
 	    break;
 	  }
     }
-#else
-  if (n_infiles > 0)
-    set_input (infiles[0].name);
-#endif
 
   if (error_count == 0)
     {
-- 
1.7.3.2

Activities

psmedley

2012-04-10 03:53

administrator   ~0002234

what is the behaviour on other platforms?

komh

2012-04-15 04:25

reporter   ~0002235

gcc 4.6.1 of MingW generates 'a.exe'.

komh

2012-04-15 09:52

reporter   ~0002236

gcc 4.6.1 on Ubutu 11 generates 'a.out' unless -o is specified.

komh

2012-04-15 09:55

reporter   ~0002237

gcc 2.8.1 of emx 0.9d genereates test.exe.

gcc 3.2.1 for emx generates -lpthread.exe

psmedley

2012-04-22 10:02

administrator   ~0002242

I have some ideas on why this happens - GCC/2 has some weird stuff for adding .exe in gcc.c over and above what's used for windows - I've always planned on exploring what that does - perhaps backing it out will fix your issue - I will try look at it soon.

psmedley

2012-04-25 09:38

administrator   ~0002252

ok - my original thought was wrong - I think the following in LINK_SPEC in emx.h is the problem:

  "%{!o*:-o %b%{Zdll|shared:.dll}%{!Zdll:%{!shared:%{!Zexe:.exe}}}} " \

I believe this adds a -o %b if o isn't a parameter.

In STABS code - %b is:

 %b substitute the basename of the input file being processed.
    This is the substring up to (and not including) the last period
    and not including the directory.

So this _should_ be OK but clearly isn't. Building a gcc.exe without that line and will see what happens

psmedley

2012-04-26 09:22

administrator   ~0002254

OK - getting there - now I get a.out as the result of 'gcc -lpthread test.c'

Just need to produce an executable now :P

psmedley

2012-04-26 09:48

administrator   ~0002256

[U:\DEV\t]gcc -Zomf -lpthread test.c
emxomfld: no output file, creating $$$.exe or $$$.dll

komh

2012-04-29 09:18

reporter   ~0002257

I attach a patch, review please.

psmedley

2012-05-07 09:35

administrator   ~0002264

Hi KO - your patch works nicely!

komh

2012-05-08 11:56

reporter   ~0002266

Good to know that.

If so, is it possible to get the fixed build ?

Strangely, my build has a problem with -pipe option.

psmedley

2012-05-16 09:25

administrator   ~0002267

http://smedley.id.au/gcc446.zip

komh

2012-05-19 07:35

reporter   ~0002270

Thanks.

Issue History

Date Modified Username Field Change
2012-04-09 04:29 komh New Issue
2012-04-10 03:53 psmedley Note Added: 0002234
2012-04-15 04:25 komh Note Added: 0002235
2012-04-15 09:52 komh Note Added: 0002236
2012-04-15 09:55 komh Note Added: 0002237
2012-04-22 10:02 psmedley Note Added: 0002242
2012-04-25 06:57 psmedley Assigned To => psmedley
2012-04-25 06:57 psmedley Status new => assigned
2012-04-25 09:38 psmedley Note Added: 0002252
2012-04-26 09:22 psmedley Note Added: 0002254
2012-04-26 09:48 psmedley Note Added: 0002256
2012-04-29 09:18 komh Note Added: 0002257
2012-04-29 09:19 komh File Added: 0001-OS-2-Use-the-first-file-that-a-compiler-to-compile-i.patch
2012-05-07 09:35 psmedley Note Added: 0002264
2012-05-08 11:56 komh Note Added: 0002266
2012-05-16 09:25 psmedley Note Added: 0002267
2012-05-19 07:35 komh Note Added: 0002270
2012-11-15 20:24 psmedley Status assigned => resolved
2012-11-15 20:24 psmedley Resolution open => fixed
2020-08-24 03:13 psmedley Status resolved => closed