Bug 217682

Summary: net/openmpi2: remove implicit -L/usr/local/lib
Product: Ports & Packages Reporter: Tijl Coosemans <tijl>
Component: Individual Port(s)Assignee: Danilo Egea Gondolfo <danilo>
Status: Closed FIXED    
Severity: Affects Only Me CC: as
Priority: --- Flags: bugzilla: maintainer-feedback? (danilo)
Version: Latest   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 217283    
Attachments:
Description Flags
patch none

Description Tijl Coosemans freebsd_committer freebsd_triage 2017-03-10 13:46:51 UTC
Created attachment 180696 [details]
patch

While working on a port of OpenCoarrays (bug 217283) it was discovered that Open MPI 2 runs the compiler with "-L/usr/local/lib" before "-L/usr/local/mpi/openmpi2/lib -lmpi".  You can verify this by running "/usr/local/mpi/openmpi2/bin/mpicc -show".  This causes /usr/local/lib/libmpi.so to be used if it exists instead of the Open MPI library.

-L/usr/local/lib is added by the configure script.  The attached patch changes CONFIGURE_ARGS to avoid this.  To allow the configure script to still find external libraries USES=localbase is added.  A post-patch command needed to be added to set the full path of hwloc.h like --with-hwloc=${LOCALBASE} does.  With --with-hwloc=external just the name "hwloc.h" is used.  This fails because the work directory contains its own hwloc.h which gets included instead of the system header.
Comment 1 commit-hook freebsd_committer freebsd_triage 2017-03-12 16:12:10 UTC
A commit references this bug:

Author: danilo
Date: Sun Mar 12 16:11:48 UTC 2017
New revision: 435994
URL: https://svnweb.freebsd.org/changeset/ports/435994

Log:
  - Remove implicit -L/usr/local/lib
  - Simplify TORQUE option selection

  PR:		217682
  Submitted by:	tijl

Changes:
  head/net/openmpi2/Makefile
Comment 2 Danilo Egea Gondolfo freebsd_committer freebsd_triage 2017-03-12 16:14:22 UTC
Committed, thanks!
Comment 3 Anton Shterenlikht 2017-03-13 11:30:12 UTC
With this patch I still get:

$ /usr/local/mpi/openmpi2/bin/mpif90 z.f90
$ /usr/local/mpi/openmpi2/bin/mpirun -np 3 ./a.out 
-------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code.. Per user-direction, the job has been aborted.
-------------------------------------------------------
/lib/libgcc_s.so.1: version GCC_4.8.0 required by /usr/local/lib/gcc7/libgfortran.so.4 not found
/lib/libgcc_s.so.1: version GCC_4.8.0 required by /usr/local/lib/gcc7/libgfortran.so.4 not found
/lib/libgcc_s.so.1: version GCC_4.8.0 required by /usr/local/lib/gcc7/libgfortran.so.4 not found
--------------------------------------------------------------------------

so -rpath is still needed:

$ /usr/local/mpi/openmpi2/bin/mpif90 -Wl,-rpath="/usr/local/lib/gcc7" mpi.f90
$ /usr/local/mpi/openmpi2/bin/mpirun -np 3 ./a.out
 Hello from            2  out of            3  processes.
 Hello from            1  out of            3  processes.
 Hello from            0  out of            3  processes.

Or was the patch not intended to fix this?
Comment 4 Tijl Coosemans freebsd_committer freebsd_triage 2017-03-13 11:54:12 UTC
No, you should open a separate bug about that.  This patch was to make it stop use /usr/local/lib/libmpi.so (from MPICH).