Bug 20530 - gnatlink does not respect -mno-cygwin
Summary: gnatlink does not respect -mno-cygwin
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 3.4.1
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-18 10:03 UTC by Rolf Ebert
Modified: 2005-07-23 22:49 UTC (History)
3 users (show)

See Also:
Host: i686-pc-cygwin
Target: i686-pc-mingw32
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rolf Ebert 2005-03-18 10:03:54 UTC
despite passing -mno-cygwin as a gnatmake option and additionally as a gnatlink 
option, gnatlink adds the cygwin path to adalib to the link command. The libgnat 
 is found first in the cygwin path and not in the mingw path.  The link 
consequently fails.

The problem is present on both gcc-3.3.3 and gcc-3.4.1

$ gnatmake -mno-cygwin hello -largs -v -v -mno-cygwin
gcc -c -mno-cygwin hello.adb
gnatbind -x hello.ali
gnatlink -v -v -mno-cygwin hello.ali

GNATLINK 3.3.3 (cygwin special) Copyright 1996-2002 Free Software Foundation, In
c.
gcc -c -gnatA -gnatWb -gnatiw -mno-cygwin -v -gnatws b~hello.adb
Reading specs from /usr/lib/gcc-lib/i686-pc-mingw32/3.3.3/specs
Configured with: /gcc/gcc-3.3.3-3/configure --verbose --prefix=/usr --exec-prefi
x=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/s
hare/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,java,objc,
pascal --enable-nls --without-included-gettext --enable-libgcj --with-system-zli
b --enable-interpreter --enable-threads=posix --enable-java-gc=boehm --enable-sj
lj-exceptions --disable-version-specific-runtime-libs --disable-win32-registry
Thread model: posix
gcc version 3.3.3 (cygwin special)
 /usr/lib/gcc-lib/i686-pc-mingw32/3.3.3/gnat1.exe -quiet -dumpbase b~hello.adb -
gnatA -gnatWb -gnatiw -gnatws -mno-cygwin b~hello.adb -o /c/DOKUME~1/EBERT/LOKAL
E~1/Temp/ccsNrn8f.s
 /usr/lib/gcc-lib/i686-pc-mingw32/3.3.3/../../../../i686-pc-mingw32/bin/as.exe -
-traditional-format -o b~hello.o /c/DOKUME~1/EBERT/LOKALE~1/Temp/ccsNrn8f.s
/usr/bin/gcc.exe b~hello.o ./hello.o -v -mno-cygwin -o hello.exe -L./ -L/usr/lib
/gcc-lib/i686-pc-cygwin/3.3.3/adalib/ /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adal
ib/libgnat.a
Reading specs from /usr/lib/gcc-lib/i686-pc-mingw32/3.3.3/specs
Configured with: /gcc/gcc-3.3.3-3/configure --verbose --prefix=/usr --exec-prefi
x=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/s
hare/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,java,objc,
pascal --enable-nls --without-included-gettext --enable-libgcj --with-system-zli
b --enable-interpreter --enable-threads=posix --enable-java-gc=boehm --enable-sj
lj-exceptions --disable-version-specific-runtime-libs --disable-win32-registry
Thread model: posix
gcc version 3.3.3 (cygwin special)
 /usr/lib/gcc-lib/i686-pc-mingw32/3.3.3/collect2.exe -Bdynamic -o hello.exe /usr
/lib/gcc-lib/i686-pc-mingw32/3.3.3/../../../../i686-pc-mingw32/lib/crt2.o /usr/l
ib/gcc-lib/i686-pc-mingw32/3.3.3/crtbegin.o -L./ -L/usr/lib/gcc-lib/i686-pc-cygw
in/3.3.3/adalib/ -L/usr/lib/gcc-lib/i686-pc-mingw32/3.3.3 -L/usr/lib/gcc-lib/i68
6-pc-mingw32/3.3.3/../../../../i686-pc-mingw32/lib -L/usr/lib/gcc-lib/i686-pc-mi
ngw32/3.3.3/../../.. b~hello.o ./hello.o /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/a
dalib/libgnat.a -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -lmingw32 -luser32
 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt /
