From 559da81e5a72b2dca56ccb686739650386b5b89e Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 29 Mar 2018 23:31:16 +0200 Subject: [PATCH] smpicc: don't add -shared when SMPI_PRETEND_CC is on all mpi programs are compiled in the -shared binary model so that we can load them with dlopen afterward. But shared binaries cannot be run by themselves, which is a problem to ./configure that wants to ensure that mpicc is a real compiler (not a cross-compiler) by executing some stupid code of its own. Before the introduction of dlopen as a privatization mechanism, we used to prevent the binary doing weird things when SMPI_PRETEND_CC was defined. Now, we extend this mecanism for our compiler wrapers to play safe in this case. --- doc/doxygen/module-smpi.doc | 9 +++++---- src/smpi/smpicc.in | 10 ++++++++-- src/smpi/smpicxx.in | 5 ++++- src/smpi/smpif90.in | 5 ++++- src/smpi/smpiff.in | 5 ++++- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/doc/doxygen/module-smpi.doc b/doc/doxygen/module-smpi.doc index 13544860e3..bbeaed2761 100644 --- a/doc/doxygen/module-smpi.doc +++ b/doc/doxygen/module-smpi.doc @@ -641,10 +641,11 @@ make @endverbatim Indeed, the programs compiled with smpicc cannot be executed -without smpirun, while configure wants to test them directly. -With SMPI_PRETEND_CC, any program compiled with smpicc stops -and returns 0 before doing anything that would fail without -smpirun. +without smpirun (they are shared libraries, and they do weird +things on startup), while configure wants to test them directly. +With SMPI_PRETEND_CC smpicc does not compile as shared, +and the SMPI initialization stops and returns 0 before doing anything +that would fail without smpirun. \warning diff --git a/src/smpi/smpicc.in b/src/smpi/smpicc.in index 85fd1eabe4..bdac6008f4 100755 --- a/src/smpi/smpicc.in +++ b/src/smpi/smpicc.in @@ -23,10 +23,16 @@ if [ "x@WIN32@" = "x1" ]; then list_add LINKARGS "@libdir@\libsimgrid.dll" elif [ "x@APPLE@" = "x1" ]; then list_add CFLAGS "-fpic" - list_add LINKARGS "-shared" "-lsimgrid" "-Wl,-undefined,error" + if [ "x${SMPI_PRETEND_CC}" = "x" ]; then + list_add LINKARGS "-shared" + fi + list_add LINKARGS "-lsimgrid" "-Wl,-undefined,error" else list_add CFLAGS "-fpic" - list_add LINKARGS "-shared" "-lsimgrid" "-Wl,-z,defs" + if [ "x${SMPI_PRETEND_CC}" = "x" ]; then + list_add LINKARGS "-shared" + fi + list_add LINKARGS "-lsimgrid" "-Wl,-z,defs" fi diff --git a/src/smpi/smpicxx.in b/src/smpi/smpicxx.in index a9a0b5e32c..241757c105 100755 --- a/src/smpi/smpicxx.in +++ b/src/smpi/smpicxx.in @@ -21,7 +21,10 @@ list_set LINKARGS if [ "@WIN32@" != "1" ]; then # list_add CXXFLAGS "-Dmain=smpi_simulated_main_" list_add CXXFLAGS "-fpic" "-std=gnu++11" - list_add LINKARGS "-shared" "-lsimgrid" "-std=gnu++11" + if [ "x${SMPI_PRETEND_CC}" = "x" ]; then + list_add LINKARGS "-shared" + fi + list_add LINKARGS "-lsimgrid" "-std=gnu++11" else list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_main.h" "-std=gnu++11" list_add LINKARGS "@libdir@\libsimgrid.dll" "-std=gnu++11" diff --git a/src/smpi/smpif90.in b/src/smpi/smpif90.in index b0c2b29d84..2100adb272 100644 --- a/src/smpi/smpif90.in +++ b/src/smpi/smpif90.in @@ -16,7 +16,10 @@ CMAKE_LINKARGS="-L@libdir@" @SMPITOOLS_SH@ list_set FFLAGS @SMPI_Fortran_FLAGS@ -list_set LINKARGS "-shared" "-lsimgrid" @SMPI_Fortran_LIBS@ "-lm" + if [ "x${SMPI_PRETEND_CC}" = "x" ]; then + list_add LINKARGS "-shared" + fi +list_set LINKARGS "-lsimgrid" @SMPI_Fortran_LIBS@ "-lm" list_set TMPFILES main_name=main diff --git a/src/smpi/smpiff.in b/src/smpi/smpiff.in index 5361c3bb95..210645d5e9 100644 --- a/src/smpi/smpiff.in +++ b/src/smpi/smpiff.in @@ -16,7 +16,10 @@ CMAKE_LINKARGS="-L@libdir@" @SMPITOOLS_SH@ list_set FFLAGS @SMPI_Fortran_FLAGS@ -list_set LINKARGS "-shared" "-lsimgrid" @SMPI_Fortran_LIBS@ "-lm" +if [ "x${SMPI_PRETEND_CC}" = "x" ]; then + list_add LINKARGS "-shared" +fi +list_set LINKARGS "-lsimgrid" @SMPI_Fortran_LIBS@ "-lm" list_set TMPFILES main_name=main -- 2.20.1