From 141f14c2c4affbaff04f4f4a9ac947c2e456a0cc Mon Sep 17 00:00:00 2001 From: Geoffrey Paulsen Date: Tue, 22 Jan 2019 10:07:50 -0500 Subject: [PATCH] Fix the Removed MPI APIs to fatally error if possible. Addresses https://github.com/open-mpi/ompi/issues/6278 In v4.0.x we intended that if the user did not configure with --enable-mpi1-compatibility, that they would get a Fatal error, even though we are building those removed symbols into libmpi. (to support MPI applications compiled and linked with v3.x) This commit changes removed MPI APIs to try to use either the error function attribute (if the compiler supports it) or to use use the C11 Static Assert (also if supported by the compiler) If the compiler doesn't offer this support, the user will instead just get an error trying to use a function that wasn't declared. Signed-off-by: Geoffrey Paulsen --- ompi/include/mpi.h.in | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/ompi/include/mpi.h.in b/ompi/include/mpi.h.in index 4168e6fcb79..841256613ef 100644 --- a/ompi/include/mpi.h.in +++ b/ompi/include/mpi.h.in @@ -19,7 +19,7 @@ * Copyright (c) 2015 University of Houston. All rights reserved. * Copyright (c) 2015-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2017-2018 IBM Corporation. All rights reserved. + * Copyright (c) 2017-2019 IBM Corporation. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -279,10 +279,20 @@ # define __mpi_interface_deprecated__(msg) __attribute__((__deprecated__)) # endif # endif -# if (OMPI_ENABLE_MPI1_COMPAT && !OMPI_BUILDING) -# define __mpi_interface_removed__(msg) __mpi_interface_deprecated__(msg) -# define OMPI_OMIT_MPI1_COMPAT_DECLS 0 +# endif +# if (!OMPI_ENABLE_MPI1_COMPAT && !OMPI_BUILDING) +# if OPAL_HAVE_ATTRIBUTE_ERROR +# define __mpi_interface_removed__(msg) __attribute__((__error__(msg))) +# else +# if (__STDC_VERSION__ >= 201101L) +# define __mpi_interface_removed__(msg) _Static_assert(0,msg) +# endif # endif +# else + /* If configured with --enable-mpi1-compatibility, emit + * warning with the deprecated function attribute instead. + */ +# define __mpi_interface_removed__(msg) __mpi_interface_deprecated__(msg) # endif # endif #endif @@ -1003,8 +1013,9 @@ OMPI_DECLSPEC extern MPI_Fint *MPI_F_STATUSES_IGNORE; #if (!OMPI_OMIT_MPI1_COMPAT_DECLS || OMPI_BUILDING) /* - * Removed datatypes. These datatypes are only available if Open MPI - * was configured with --enable-mpi1-compatibility. + * Removed datatypes. These datatypes _SHOULD_ only be available + * if Open MPI was configured with --enable-mpi1-compatibility, + * however they * * These datatypes were formally removed from the MPI specification * and should no longer be used in MPI applications. @@ -1012,10 +1023,8 @@ OMPI_DECLSPEC extern MPI_Fint *MPI_F_STATUSES_IGNORE; #define MPI_UB OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_ub) #define MPI_LB OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_lb) -OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_lb - __mpi_interface_removed__("MPI_LB was removed in MPI-3.0; use MPI_Type_create_resized instead."); -OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_ub - __mpi_interface_removed__("MPI_UB was removed in MPI-3.0; use MPI_Type_create_resized instead."); +OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_lb; +OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_ub; #endif /* !OMPI_OMIT_MPI1_COMPAT_DECLS */ /* @@ -2739,7 +2748,7 @@ OMPI_DECLSPEC int MPI_Type_ub(MPI_Datatype mtype, MPI_Aint *ub) __mpi_interface_removed__("MPI_Type_ub has been removed in MPI-3.0; use MPI_Type_get_extent instead."); OMPI_DECLSPEC int PMPI_Type_ub(MPI_Datatype mtype, MPI_Aint *ub) __mpi_interface_removed__("PMPI_Type_ub has been removed in MPI-3.0; use PMPI_Type_get_extent instead."); -#endif /* !OMPI_OMIT_MPI1_COMPAT_DECLS */ +#endif #if defined(c_plusplus) || defined(__cplusplus) }