Skip to content

Commit a4784ba

Browse files
authored
Merge pull request #367 from sourceryinstitute/bugfix-#317-noexecstack
Check for and remove `noexecstack` added by MPI Fixes #317
2 parents fca8657 + 8dd3112 commit a4784ba

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,28 @@ this to the OpenCoarrays developers by filing a new issue at:
204204
https://github.com/sourceryinstitute/OpenCoarrays/issues/new")
205205
endif()
206206

207+
#-----------------------------------------------
208+
# Work around bug #317 present on fedora systems
209+
#-----------------------------------------------
210+
if( (MPI_C_LINK_FLAGS MATCHES "noexecstack") OR (MPI_Fortran_LINK_FLAGS MATCHES "noexecstack") )
211+
message ( WARNING
212+
"The `noexecstack` linker flag was found in the MPI_<lang>_LINK_FLAGS variable. This is
213+
known to cause segmentation faults for some Fortran codes. See, e.g.,
214+
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71729 or
215+
https://github.com/sourceryinstitute/OpenCoarrays/issues/317.
216+
217+
`noexecstack` is being replaced with `execstack`"
218+
)
219+
string(REPLACE "noexecstack"
220+
"execstack" MPI_C_LINK_FLAGS_FIXED ${MPI_C_LINK_FLAGS})
221+
string(REPLACE "noexecstack"
222+
"execstack" MPI_Fortran_LINK_FLAGS_FIXED ${MPI_Fortran_LINK_FLAGS})
223+
set(MPI_C_LINK_FLAGS "${MPI_C_LINK_FLAGS_FIXED}" CACHE STRING
224+
"MPI C linking flags" FORCE)
225+
set(MPI_Fortran_LINK_FLAGS "${MPI_Fortran_LINK_FLAGS_FIXED}" CACHE STRING
226+
"MPI Fortran linking flags" FORCE)
227+
endif()
228+
207229
#--------------------------------------------------------
208230
# Make sure a simple "hello world" C mpi program compiles
209231
#--------------------------------------------------------

0 commit comments

Comments
 (0)