usr/lib/gcc-lib/i686-pc-mingw32/3.3.3/crtend.o
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(cio.o)(.text+0x7): undefi
ned reference to `___getreent'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(cio.o)(.text+0x67): undef
ined reference to `___getreent'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(cio.o)(.text+0x97): undef
ined reference to `___getreent'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(cio.o)(.text+0xc7): undef
ined reference to `___getreent'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(cstreams.o)(.text+0x97):
undefined reference to `___getreent'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(cstreams.o)(.text+0xb7):
more undefined references to `___getreent' follow
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(sysdep.o)(.text+0xd4): un
defined reference to `_tcgetattr'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(sysdep.o)(.text+0xfe): un
defined reference to `_tcsetattr'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(sysdep.o)(.text+0x156): u
ndefined reference to `_tcsetattr'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(sysdep.o)(.text+0x25): un
defined reference to `_ttyname'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(sysdep.o)(.text+0x1e5): u
ndefined reference to `_localtime_r'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(adaint.o)(.text+0x7e7): u
ndefined reference to `_fork'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(adaint.o)(.text+0x81b): u
ndefined reference to `_waitpid'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(adaint.o)(.text+0x860): u
ndefined reference to `_fork'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(adaint.o)(.text+0x8c2): u
ndefined reference to `_waitpid'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(adaint.o)(.text+0x901): u
ndefined reference to `_waitpid'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(adaint.o)(.text+0xa5): un
defined reference to `_readlink'
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/adalib/libgnat.a(adaint.o)(.text+0xb5): un
defined reference to `_symlink'
collect2: ld returned 1 exit status
gnatlink: cannot call /usr/bin/gcc.exe
gnatmake: *** link failed.
Comment 1 Laurent GUERBY 2005-03-19 09:47:30 UTC
Out of curiosity, does it still happen with GCC 4.0?
Comment 2 Arnaud Charlet 2005-03-30 10:27:33 UTC
Right, gnatmake has never supported -mno-cygwin. Instead, I'd suggest
configuring gcc for mingw to start with.

According to
http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Index.html#Option-Index

-mno-cygwin is not a FSF option, so closing this PR.

Arno
Comment 3 Gerrit P. Haase 2005-06-08 12:22:03 UTC
(In reply to comment #2)
> Right, gnatmake has never supported -mno-cygwin. Instead, I'd suggest
> configuring gcc for mingw to start with.
> 
> According to
> http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Index.html#Option-Index
> 
> -mno-cygwin is not a FSF option, so closing this PR.
> 
> Arno

Many thanks.
Comment 4 Gerrit P. Haase 2005-06-08 12:40:34 UTC
>> According to
>> http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Index.html#Option-Index
>> 
>> -mno-cygwin is not a FSF option, so closing this PR.

This option just triggers gcc to use other lib and include paths, as they
are defined in the specs.  So it seems gnat doesn't use the specs when 
linking.  Note that it works quite well with include paths when compiling
the source? 


I will provide a workaround in the upcoming release of cygwin gcc-3.4.4,
in addition to -mno-cygwin another flag is needed then: --RTS=no-cygwin
This will cause gnat to pick up the right runtime if the gcc-mingw-ada 
package is correctly installed.  Then there is a new subdirectory in
i686-pc-cygwin/3.4.4 named no-cygwin with symlinks to the mingw runtime:

/---3.4.4
|   /---adainclude
|   /---adalib
|   /---no-cygwin
|       +---adainclude
|       +---adalib

 
$ gcc -v -c --RTS=no-cygwin -mno-cygwin hello_a.adb
Reading specs from /usr/lib/gcc/i686-pc-mingw32/3.4.4/specs
Configured with: /gcc/gcc-3.4.4/gcc-3.4.4-1/configure --verbose --prefix=/usr
--exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--enable-languages=c,ada,c++,d,f77,java,objc --enable-nls
--without-included-gettext --enable-version-specific-runtime-libs --without-x
--enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter
--disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm
--disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization
--enable-libstdcxx-debug : (reconfigured) 
Thread model: posix
gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)
 /usr/lib/gcc/i686-pc-mingw32/3.4.4/gnat1.exe -quiet -dumpbase hello_a.adb
-mno-cygwin -mtune=pentiumpro -fRTS=no-cygwin hello_a.adb -o /tmp/ccqn0PMb.s
 /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/bin/as.exe -o
hello_a.o /tmp/ccqn0PMb.s

$ gnatbind -v -aO./ --RTS=no-cygwin -I- -x hello_a.ali

GNATBIND 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125) Copyright 1995-2004
Free Software Foundation, Inc.

Binding: hello_a.ali

No errors

$ gnatlink hello_a.ali -mno-cygwin -v

GNATLINK 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125) Copyright 1995-2004
Free Software Foundation, Inc
gcc -c -gnatA -gnatWb -gnatiw -mno-cygwin -mtune=pentiumpro --RTS=no-cygwin
-gnatws b~hello_a.adb
/usr/bin/gcc.exe b~hello_a.o ./hello_a.o -mno-cygwin -o hello_a.exe -L./
-L/usr/lib/gcc/i686-pc-cygwin/3.4.4/no-cygwin/adalib/
/usr/lib/gcc/i686-pc-cygwin/3.4.4/no-cygwin/adalib/libgnat.a -Wl,--stack=0x2000000

$ cygcheck hello_a.exe
Found: h:\cygwin\gcc\gcc-test\hello_a.exe
h:/cygwin/gcc/gcc-test/hello_a.exe
  C:\WINNT\System32\msvcrt.dll
    C:\WINNT\System32\KERNEL32.dll
      C:\WINNT\System32\ntdll.dll
  C:\WINNT\System32\ADVAPI32.DLL
    C:\WINNT\System32\USER32.dll
      C:\WINNT\System32\GDI32.dll
    C:\WINNT\System32\RPCRT4.dll


Running this executable works fine.  I'll try to find a way to integrate
this in to the binary to make it work as one expect it to work.
 
Gerrit