make MPI STUBS a C++ library so its symbols won't collide when loading a real MPI library

This commit is contained in:
Axel Kohlmeyer
2021-02-17 15:02:02 -05:00
parent 742eebec2d
commit 61585b1eb6
7 changed files with 20 additions and 21 deletions

View File

@ -156,8 +156,7 @@ if(BUILD_MPI)
endif()
endif()
else()
enable_language(C)
file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.c)
file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.cpp)
add_library(mpi_stubs STATIC ${MPI_SOURCES})
set_target_properties(mpi_stubs PROPERTIES OUTPUT_NAME lammps_mpi_stubs${LAMMPS_MACHINE})
target_include_directories(mpi_stubs PUBLIC $<BUILD_INTERFACE:${LAMMPS_SOURCE_DIR}/STUBS>)

View File

@ -2,8 +2,7 @@ if(LAMMPS_SIZES STREQUAL BIGBIG)
message(FATAL_ERROR "The MESSAGE Package is not compatible with -DLAMMPS_BIGBIG")
endif()
option(MESSAGE_ZMQ "Use ZeroMQ in MESSAGE package" OFF)
file(GLOB_RECURSE cslib_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.F
${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.c
file(GLOB_RECURSE cslib_SOURCES
${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.cpp)
add_library(cslib STATIC ${cslib_SOURCES})

View File

@ -11,13 +11,13 @@ SHELL = /bin/sh
# Files
SRC = mpi.c
SRC = mpi.cpp
INC = mpi.h
# Definitions
EXE = libmpi_stubs.a
OBJ = $(SRC:.c=.o)
OBJ = $(SRC:.cpp=.o)
# System-specific settings
@ -36,7 +36,7 @@ clean:
# Compilation rules
.c.o:
.cpp.o:
$(CC) $(CCFLAGS) -c $<
# Individual dependencies

View File

@ -5,17 +5,17 @@ SHELL = /bin/sh
# Files
SRC = mpi.c
SRC = mpi.cpp
INC = mpi.h
# Definitions
EXE = libmpi_mingw32.a
OBJ = $(SRC:%.c=%_mingw32.o)
OBJ = $(SRC:%.cpp=%_mingw32.o)
# System-specific settings
CC = i686-w64-mingw32-gcc
CC = i686-w64-mingw32-g++
CCFLAGS = -O2 -Wall -march=i686 -mtune=generic -mfpmath=387 -mpc64 -I.
ARCHIVE = i686-w64-mingw32-ar
ARCHFLAG = rs

View File

@ -5,17 +5,17 @@ SHELL = /bin/sh
# Files
SRC = mpi.c
SRC = mpi.cpp
INC = mpi.h
# Definitions
EXE = libmpi_mingw64.a
OBJ = $(SRC:%.c=%_mingw64.o)
OBJ = $(SRC:%.cpp=%_mingw64.o)
# System-specific settings
CC = x86_64-w64-mingw32-gcc
CC = x86_64-w64-mingw32-g++
CCFLAGS = -O2 -Wall -march=core2 -mtune=core2 -msse2 -mpc64 -I.
ARCHIVE = x86_64-w64-mingw32-ar
ARCHFLAG = rs

View File

@ -16,12 +16,17 @@
#include <stdlib.h>
/* use C bindings for MPI interface */
/* We compile STUBS with C++ so the symbols embedded
* the serial shared library will not collide with any
* corresponding symbols from a real MPI library (which
* uses C bindings). As a consequence the header *must*
* enforce compiling with C++ only. */
#ifdef __cplusplus
extern "C" {
#ifndef __cplusplus
#error "MPI STUBS must be compiled with a C++ compiler"
#endif
/* Dummy defs for MPI stubs */
#define MPI_COMM_WORLD 0
@ -176,8 +181,4 @@ int MPI_Alltoallv(void *sendbuf, int *sendcounts, int *sdispls,
MPI_Datatype recvtype, MPI_Comm comm);
/* ---------------------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif