Bug 206655 - net/mpich: fortran linking error
Summary: net/mpich: fortran linking error
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Tijl Coosemans
URL:
Keywords: easy, needs-qa, patch
Depends on:
Blocks:
 
Reported: 2016-01-26 22:04 UTC by Guillaume Dollé
Modified: 2016-02-01 14:07 UTC (History)
0 users

See Also:
koobs: maintainer-feedback+
koobs: merge-quarterly?


Attachments
patch (553 bytes, patch)
2016-01-29 14:55 UTC, Tijl Coosemans
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Guillaume Dollé 2016-01-26 22:04:12 UTC
Compiling with fortran option causes linking error.

To reproduce, compile a simple C hello world program using /usr/local/bin/mpicc will produce this result:

```
c++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
/usr/local/lib/gcc48/libgfortran.so.3: undefined reference to `__getf2@GCC_4.6.0'
/usr/local/lib/gcc48/libgfortran.so.3: undefined reference to `__floatunditf@GCC_4.6.0'
/usr/local/lib/gcc48/libgfortran.so.3: undefined reference to `__subtf3@GCC_4.6.0'
/usr/local/lib/gcc48/libgfortran.so.3: undefined reference to `__multf3@GCC_4.6.0'
/usr/local/lib/gcc48/libgfortran.so.3: undefined reference to `__unordtf2@GCC_4.6.0'
/usr/local/lib/gcc48/libgfortran.so.3: undefined reference to `__lttf2@GCC_4.6.0'
/usr/local/lib/gcc48/libgfortran.so.3: undefined reference to `__addtf3@GCC_4.6.0'
/usr/local/lib/gcc48/libgfortran.so.3: undefined reference to `__gttf2@GCC_4.6.0'
/usr/local/lib/gcc48/libgfortran.so.3: undefined reference to `__divtf3@GCC_4.6.0'
/usr/local/lib/gcc48/libgfortran.so.3: undefined reference to `__letf2@GCC_4.6.0'
/usr/local/lib/gcc48/libgfortran.so.3: undefined reference to `__netf2@GCC_4.6.0'
/usr/local/lib/gcc48/libgfortran.so.3: undefined reference to `__floatditf@GCC_4.6.0'
/usr/local/lib/gcc48/libgfortran.so.3: undefined reference to `__trunctfdf2@GCC_4.6.0'
/usr/local/lib/gcc48/libgfortran.so.3: undefined reference to `__eqtf2@GCC_4.6.0'
/usr/local/lib/gcc48/libgfortran.so.3: undefined reference to `__floatsitf@GCC_4.6.0'
c++: error: linker command failed with exit code 1 (use -v to see invocation)
```

It seems that these lines from the net/mpich port Makefile,
```
FORTRAN_CONFIGURE_ON=           \
         MPICH_LDFLAGS="-Wl,-rpath=${LOCALBASE}/lib/gcc${_GCC_VER} \
                        -L${LOCALBASE}/lib/gcc${_GCC_VER} -B${LOCALBASE}/bin"
```
are not taken into account.

Replacing MPICH_LDFLAGS by LDFLAGS seems to solve the problem.
Comment 1 Tijl Coosemans freebsd_committer 2016-01-26 22:17:52 UTC
I'll take a closer look later, but I think you need to include those flags on the command line when compiling with mpicc, just like when you compile something with gcc48.  This is a (mis)feature of the gcc ports.
Comment 2 Tijl Coosemans freebsd_committer 2016-01-29 14:55:27 UTC
Created attachment 166270 [details]
patch

Is this patch enough to fix the problem?

The problem is that the linker finds /usr/lib/libgcc_s.so before /usr/local/lib/gcc48/libgcc_s.so.  Ultimately this is problem of the gcc ports.  They are configured with --libdir=/usr/local/lib/gcc48 which puts runtime libraries there instead of in /usr/local/lib.  The gcc compilers cannot find their own runtime libraries in that location so everybody has to pass -L and -Wl,-rpath flags.
Comment 3 Guillaume Dollé 2016-02-01 11:10:50 UTC
(In reply to Tijl Coosemans from comment #2)

Ok for me.
Comment 4 commit-hook freebsd_committer 2016-02-01 14:06:24 UTC
A commit references this bug:

Author: tijl
Date: Mon Feb  1 14:05:47 UTC 2016
New revision: 407716
URL: https://svnweb.freebsd.org/changeset/ports/407716

Log:
  The configure variable MPICH_LDFLAGS is no longer supported.  There is a
  separate variable for each compiler wrapper now.

  PR:		206655

Changes:
  head/net/mpich/Makefile