Source: valgrind Version: 1:3.13.0-2 Tags: upstream patch User: helm...@debian.org Usertags: rebootstrap
valgrind fails to cross build from source, because it fails to detect mpi, builds without it and then fails dh_install. It tries to use mpicc, but making mpicc work with cross compilation is hard. The wrapper is not universally loved as it conflicts with other wrappers. The better way to use mpi is using pkg-config (like everything else). The attached patch make valgrind detect mpi using pkg-config while falling back to use mpicc. It thus makes valgrind cross buildable and removes an unloved hack. Please consider applying it. Helmut
--- valgrind-3.13.0.orig/configure.ac +++ valgrind-3.13.0/configure.ac @@ -3961,16 +3961,22 @@ [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic" LDFLAGS_MPI="-fpic -shared"]) +PKG_CHECK_MODULES([MPI_C],[mpi-c],[ + CFLAGS_MPI="$CFLAGS_MPI $MPI_C_CFLAGS" + LDFLAGS_MPI="$LDFLAGS_MPI $MPI_C_LIBS" +],[ + CFLAGS_MPI="$CFLAGS_MPI `$MPI_CC -showme:compile`" + LDFLAGS_MPI="$LDFLAGS_MPI `$MPI_CC -showme:link`" +]) + AC_SUBST([CFLAGS_MPI]) AC_SUBST([LDFLAGS_MPI]) ## See if MPI_CC works for the primary target ## AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h]) -saved_CC=$CC saved_CFLAGS=$CFLAGS -CC=$MPI_CC CFLAGS="$CFLAGS_MPI $mflag_primary" saved_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS_MPI $mflag_primary" @@ -3990,27 +3995,23 @@ ac_have_mpi2_pri=no AC_MSG_RESULT([no]) ]) -CC=$saved_CC CFLAGS=$saved_CFLAGS LDFLAGS="$saved_LDFLAGS" AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes) ## See if MPI_CC works for the secondary target. Complication: what if ## there is no secondary target? We need this to then fail. -## Kludge this by making MPI_CC something which will surely fail in +## Kludge this by making CFLAGS something which will surely fail in ## such a case. ## AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h]) -saved_CC=$CC saved_CFLAGS=$CFLAGS saved_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS_MPI $mflag_secondary" +CFLAGS="$CFLAGS_MPI $mflag_secondary" if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then - CC="$MPI_CC this will surely fail" -else - CC=$MPI_CC + CFLAGS="this will surely fail" fi -CFLAGS="$CFLAGS_MPI $mflag_secondary" AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <mpi.h> #include <stdio.h> @@ -4027,7 +4028,6 @@ ac_have_mpi2_sec=no AC_MSG_RESULT([no]) ]) -CC=$saved_CC CFLAGS=$saved_CFLAGS LDFLAGS="$saved_LDFLAGS" AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes) --- valgrind-3.13.0.orig/mpi/Makefile.am +++ valgrind-3.13.0/mpi/Makefile.am @@ -1,16 +1,5 @@ include $(top_srcdir)/Makefile.all.am -# HACK WARNING: automake isn't good at supporting non-$(CC) compilers. -# But we need to use $(MPI_CC) for the MPI stuff. So we have this mpi stuff -# in its own directory so we can use the following blunt instruments, which -# override the C compiler and all the default flags. -CC = $(MPI_CC) -DEFS = -DEFAULT_INCLUDES = -CPPFLAGS = -CFLAGS = -LDFLAGS = - EXTRA_DIST = \ mpiwrap_type_test.c