public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/31073]  New: symbol names are not created with stdcall syntax
@ 2007-03-07 16:23 wt at simpack dot de
  2007-03-07 17:13 ` [Bug fortran/31073] " burnus at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: wt at simpack dot de @ 2007-03-07 16:23 UTC (permalink / raw)
  To: gcc-bugs

GNU Fortran 95 (GCC) 4.3.0 20061021 (experimental), MINGW build

I am trying to compile f90 code into objects that generate the symbol names
in stdcall syntax, i.e. _symname@NN
We need the stdcall decorations since we build a dll that is called from an 
app that needs to do all calls with stdcall.

I have tried each of the following options without success:
   -mrtd  
      (gfortran -c -mrtd simple.f): compiles w/o problems, however
      no stdcall decorations in object
      nm simple.o:
         00000000 b .bss
         00000000 d .data
         00000000 t .text
         00000000 T _simple_sub_


  --enable-stdcall-fixup

     (gfortran -c --enable-stdcall-fixup simple.f): compile error
     f951.exe: error: unrecognized command line option "-fenable-stdcall-fixup"



  --enable-stdcall-alias
     (gfortran -c --enable-stdcall-alias simple.f): compile error
     f951.exe: error: unrecognized command line option "-fadd-stdcall-alias"


The following code was compiled (simple.f):

       SUBROUTINE simple_sub(a,b)
       integer a,b

       a = b

       end


Any help greatly appreciated!

regards

  Wolfgang


-- 
           Summary: symbol names are not created with stdcall syntax
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: blocker
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wt at simpack dot de
 GCC build triplet: GNU Fortran 95 (GCC) 4.3.0 20061021 (experimental)
  GCC host triplet: winXP
GCC target triplet: winXP


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31073


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

* [Bug fortran/31073] symbol names are not created with stdcall syntax
  2007-03-07 16:23 [Bug fortran/31073] New: symbol names are not created with stdcall syntax wt at simpack dot de
@ 2007-03-07 17:13 ` burnus at gcc dot gnu dot org
  2007-03-08 16:18 ` wt at simpack dot de
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-07 17:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2007-03-07 17:13 -------
> I am trying to compile f90 code into objects that generate the symbol names
> in stdcall syntax, i.e. _symname@NN

I think you are not looking for -mrtd but for versioned symbols.

-mrtd does:
"Use a different function-calling convention, in which functions that take a
fixed number of arguments return with the "ret" num instruction, which pops
their arguments while returning."

According to the assembler that seems to work. I have frankly no idea how to do
symbol versioning and I have to admit I failed to find any usable information
on  the net, the closed comes the glibc implementation notes at:
http://people.redhat.com/drepper/symbol-versioning

By far not sure whether the following works, but it produces the right symbol:

asm(".symver simple_sub, simple_sub@N42");
void simple_sub(int *a,int *b)
{
  *a = *b;
}

$nm foo.o
0000000000000000 T simple_sub
0000000000000000 T simple_sub@N42

I have no idea how to do it properly and I don't know how to do it in Fortran.
You are probably better off in asking this question in a mailing list.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu dot
                   |                            |org
           Severity|blocker                     |normal


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31073


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

* [Bug fortran/31073] symbol names are not created with stdcall syntax
  2007-03-07 16:23 [Bug fortran/31073] New: symbol names are not created with stdcall syntax wt at simpack dot de
  2007-03-07 17:13 ` [Bug fortran/31073] " burnus at gcc dot gnu dot org
@ 2007-03-08 16:18 ` wt at simpack dot de
  2007-03-08 17:07 ` [Bug target/31073] " burnus at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: wt at simpack dot de @ 2007-03-08 16:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from wt at simpack dot de  2007-03-08 16:17 -------
the docs say:

gfortran --target-help
  ...
  --add-stdcall-alias                Export symbols with and without @nn
  --disable-stdcall-fixup            Don't link _sym to _sym@nn
  --enable-stdcall-fixup             Link _sym to _sym@nn without warnings
  ...
  -mrtd                              Alternate calling convention

None of the first three options is accepted by gfortran, e.g.:
gfortran -c --add-stdcall-alias simple.f
f951.exe: error: unrecognized command line option "-fadd-stdcall-alias"

