Skip to content

Defect: master, src/mpi/CMakeLists.txt 3rd argument of CHECK_SYMBOL_EXISTS #457

Closed
@jbmaggard

Description

@jbmaggard

Defect/Bug Report

  • OpenCoarrays Version: master and 1.9.2
  • Version of CMake: 3.9.2 (on MSYS) and 3.9.3 (on Linux)

Observed Behavior

Line 52 of src/mpi/CMakeLists.txt: Unless the 3rd argument of CHECK_SYMBOL_EXISTS is a new, unused variable, the function does not seem to be called (or perhaps is called, but does not produce any output or change the value of the 3rd argument).

Expected Behavior

Verify SIGKILL is defined, with -D_POSIX required for GCC, MinGW-w64 on Windows (including MSYS).

Steps to Reproduce

A small test example:

$ pacman -Ss mingw-w64-x86_64-gcc-fortran
mingw64/mingw-w64-x86_64-gcc-fortran 7.2.0-1 (mingw-w64-x86_64-toolchain) [installed]
    GNU Compiler Collection (Fortran) for MinGW-w64

$ rm -rf build
$ cat src/CMakeLists.txt
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
project(sigkill NONE)
enable_language(C)
include(CheckIncludeFile)
CHECK_INCLUDE_FILE("signal.h" HAVE_SIGNAL_H)
#add_executable(h h.c)
include(CheckSymbolExists)
CHECK_SYMBOL_EXISTS(SIGINT "signal.h" HAVE_SIGINT)
CHECK_SYMBOL_EXISTS(SIGKILL "signal.h" HAVE_SIGKILL)
CHECK_SYMBOL_EXISTS(SIGILL "signal.h" HAVE_SIGILL)
if(NOT HAVE_SIGKILL)
  message("Trying -D_POSIX")
  list( APPEND CMAKE_REQUIRED_DEFINITIONS -D_POSIX)
  CHECK_SYMBOL_EXISTS(SIGKILL "signal.h" HAVE_SIGKILL_NEW)
endif()

$ cmake -Bbuild -Hsrc -G "MSYS Makefiles"
-- The C compiler identification is GNU 7.2.0
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for signal.h
-- Looking for signal.h - found
-- Looking for SIGINT
-- Looking for SIGINT - found
-- Looking for SIGKILL
-- Looking for SIGKILL - not found
-- Looking for SIGILL
-- Looking for SIGILL - found
Trying -D_POSIX
-- Looking for SIGKILL
-- Looking for SIGKILL - found
-- Configuring done
-- Generating done
-- Build files have been written to: C:/msys64/home/bmaggard/temp/sigkill/build

SIGKILL is found after the Trying -D_POSIX message. Switching HAVE_SIGKILL_NEW to the previously used variable HAVE_SIGKILL results in the following output:

$ cmake -Bbuild -Hsrc -G "MSYS Makefiles"
-- The C compiler identification is GNU 7.2.0
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for signal.h
-- Looking for signal.h - found
-- Looking for SIGINT
-- Looking for SIGINT - found
-- Looking for SIGKILL
-- Looking for SIGKILL - not found
-- Looking for SIGILL
-- Looking for SIGILL - found
Trying -D_POSIX
-- Configuring done
-- Generating done
-- Build files have been written to: C:/msys64/home/bmaggard/temp/sigkill/build

With SIGKILL not found after the Trying -D_POSIX message.

Similar behavior with 3rd argument was reproduced on Linux (-G "Unix Makefiles") with cmake 3.9.3; for example, attempting to reuse the HAVE_SIGINT variable with one of the other calls to CHECK_SYMBOL_EXISTS.

The simple work-around for src/mpi/CMakeLists.txt would be to use a new variable for each call to CHECK_SYMBOL_EXISTS.

I didn't see anything about this cmake feature in the documentation or during a brief web search. However, I am a very much a novice with cmake.

@zbeekman
I am continuing to progress on implementation of CAF using the native Windows MSYS gfortran, the Intel-MPI runtime, and building OpenCoarrays.

Adding a couple of symlinks and the previously discussed import library to the MPI runtime installation (#435), I have implemented bash scripts for mpirun (which simply executes the Intel mpiexec.exe), mpicc, and mpifort (mpicc and mpifort are taken from MPICH 3.2, with only the path variables near the top changed) all working together in a fashion similar to MPICH on Linux.

Minor changes to (cmake command line near end of) prerequisites/install-functions/build_opencoarrays.sh, allows install.sh to make it to the first cmake command, which is where I'm at right now. I'm currently learning about MPI builds with cmake. I'll keep you updated if/when I get to the point where it is more feasible to consider adding to install.sh.

I'm considering a way that does not require use of the header files (mpi.h, mpif.h, mpio.h, and mpiof.h) from the Intel-MPI SDK. Since Intel-MPI is ABI compatible with MPICH, it may be possible to use the MPICH header files (with MPI_Aint of type long long on Windows). With ABI compatibility, it may even be possible to build and use the mpi.mod from MPICH source code, to interface with the Intel-MPI runtime.

I recall an article at intel.com discussing using code compiled for Intel-MPI but executing under MSMPI (and/or vice versa); implying that if the runtime has the necessary MPI functions for OpenCoarrays (MSMPI currently does not, but Intel-MPI does), then the MPI functions should be accessible through the same ABI (and therefore, theoretically by using the same .h files {and/or same source code for mpi.mod}) as the MPICH runtime.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions