Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't take default smpi compiler flags from the environment.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 4 May 2021 21:37:07 +0000 (23:37 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 4 May 2021 21:48:22 +0000 (23:48 +0200)
The user must explicitly define them through cmake parameters
SMPI_C_FLAGS, SMPI_CXX_FLAGS, or SMPI_Fortran_FLAGS.

CMakeLists.txt
ChangeLog
docs/source/Installing_SimGrid.rst

index 46a1435..2d001ad 100644 (file)
@@ -31,12 +31,6 @@ project(simgrid C CXX)
 # customizable installation directories
 include(GNUInstallDirs)
 
-## Save compiler flags preset with environment variables CFLAGS or CXXFLAGS;
-## they will used within smpicc, smpicxx.
-## Do it early so that we get their genuine values. The same will be done later for Fortran.
-string(REGEX REPLACE " *-f[a-z]+-prefix-map=[^ ]*" "" SMPI_C_FLAGS "${CMAKE_C_FLAGS}")
-string(REGEX REPLACE " *-f[a-z]+-prefix-map=[^ ]*" "" SMPI_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
 #     Check for the compiler        #
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
@@ -94,19 +88,19 @@ if ((NOT DEFINED enable_smpi) OR enable_smpi)
 
        # Set flags/libs to be used in smpiff
     if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
-      set(SMPI_Fortran_FLAGS "\"-fpic\" \"-ff2c\" \"-fno-second-underscore\"")
+      set(SMPI_Fortran_FLAGS_ "\"-fpic\" \"-ff2c\" \"-fno-second-underscore\"")
       set(SMPI_Fortran_LIBS "\"-lgfortran\"")
       set(SMPI_GFORTRAN 1)
     elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
-      set(SMPI_Fortran_FLAGS "\"-fPIC\" \"-nofor-main\"")
+      set(SMPI_Fortran_FLAGS_ "\"-fPIC\" \"-nofor-main\"")
       set(SMPI_Fortran_LIBS "\"-lifcore\"")
       set(SMPI_IFORT 1)
     elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI|Flang") # flang
-      set(SMPI_Fortran_FLAGS "\"-fPIC\"")
+      set(SMPI_Fortran_FLAGS_ "\"-fPIC\"")
       set(SMPI_Fortran_LIBS "")
       set(SMPI_FLANG 1)
     endif()
-    string(REGEX REPLACE " *-f[a-z]+-prefix-map=[^ ]*" "" SMPI_Fortran_FLAGS "${SMPI_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS}")
+    set(SMPI_Fortran_FLAGS "${SMPI_Fortran_FLAGS_} ${SMPI_Fortran_FLAGS}")
 
     ## Request debugging flags for Fortran too
     set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g")
index 94b030d..641e419 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,11 @@ S4U:
  - Fixed a bug where Activity::wait_for() killed the activity on timeout.
    Explicitly cancel the activity to get back to previous behavior.
 
+SMPI:
+ - The default SMPI compiler flags are no more taken from the environment.
+   They can be explicitly set through cmake parameters SMPI_C_FLAGS,
+   SMPI_CXX_FLAGS, or SMPI_Fortran_FLAGS.
+
 LUA:
  - Lua platform files are deprecated. Their support will be dropped after v3.31.
 
index 3d9c4f4..c2b92cb 100644 (file)
@@ -293,6 +293,12 @@ minimal-bindings (on/OFF)
   Take as few optional dependencies as possible, to get minimal
   library bindings in Java and Python.
 
+SMPI_C_FLAGS (string)
+SMPI_CXX_FLAGS (string)
+SMPI_Fortran_FLAGS (string)
+  Default compiler options to use in smpicc, smpicxx, or smpiff.
+  This can be useful to set options like "-m32" or "-m64".
+
 Reset the build configuration
 """""""""""""""""""""""""""""
 
@@ -498,12 +504,15 @@ version of SimGrid with something like:
 
   CFLAGS=-m32 \
   CXXFLAGS=-m32 \
+  FFLAGS=-m32 \
   PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu/pkgconfig/ \
   cmake . \
   -DCMAKE_SYSTEM_PROCESSOR=i386 \
   -DCMAKE_Fortran_COMPILER=/some/path/to/i686-linux-gnu-gfortran \
   -DGFORTRAN_EXE=/some/path/to/i686-linux-gnu-gfortran \
-  -DCMAKE_Fortran_FLAGS=-m32
+  -DSMPI_C_FLAGS=-m32 \
+  -DSMPI_CXX_FLAGS=-m32 \
+  -DSMPI_Fortran_FLAGS=-m32
 
 If needed, implement ``i686-linux-gnu-gfortran`` as a script: