public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/16485] New: Private subroutines from different modules collide during linking.
@ 2004-07-12  0:45 olchansk at panix dot com
  2004-07-12  4:39 ` [Bug fortran/16485] " olchansk at panix dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: olchansk at panix dot com @ 2004-07-12  0:45 UTC (permalink / raw)
  To: gcc-bugs

gfortran version "gcc version 3.5.0 20040710 (experimental)" generates incorrect
names for private functions inside modules, causing link-time collisions between
same-named private functions from different modules: (this problem prevents this
example from even assembling):

[olchansk@tw15 gfortran_test]$ cat test_ldcollide.f90
module foo
  private
contains
  subroutine sub
  end subroutine sub
end module foo
module bar
  private
contains
  subroutine sub
  end subroutine sub
end module bar
[olchansk@tw15 gfortran_test]$ make test_ldcollide.o
/triumfcs/trshare/olchansk/gcc-tree-ssa/install/bin/gfortran -x f95 -c  -o
test_ldcollide.o -O2 -g -Wall -Waliasing -Wline-truncation -Wsurprising
-Wunused-labels -fPIC -ffixed-line-length-132 test_ldcollide.f90
/tmp/ccAzTdiq.s: Assembler messages:
/tmp/ccAzTdiq.s:30: Error: symbol `sub_' is already defined
make: *** [test_ldcollide.o] Error 1

K.O.

-- 
           Summary: Private subroutines from different modules collide
                    during linking.
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: olchansk at panix dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug fortran/16485] Private subroutines from different modules collide during linking.
  2004-07-12  0:45 [Bug fortran/16485] New: Private subroutines from different modules collide during linking olchansk at panix dot com
@ 2004-07-12  4:39 ` olchansk at panix dot com
  2004-07-12  6:25 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: olchansk at panix dot com @ 2004-07-12  4:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From olchansk at panix dot com  2004-07-12 04:38 -------
This change to module.c::write_symbol0() fixes the symbol collisions. My project
now almost links, except for the missing "entry" symbols. Yay!

Something silly is going on. This is how I understand this problem (feel free to
laugh at me if I got it completly backwards). gfc_sym_mangled_function_id()
depends on sym->module to create unique mangled names. However, private module
subroutines arrive there with sym->module blank and mangling cannot happen. So,
who sets sym->module? The only place I could find is in
module.c::write_symbol(). Internal subroutines do not go through "write_symbol"
and their sym->module remains blank.

Fix to module.c::write_symbol0(): add lines marked "+" (no cvs diff this time,
sorry).

  sym = st->n.sym;

  if (sym->attr.flavor == FL_PROCEDURE && sym->attr.generic
      && !sym->attr.subroutine && !sym->attr.function)
    return;

+  if (sym->attr.proc == PROC_MODULE && sym->module[0] == 0)
+    strcpy (sym->module, module_name);

  if (!check_access (sym->attr.access, sym->ns->default_access))
    return;

K.O.


-- 


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


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

* [Bug fortran/16485] Private subroutines from different modules collide during linking.
  2004-07-12  0:45 [Bug fortran/16485] New: Private subroutines from different modules collide during linking olchansk at panix dot com
  2004-07-12  4:39 ` [Bug fortran/16485] " olchansk at panix dot com
@ 2004-07-12  6:25 ` pinskia at gcc dot gnu dot org
  2004-07-12 12:37 ` tobi at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-12  6:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-12 06:25 -------
Confirmed from a build which was updated about 2 hours ago.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-07-12 06:25:49
               date|                            |


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


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

* [Bug fortran/16485] Private subroutines from different modules collide during linking.
  2004-07-12  0:45 [Bug fortran/16485] New: Private subroutines from different modules collide during linking olchansk at panix dot com
  2004-07-12  4:39 ` [Bug fortran/16485] " olchansk at panix dot com
  2004-07-12  6:25 ` pinskia at gcc dot gnu dot org
@ 2004-07-12 12:37 ` tobi at gcc dot gnu dot org
  2004-07-13 17:19 ` tobi at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-07-12 12:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2004-07-12 12:37 -------
There's another problem: splitting your testcase in two files gives an error at
link time. I don't think there's any reason a private procedure should have
global linkage. (Mangling names would help for this, but linking large projects
would definitely be sped up by not creating these global symbols in the first
place).
[tobi@marktplatz tests]$ cat pr16485.f90
module foo
  private
contains
  subroutine sub
  end subroutine sub
end module foo
[tobi@marktplatz tests]$ cat pr16485_2.f90
module bar
  private
contains
  subroutine sub
  end subroutine sub
end module bar
 
end
[tobi@marktplatz tests]$ gfortran pr16485.f90 pr16485_2.f90
/tmp/ccadlrBF.o(.text+0x0): In function `sub_':
: multiple definition of `sub_'
/tmp/ccWqd9At.o(.text+0x0): first defined here
collect2: ld returned 1 exit status
[tobi@marktplatz tests]$

