Bug 24909 - libmatmul.a breaks darwin build
Summary: libmatmul.a breaks darwin build
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: 4.1.0
Assignee: Janne Blomqvist
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-16 22:56 UTC by Andreas Tobler
Modified: 2005-11-22 16:04 UTC (History)
5 users (show)

See Also:
Host: powerpc-apple-darwin8.3.0
Target: powerpc-apple-darwin8.3.0
Build: powerpc-apple-darwin8.3.0
Known to work:
Known to fail:
Last reconfirmed: 2005-11-16 23:00:41


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Tobler 2005-11-16 22:56:41 UTC
This patch breaks the build of libgfortran on darwin.

http://gcc.gnu.org/ml/gcc-cvs/2005-11/msg00601.html

-all_load  ./.libs/libmatmul.a   -lm ./.libs/libmatmul.a  -lc -Wl,-single_module -install_name  /Volumes/export/gcc/gcc-svn/head/testbin/lib/libgfortran.0.dylib -compatibility_version 1 -current_version 1.0
ld: multiple definitions of symbol __gfortran_matmul_i4
./.libs/libmatmul.a(libmatmul_la-matmul_i4.o) definition of __gfortran_matmul_i4 in section (__TEXT,__text)
./.libs/libmatmul.a(libmatmul_la-matmul_i4.o) definition of __gfortran_matmul_i4 in section (__TEXT,__text)

The reason is that the link command tries to link two times the libmatmul.a which gives the duplicates.

Atm, I have not a solution handy, but it seems to me that using convenience library scheme would be the solution.

Modifying the libtool and removing the $convenience part in libtools whole_archive_flag_spec makes it link and pass the testsuite.

Sorry for not posting a solution right now. Moving pressure :)
Comment 1 Janne Blomqvist 2005-11-16 23:00:41 UTC
As discussed on IRC, the solution is to use noinst_LTLIBRARIES instead of EXTRA_LTLIBRARIES. It was also suggested to name the library libmatmul_convenience.a. Example in libffi/Makefile.am
Comment 2 Janne Blomqvist 2005-11-17 08:26:14 UTC
Patch here: http://gcc.gnu.org/ml/gcc-patches/2005-11/msg01271.html
Comment 3 Andreas Tobler 2005-11-17 14:37:26 UTC
Unfortunately it does not werk :(

I found this message in the libtool archive:

http://lists.gnu.org/archive/html/libtool-patches/2004-08/msg00002.html

Currently we have this 'whole_archive_flag_spec='-all_load $convenience''

in gcc-root/ltcf-c.sh (for darwin)

Is this needed somehwere?

Maybe we could remove this -all_load $convenience' entry in the ltcf-c.sh? 
Geoff?

Doing so by hand in the gfortran libtool makes the library link.
Comment 4 Geoff Keating 2005-11-17 22:35:25 UTC
It's certainly wrong to be using -all-load unless you're also using -r.
Comment 5 Andreas Tobler 2005-11-17 22:54:42 UTC
would this snippet be ok? 

Index: ltcf-c.sh
===================================================================
--- ltcf-c.sh   (revision 107140)
+++ ltcf-c.sh   (working copy)
@@ -419,7 +419,7 @@
     hardcode_direct=no
     hardcode_automatic=yes
     hardcode_shlibpath_var=unsupported
-    whole_archive_flag_spec='-all_load $convenience'
+    whole_archive_flag_spec=''
     link_all_deplibs=yes
     ;;
 
Comment 6 Andreas Tobler 2005-11-18 14:31:51 UTC
On sparc-solaris I get runtime failures:

collect2: ld returned 1 exit status^M
compiler exited with status 1
output is:
Undefined                       first referenced^M
 symbol                             in file^M
_gfortran_matmul_r4                 /var/tmp//ccKKiCDj.o^M
ld: fatal: Symbol referencing errors. No output written to ./matmul_1.exe^M
collect2: ld returned 1 exit status^M

this is with both, the original libmatmul and with libmatmul_convenience.
(using native, sun, as and ld)

I try to investigate deeper by next week. If I do not get beaten by others :)
Comment 7 Eric Botcazou 2005-11-19 08:38:19 UTC
> On sparc-solaris I get runtime failures:
> 
> collect2: ld returned 1 exit status^M
> compiler exited with status 1
> output is:
> Undefined                       first referenced^M
>  symbol                             in file^M
> _gfortran_matmul_r4                 /var/tmp//ccKKiCDj.o^M
> ld: fatal: Symbol referencing errors. No output written to ./matmul_1.exe^M
> collect2: ld returned 1 exit status^M
> 
> this is with both, the original libmatmul and with libmatmul_convenience.
> (using native, sun, as and ld)

Confirmed with all versions of Solaris.
Comment 8 Janne Blomqvist 2005-11-20 21:39:04 UTC
rth committed a fix to trunk and 4.1: http://gcc.gnu.org/ml/fortran/2005-11/msg00548.html

It should now work again on all supported platforms.

Unless new problems are reported I'll close this in a few days.
Comment 9 Eric Botcazou 2005-11-21 09:02:02 UTC
> It should now work again on all supported platforms.

Confirmed on all versions of Solaris.  Thanks!
Comment 10 Janne Blomqvist 2005-11-22 08:59:08 UTC
With the fix by rth, it seems to work again on Solaris (#9) and Darwin ( http://gcc.gnu.org/ml/fortran/2005-11/msg00571.html ); closing the bug.