[mpich-discuss] static compiling with mpich2

Jason Palmer jason at sccn.ucsd.edu
Fri Jan 29 18:17:20 CST 2010


The problem does seem to be related to MPICH and/or gcc with static
compilation ... oddly, I only get a seg fault when I try to print (to
stdout) and execute an MPI instruction, but either alone works.

I can compile using mpif90 with or without -static.

In the following simple fortran program:

---------------------
program main
use mpi
implicit none
integer :: ierr

print *, 'This is a test ...'

call MPI_INIT(ierr)
call MPI_FINALIZE(ierr)

end program
------------------------

when compiled with MPICH2 mpif90 and gcc-4.4.3, and -static, no
optimization, I get a seg fault.

If I comment out the print statement, there is no error (even with static
compile).
If I comment out the MPI statements, the print statement works and no error
(even though compiled with mpif90).

I get the error both with the "use mpi" and include mpif.h.

I re-compiled MPICH2 without --enable-fast, and with --enable-g=dbg and
--enable-debug-info (I got a compile error when I tried to use
--enable-error-checking complaining about and unknown error number).

I ran gdb, and the seg fault happens during a return from a thread mutex
call. I compiled gcc with enable-threads=posix, but there is no explicit
threading in my code here.

The MPI routines work fine with static and no print statement, and
vice-versa. And somehow the combination seems to die in a thread call.

I will try recompiling gcc without --enable-threads=posix to see what that
does (assuming no immediate fixes are forthcoming.)

Thanks for your help.

Jason



-----Original Message-----
From: mpich-discuss-bounces at mcs.anl.gov
[mailto:mpich-discuss-bounces at mcs.anl.gov] On Behalf Of Dave Goodell
Sent: Friday, January 29, 2010 1:21 PM
To: mpich-discuss at mcs.anl.gov
Subject: Re: [mpich-discuss] static compiling with mpich2

We (the MPICH2 developers) primarily compile statically and we  
definitely use static libraries in many of our nightly tests.  GCC is  
also well tested with MPICH2 and is totally compatible on most  
platforms.

Have you used gdb or valgrind to determine where/why the segfault is  
occurring?

If the segfault is coming from within MPICH2, can you try configuring  
with "--enable-g=dbg --enable-error-checking" and *without* any "-- 
enable-fast" arguments?  Versions of MPICH2 built for performance are  
much less forgiving of errors in application code.

-Dave

On Jan 29, 2010, at 3:03 PM, Jason Palmer wrote:

> Hi all,
>
> We recently switched from Mpich1 to Mpich2 as part of a general  
> upgrade, and I'm re-building a program that was previously compiled  
> as a static binary under Mpich1 on 64-bit RedHat Linux using  
> pathscale fortran on an AMD Opteron cluster.
>
> We are now using gcc-4.4.3 (instead of pathscale), and I can compile  
> and run the code with dynamic libraries, but when I compile with - 
> static, the compile succeeds, but the binary gives a segmentation  
> fault when executed, with or without mpiexec.
>
> I have tried compiling Mpich2 (using gcc 4.4.3) both with -enable- 
> sharedlibs=gcc and without, but both give the error in the static  
> version but no error in the non-static version.
>
> Has anyone had success with static compiling of Mpich2 / gcc programs?
>
> Thanks,
> Jason
>
>
> _______________________________________________
> mpich-discuss mailing list
> mpich-discuss at mcs.anl.gov
> https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss

_______________________________________________
mpich-discuss mailing list
mpich-discuss at mcs.anl.gov
https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss



More information about the mpich-discuss mailing list