From: Marco Atzeri <marco.atzeri@gmail.com>
To: cygwin@cygwin.com
Subject: Re: problem with fortran common block in shared library
Date: Wed, 01 Mar 2017 18:49:00 -0000 [thread overview]
Message-ID: <f5b74117-1989-1b4a-114b-06aa27f982fb@gmail.com> (raw)
In-Reply-To: <CABUrC_YEVCefiPjNzivja_LhrvfaU3ZXrvtPmvbxhtXM6_baCQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 948 bytes --]
On 06/01/2017 16:52, Bill Greene wrote:
> This problem is not a generic gcc/gfortran one.
> If you build the test code on Linux, it works correctly.
>
> Bill
>
the problem is gfortran one on Windows platform
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47030
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68040
If you create a directive like
--------------------------------------
!GCC$ ATTRIBUTES DLLEXPORT :: /cb1/
integer cvar
common /cb1/ cvar
--------------------------------------
It produces and error like
--------------------------------------
!GCC$ ATTRIBUTES DLLEXPORT :: /cb1/
1
Error: Invalid character in name at (1)
--------------------------------------
so the DLLEXPORT directive is not correctly
managing "common" as "/cb1/"
I also noted that the "!GCC$" must be at the beginning of the line
otherwise is totally ignored, that is also very hard to note.
Regards
Marco
[-- Attachment #2: cb_test-3.sh --]
[-- Type: text/plain, Size: 1199 bytes --]
#!/bin/sh -x
cat >cb_main.f <<\EOF
program cb_main
!GCC$ ATTRIBUTES DLLEXPORT :: /cb1/
integer cvar
common /cb1/ cvar
cvar = 0
call cb_func()
if(cvar.eq.2) then
write(*,*)'GOOD COMMON BLOCK'
else
write(*,*)'BAD COMMON BLOCK'
endif
end
EOF
cat >cb_func.f <<\EOF
subroutine cb_func()
!GCC$ ATTRIBUTES DLLIMPORT :: /cb1/
integer cvar
common /cb1/ cvar
cvar = 2
cvar2 = 2
end
EOF
################################################################################
rm -f *.o *.dll *.a *.exe
gfortran -c cb_func.f
gfortran -c cb_main.f
################################################################################
ar cr libcb_static.a cb_func.o
gfortran cb_main.o -L. -lcb_static -o cb_main_static
################################################################################
gfortran -shared -o libcb_dynamic.dll cb_func.o
gfortran cb_main.o -L. -lcb_dynamic -o cb_main_dynamic
################################################################################
./cb_main_static
./cb_main_dynamic
################################################################################
[-- Attachment #3: cb_test-2.sh --]
[-- Type: text/plain, Size: 1187 bytes --]
#!/bin/sh -x
cat >cb_main.f <<\EOF
program cb_main
!GCC$ ATTRIBUTES DLLEXPORT :: /cb1/
integer cvar
common /cb1/ cvar
cvar = 0
call cb_func()
if(cvar.eq.2) then
write(*,*)'GOOD COMMON BLOCK'
else
write(*,*)'BAD COMMON BLOCK'
endif
end
EOF
cat >cb_func.f <<\EOF
subroutine cb_func()
!GCC$ ATTRIBUTES DLLIMPORT :: /cb1/
integer cvar
common /cb1/ cvar
cvar = 2
cvar2 = 2
end
EOF
################################################################################
rm -f *.o *.dll *.a *.exe
gfortran -c cb_func.f
gfortran -c cb_main.f
################################################################################
ar cr libcb_static.a cb_func.o
gfortran cb_main.o -L. -lcb_static -o cb_main_static
################################################################################
gfortran -shared -o libcb_dynamic.dll cb_func.o
gfortran cb_main.o -L. -lcb_dynamic -o cb_main_dynamic
################################################################################
./cb_main_static
./cb_main_dynamic
################################################################################
[-- Attachment #4: Type: text/plain, Size: 219 bytes --]
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
prev parent reply other threads:[~2017-03-01 18:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-06 15:26 Bill Greene
2017-01-06 15:45 ` Arjen Markus
2017-01-06 15:53 ` Bill Greene
2017-03-01 18:49 ` Marco Atzeri [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f5b74117-1989-1b4a-114b-06aa27f982fb@gmail.com \
--to=marco.atzeri@gmail.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).