Other source in the web (e.g.:
http://04.code-hosting.com/Fortran/1509485-g95---how-to-build-a-DLL )
point out the -mrtd would be the option to do the trick.
None of that works. 

So I want to suggest that this really is a bug if a document command line 
options causes the compiler to not compile. Additionally this disables
the generation of symbol names in stdcall syntax.


-- 

wt at simpack dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |blocker


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31073


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

* [Bug target/31073] symbol names are not created with stdcall syntax
  2007-03-07 16:23 [Bug fortran/31073] New: symbol names are not created with stdcall syntax wt at simpack dot de
  2007-03-07 17:13 ` [Bug fortran/31073] " burnus at gcc dot gnu dot org
  2007-03-08 16:18 ` wt at simpack dot de
@ 2007-03-08 17:07 ` burnus at gcc dot gnu dot org
  2007-03-08 17:54 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-08 17:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from burnus at gcc dot gnu dot org  2007-03-08 17:06 -------
> gfortran --target-help
>   --add-stdcall-alias                Export symbols with and without @nn
>   --disable-stdcall-fixup            Don't link _sym to _sym@nn
>   --enable-stdcall-fixup             Link _sym to _sym@nn without warnings

I couldn't find anything about this in the .texi documentation, but anyway this
is target specific and has nothing to do with the Fortran frontend. It seems as
if --add-stdcall-alias is indeed what you want, but reading the manpage -mrtd
seems to do something different and -mrtd seems to work.

=> component: Target


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|fortran                     |target


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31073


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

* [Bug target/31073] symbol names are not created with stdcall syntax
  2007-03-07 16:23 [Bug fortran/31073] New: symbol names are not created with stdcall syntax wt at simpack dot de
                   ` (2 preceding siblings ...)
  2007-03-08 17:07 ` [Bug target/31073] " burnus at gcc dot gnu dot org
@ 2007-03-08 17:54 ` pinskia at gcc dot gnu dot org
  2007-03-08 17:58 ` kargl at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-08 17:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2007-03-08 17:54 -------
>gfortran --target-help
>  ...
> --add-stdcall-alias                Export symbols with and without @nn
>  --disable-stdcall-fixup            Don't link _sym to _sym@nn
>  --enable-stdcall-fixup             Link _sym to _sym@nn without warnings

Those are most likely assembler or linker options, which you can supply using
-Wa,--option or -Wl,--option depending on if they are an assembler or linker
option.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|blocker                     |normal


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31073


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

* [Bug target/31073] symbol names are not created with stdcall syntax
  2007-03-07 16:23 [Bug fortran/31073] New: symbol names are not created with stdcall syntax wt at simpack dot de
                   ` (3 preceding siblings ...)
  2007-03-08 17:54 ` pinskia at gcc dot gnu dot org
@ 2007-03-08 17:58 ` kargl at gcc dot gnu dot org
  2007-03-09  7:39 ` wt at simpack dot de
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kargl at gcc dot gnu dot org @ 2007-03-08 17:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from kargl at gcc dot gnu dot org  2007-03-08 17:58 -------

> Other source in the web (e.g.:
> http://04.code-hosting.com/Fortran/1509485-g95---how-to-build-a-DLL )
> point out the -mrtd would be the option to do the trick.
> None of that works. 

What g95 does is on absolutely no relevance.  It is a different compiler.


-- 

kargl at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P5


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31073


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

* [Bug target/31073] symbol names are not created with stdcall syntax
  2007-03-07 16:23 [Bug fortran/31073] New: symbol names are not created with stdcall syntax wt at simpack dot de
                   ` (4 preceding siblings ...)
  2007-03-08 17:58 ` kargl at gcc dot gnu dot org
@ 2007-03-09  7:39 ` wt at simpack dot de
  2007-03-09 15:23 ` fxcoudert at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: wt at simpack dot de @ 2007-03-09  7:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from wt at simpack dot de  2007-03-09 07:39 -------
guys, is absolutely agree that what g95 does is of no concern here.
However the problems we are experienceing are with gfortran (the link attached 
in the previous statement contained info about both gfortran and g95).
when typing gfortran --target-help those options are all listed as compiler
options.
It is still a showstopper for us using gfortran if it cannot create
stdcall conform symbol names even if it says it can.


-- 

wt at simpack dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |blocker


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31073


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

* [Bug target/31073] symbol names are not created with stdcall syntax
  2007-03-07 16:23 [Bug fortran/31073] New: symbol names are not created with stdcall syntax wt at simpack dot de
                   ` (5 preceding siblings ...)
  2007-03-09  7:39 ` wt at simpack dot de
@ 2007-03-09 15:23 ` fxcoudert at gcc dot gnu dot org
  2007-03-09 17:07 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-03-09 15:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from fxcoudert at gcc dot gnu dot org  2007-03-09 15:23 -------
(In reply to comment #6)
> when typing gfortran --target-help those options are all listed as compiler
> options.

We all agree it's a bug: compiler, assembler and linker options are listed
there indifferently. I filed it as a different PR (PR 31107) so that we don't
get too confused.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31073


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

* [Bug target/31073] symbol names are not created with stdcall syntax
  2007-03-07 16:23 [Bug fortran/31073] New: symbol names are not created with stdcall syntax wt at simpack dot de
                   ` (6 preceding siblings ...)
  2007-03-09 15:23 ` fxcoudert at gcc dot gnu dot org
@ 2007-03-09 17:07 ` pinskia at gcc dot gnu dot org
  2007-03-09 17:08 ` pinskia at gcc dot gnu dot org
  2007-03-10  1:51 ` dannysmith at users dot sourceforge dot net
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-09 17:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2007-03-09 17:05 -------
This is not that much of a blocker, really.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|blocker                     |enhancement


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31073


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

* [Bug target/31073] symbol names are not created with stdcall syntax
  2007-03-07 16:23 [Bug fortran/31073] New: symbol names are not created with stdcall syntax wt at simpack dot de
                   ` (7 preceding siblings ...)
  2007-03-09 17:07 ` pinskia at gcc dot gnu dot org
@ 2007-03-09 17:08 ` pinskia at gcc dot gnu dot org
  2007-03-10  1:51 ` dannysmith at users dot sourceforge dot net
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-09 17:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pinskia at gcc dot gnu dot org  2007-03-09 17:08 -------
In fact this is an enhancement and really there just needs a new win32 option
for this feature.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  GCC build triplet|GNU Fortran 95 (GCC) 4.3.0  |
                   |20061021 (experimental)     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31073


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

* [Bug target/31073] symbol names are not created with stdcall syntax
  2007-03-07 16:23 [Bug fortran/31073] New: symbol names are not created with stdcall syntax wt at simpack dot de
                   ` (8 preceding siblings ...)
  2007-03-09 17:08 ` pinskia at gcc dot gnu dot org
@ 2007-03-10  1:51 ` dannysmith at users dot sourceforge dot net
  9 siblings, 0 replies; 11+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2007-03-10  1:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from dannysmith at users dot sourceforge dot net  2007-03-10 01:51 -------
In dlls buit by MS windows native toolchain (eg the win32api system
libraries), exported functions are built with __stdcall calling
convention, but are exported without any decoration, eg, WinFooFoo is
simply WinFooFoo. I believe this is a legacy of use of Pascal language
way back in MS-DOS beginnings. IIRC, the old MS VisualFortran compiler
also, used stdcall convention by default, but did not use the @n stdcall
decoration, Now, MS has a popular language called VisualBasic, that like
Pascal, uses __stdcall convention (sans decoration of symbol names). So
if you want to use your gfortran dll in a VB app, the simplest thing to do is
build your dll's the MS way.  That is where -mrtd comes in. 
(And please do read the big caveat about using -mrtd in gcc.info.)

The @n stdcall suffix is an extern "C" language thing. (MS compiler
doesn't even use in C++, but G++ does.) To link against a stdcall
function exported from a DLL (undecorated as per win32api convention)
you need to map the the stdcall name expected by C to the undecorated
Pascal name exported from the DLL. This is normally done by the linker
when building a DLL import lib from a .def file. The GNU linker option to
accomplish this is "--kill-at".

Danny


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31073


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

end of thread, other threads:[~2007-03-10  1:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-07 16:23 [Bug fortran/31073] New: symbol names are not created with stdcall syntax wt at simpack dot de
2007-03-07 17:13 ` [Bug fortran/31073] " burnus at gcc dot gnu dot org
2007-03-08 16:18 ` wt at simpack dot de
2007-03-08 17:07 ` [Bug target/31073] " burnus at gcc dot gnu dot org
2007-03-08 17:54 ` pinskia at gcc dot gnu dot org
2007-03-08 17:58 ` kargl at gcc dot gnu dot org
2007-03-09  7:39 ` wt at simpack dot de
2007-03-09 15:23 ` fxcoudert at gcc dot gnu dot org
2007-03-09 17:07 ` pinskia at gcc dot gnu dot org
2007-03-09 17:08 ` pinskia at gcc dot gnu dot org
2007-03-10  1:51 ` dannysmith at users dot sourceforge dot net

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