The error message is also remarkably bad. Compiling and linking in separate
steps fixes that:
[tobi@marktplatz tests]$ gfortran pr16485.f90 -c
[tobi@marktplatz tests]$ gfortran pr16485_2.f90 -c
[tobi@marktplatz tests]$ gfortran pr16485.o pr16485_2.o
pr16485_2.o(.text+0x0): In function `sub_':
: multiple definition of `sub_'
pr16485.o(.text+0x0): first defined here
collect2: ld returned 1 exit status
[tobi@marktplatz tests]$


-- 


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


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

* [Bug fortran/16485] Private subroutines from different modules collide during linking.
  2004-07-12  0:45 [Bug fortran/16485] New: Private subroutines from different modules collide during linking olchansk at panix dot com
                   ` (2 preceding siblings ...)
  2004-07-12 12:37 ` tobi at gcc dot gnu dot org
@ 2004-07-13 17:19 ` tobi at gcc dot gnu dot org
  2004-09-02 10:51 ` tobi at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-07-13 17:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2004-07-13 17:19 -------
Looks like I attached the second patch again, when I attached for the third
time. Anyway, I've posted my current patch to the mailing list:
http://gcc.gnu.org/ml/fortran/2004-07/msg00161.html

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


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


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

* [Bug fortran/16485] Private subroutines from different modules collide during linking.
  2004-07-12  0:45 [Bug fortran/16485] New: Private subroutines from different modules collide during linking olchansk at panix dot com
                   ` (3 preceding siblings ...)
  2004-07-13 17:19 ` tobi at gcc dot gnu dot org
@ 2004-09-02 10:51 ` tobi at gcc dot gnu dot org
  2004-09-15 13:13 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-09-02 10:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2004-09-02 10:51 -------
Updated patch here: http://gcc.gnu.org/ml/fortran/2004-09/msg00019.html

-- 


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


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

* [Bug fortran/16485] Private subroutines from different modules collide during linking.
  2004-07-12  0:45 [Bug fortran/16485] New: Private subroutines from different modules collide during linking olchansk at panix dot com
                   ` (4 preceding siblings ...)
  2004-09-02 10:51 ` tobi at gcc dot gnu dot org
@ 2004-09-15 13:13 ` cvs-commit at gcc dot gnu dot org
  2004-09-15 13:16 ` pbrook at gcc dot gnu dot org
  2004-11-06 15:43 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-09-15 13:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-09-15 13:13 -------
Subject: Bug 16485

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pbrook@gcc.gnu.org	2004-09-15 13:12:52

Modified files:
	gcc/fortran    : ChangeLog module.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: same_name_1.f90 

Log message:
	2004-09-15  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
	
	PR fortran/16485
	* module.c (write_symbol): Don't fill in module name here.
	(write_symbol0): Fill in here instead.
	testsuite/
	* gfortran.dg/same_name_1.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.202&r2=1.203
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/module.c.diff?cvsroot=gcc&r1=1.15&r2=1.16
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4294&r2=1.4295
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/same_name_1.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


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

* [Bug fortran/16485] Private subroutines from different modules collide during linking.
  2004-07-12  0:45 [Bug fortran/16485] New: Private subroutines from different modules collide during linking olchansk at panix dot com
                   ` (5 preceding siblings ...)
  2004-09-15 13:13 ` cvs-commit at gcc dot gnu dot org
@ 2004-09-15 13:16 ` pbrook at gcc dot gnu dot org
  2004-11-06 15:43 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pbrook at gcc dot gnu dot org @ 2004-09-15 13:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pbrook at gcc dot gnu dot org  2004-09-15 13:16 -------
Fixed. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug fortran/16485] Private subroutines from different modules collide during linking.
  2004-07-12  0:45 [Bug fortran/16485] New: Private subroutines from different modules collide during linking olchansk at panix dot com
                   ` (6 preceding siblings ...)
  2004-09-15 13:16 ` pbrook at gcc dot gnu dot org
@ 2004-11-06 15:43 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-06 15:43 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.0


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


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

end of thread, other threads:[~2004-11-06 15:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-12  0:45 [Bug fortran/16485] New: Private subroutines from different modules collide during linking olchansk at panix dot com
2004-07-12  4:39 ` [Bug fortran/16485] " olchansk at panix dot com
2004-07-12  6:25 ` pinskia at gcc dot gnu dot org
2004-07-12 12:37 ` tobi at gcc dot gnu dot org
2004-07-13 17:19 ` tobi at gcc dot gnu dot org
2004-09-02 10:51 ` tobi at gcc dot gnu dot org
2004-09-15 13:13 ` cvs-commit at gcc dot gnu dot org
2004-09-15 13:16 ` pbrook at gcc dot gnu dot org
2004-11-06 15:43 ` pinskia at gcc dot gnu 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).