public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/55891] New: Problem with shared library and EQUIVALENCE on darwin 11.4.2 x86_64
@ 2013-01-07  2:36 brtnfld at hdfgroup dot org
  2013-01-07  9:39 ` [Bug fortran/55891] " burnus at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: brtnfld at hdfgroup dot org @ 2013-01-07  2:36 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55891
           Summary: Problem with shared library and EQUIVALENCE on darwin
                    11.4.2 x86_64
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: brtnfld@hdfgroup.org


On a x86_64 system with Darwin Kernel Version 11.4.2, and if you use to compile
the programs:

gfortran -shared -fPIC  mod.f90 -o lib.so
gfortran -fPIC main.f90 lib.so

The main program does not receive the values from the module (i.e. the print
statement will print 0,0). It works if you use a static library.

main.f90:

PROGRAM main
  USE LIB2
  IMPLICIT NONE
  CALL f()
  PRINT*,i,j
END PROGRAM main

mod.f90:

MODULE LIB2
  INTEGER i
  INTEGER :: j
  EQUIVALENCE (j, i)
CONTAINS
  SUBROUTINE f()
    IMPLICIT NONE
    j = 40
  END SUBROUTINE f
END MODULE LIB2

nm lib.so
0000000000000f9a T ___lib2_MOD_f
0000000000000f94 t __dyld_func_lookup
0000000000001010 S _lib2.eq.0_
                 U dyld_stub_binder
0000000000000f80 t dyld_stub_binding_helper


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

* [Bug fortran/55891] Problem with shared library and EQUIVALENCE on darwin 11.4.2 x86_64
  2013-01-07  2:36 [Bug fortran/55891] New: Problem with shared library and EQUIVALENCE on darwin 11.4.2 x86_64 brtnfld at hdfgroup dot org
@ 2013-01-07  9:39 ` burnus at gcc dot gnu.org
  2013-01-07 11:50 ` dominiq at lps dot ens.fr
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-01-07  9:39 UTC (permalink / raw)
  To: gcc-bugs


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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org,
                   |                            |dominiq at lps dot ens.fr

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-01-07 09:39:33 UTC ---
For what it is worth: It works with GCC 4.8 on x86-64-gnu-linux.


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

* [Bug fortran/55891] Problem with shared library and EQUIVALENCE on darwin 11.4.2 x86_64
  2013-01-07  2:36 [Bug fortran/55891] New: Problem with shared library and EQUIVALENCE on darwin 11.4.2 x86_64 brtnfld at hdfgroup dot org
  2013-01-07  9:39 ` [Bug fortran/55891] " burnus at gcc dot gnu.org
@ 2013-01-07 11:50 ` dominiq at lps dot ens.fr
  2013-01-22 11:52 ` dominiq at lps dot ens.fr
  2013-02-06  6:01 ` brtnfld at hdfgroup dot org
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-01-07 11:50 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2013-01-07 11:49:53 UTC ---
I see this behavior with gcc 4.8 on x86_64-apple-darwin10. It happens even if
the -fPIC options are removed (isn't it the default on darwin?). I recover the
expected behavior if I add -c when compiling mod.f90, but I cannot say more
since I don't understand what is intended.


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

* [Bug fortran/55891] Problem with shared library and EQUIVALENCE on darwin 11.4.2 x86_64
  2013-01-07  2:36 [Bug fortran/55891] New: Problem with shared library and EQUIVALENCE on darwin 11.4.2 x86_64 brtnfld at hdfgroup dot org
  2013-01-07  9:39 ` [Bug fortran/55891] " burnus at gcc dot gnu.org
  2013-01-07 11:50 ` dominiq at lps dot ens.fr
@ 2013-01-22 11:52 ` dominiq at lps dot ens.fr
  2013-02-06  6:01 ` brtnfld at hdfgroup dot org
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-01-22 11:52 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2013-01-22 11:52:27 UTC ---
Form
https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.fortran/E_ll5RFNL14
FX said:

Compiling shared libraries on Darwin is a bit more tricky than on your 
typical Linux system. 

In your case, you're missing -flat_namespace: 

   Two-level namespace 
     By default all references resolved to a dynamic library record the 
     library to which they were resolved. At runtime, dyld uses that informa- 
     tion to directly resolve symbols.  The alternative is to use the 
     -flat_namespace option.  With flat namespace, the library is not 
     recorded.  At runtime, dyld will search each dynamic library in load 
     order when resolving symbols. This is slower, but more like how other 
     operating systems resolve symbols. 

(from Mac OS ld man page). Typical use case for creating a Darwin shared 
library is: 

$ gfortran -dynamiclib -undefined suppress -flat_namespace -fPIC  mod.f90 -o
libfoo.dylib 
$ gfortran main.f90 -lfoo -L. && ./a.out 
          40          40 

This PR should probably be closed as INVALID.


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

* [Bug fortran/55891] Problem with shared library and EQUIVALENCE on darwin 11.4.2 x86_64
  2013-01-07  2:36 [Bug fortran/55891] New: Problem with shared library and EQUIVALENCE on darwin 11.4.2 x86_64 brtnfld at hdfgroup dot org
                   ` (2 preceding siblings ...)
  2013-01-22 11:52 ` dominiq at lps dot ens.fr
@ 2013-02-06  6:01 ` brtnfld at hdfgroup dot org
  3 siblings, 0 replies; 5+ messages in thread
From: brtnfld at hdfgroup dot org @ 2013-02-06  6:01 UTC (permalink / raw)
  To: gcc-bugs


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

Scot Breitenfeld <brtnfld at hdfgroup dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #4 from Scot Breitenfeld <brtnfld at hdfgroup dot org> 2013-02-06 06:00:58 UTC ---
That works for the simple example, but I still have problems with the larger
code. But I have not been able to isolate the problem as of yet, so I'm no
longer sure this is a bug in gfortran. I'll close the bug.

It's good to know about those additional needed flags. Thanks.


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

end of thread, other threads:[~2013-02-06  6:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-07  2:36 [Bug fortran/55891] New: Problem with shared library and EQUIVALENCE on darwin 11.4.2 x86_64 brtnfld at hdfgroup dot org
2013-01-07  9:39 ` [Bug fortran/55891] " burnus at gcc dot gnu.org
2013-01-07 11:50 ` dominiq at lps dot ens.fr
2013-01-22 11:52 ` dominiq at lps dot ens.fr
2013-02-06  6:01 ` brtnfld at hdfgroup dot org

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