From 0c102e6e5b85d9b9b6eea9f689343c51518c93b6 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 20 Jul 2006 19:48:03 +0000 Subject: [PATCH] Fix OSX linker problems with the Fortran bindings: - ensure to initialize the values that we use for fortran constants (even tough their *values* don't matter -- only their *addresses* do, but initializing them or not has implications for the OSX linker) - move the fortran constants to a file with functions in it, because the OSX linker sometimes does not import global variables from object files that do not have functions (I'm not even going to pretend to get all the subtle details about the OSX linker right here -- it's just "better" to have global variables in object files with functions that otherwise get pulled in during linker resolution). This commit was SVN r10908. --- ompi/mpi/f77/Makefile.am | 4 +-- ompi/mpi/f77/constants.h | 3 +++ ompi/mpi/f77/constants_f.c | 43 --------------------------------- ompi/mpi/f77/test_constants_f.c | 43 +++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 45 deletions(-) delete mode 100644 ompi/mpi/f77/constants_f.c diff --git a/ompi/mpi/f77/Makefile.am b/ompi/mpi/f77/Makefile.am index a44aedc8d1..76afdeed60 100644 --- a/ompi/mpi/f77/Makefile.am +++ b/ompi/mpi/f77/Makefile.am @@ -9,6 +9,7 @@ # University of Stuttgart. All rights reserved. # Copyright (c) 2004-2005 The Regents of the University of California. # All rights reserved. +# Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -62,14 +63,13 @@ headers = \ # libmpi_f77_la_SOURCES = \ - constants_f.c \ attr_fn_f.c \ f90_accessors.c \ strings.c \ test_constants_f.c # -# libmpi_c_mpi.la is only built in some cases (see above) +# These files are only built and added to libmpi_f77.la in certain cases. # libmpi_f77_mpi_la_SOURCES = \ diff --git a/ompi/mpi/f77/constants.h b/ompi/mpi/f77/constants.h index 62902511fc..96dda98dda 100644 --- a/ompi/mpi/f77/constants.h +++ b/ompi/mpi/f77/constants.h @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -40,8 +41,10 @@ #if defined(HAVE_LONG_DOUBLE) && OMPI_ALIGNMENT_LONG_DOUBLE == 16 typedef struct { long double bogus[1]; } ompi_fortran_common_t; +#define OMPI_FORTRAN_COMMON_INIT {{ 0 }} #else typedef struct { double bogus[2]; } ompi_fortran_common_t; +#define OMPI_FORTRAN_COMMON_INIT {{ 0, 0 }} #endif /* diff --git a/ompi/mpi/f77/constants_f.c b/ompi/mpi/f77/constants_f.c deleted file mode 100644 index 215341b2d8..0000000000 --- a/ompi/mpi/f77/constants_f.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana - * University Research and Technology - * Corporation. All rights reserved. - * Copyright (c) 2004-2005 The University of Tennessee and The University - * of Tennessee Research Foundation. All rights - * reserved. - * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, - * University of Stuttgart. All rights reserved. - * Copyright (c) 2004-2005 The Regents of the University of California. - * All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "ompi_config.h" - -#include "ompi/mpi/f77/bindings.h" -#include "constants.h" - -#define INST(upper_case, lower_case, single_u, double_u) \ -ompi_fortran_common_t lower_case; \ -ompi_fortran_common_t upper_case; \ -ompi_fortran_common_t single_u; \ -ompi_fortran_common_t double_u - -INST(MPI_FORTRAN_BOTTOM, mpi_fortran_bottom, - mpi_fortran_bottom_, mpi_fortran_bottom__); -INST(MPI_FORTRAN_IN_PLACE, mpi_fortran_in_place, - mpi_fortran_in_place_, mpi_fortran_in_place__); -INST(MPI_FORTRAN_ARGV_NULL, mpi_fortran_argv_null, - mpi_fortran_argv_null_, mpi_fortran_argv_null__); -INST(MPI_FORTRAN_ARGVS_NULL, mpi_fortran_argvs_null, - mpi_fortran_argvs_null_, mpi_fortran_argvs_null__); -INST(MPI_FORTRAN_ERRCODES_IGNORE, mpi_fortran_errcodes_ignore, - mpi_fortran_errcodes_ignore_, mpi_fortran_errcodes_ignore__); -INST(MPI_FORTRAN_STATUS_IGNORE, mpi_fortran_status_ignore, - mpi_fortran_status_ignore_, mpi_fortran_status_ignore__); -INST (MPI_FORTRAN_STATUSES_IGNORE, mpi_fortran_statuses_ignore, - mpi_fortran_statuses_ignore_, mpi_fortran_statuses_ignore__); diff --git a/ompi/mpi/f77/test_constants_f.c b/ompi/mpi/f77/test_constants_f.c index f631e66007..5c5c043437 100644 --- a/ompi/mpi/f77/test_constants_f.c +++ b/ompi/mpi/f77/test_constants_f.c @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -21,6 +22,48 @@ #include "ompi/mpi/f77/bindings.h" #include "ompi/mpi/f77/constants.h" +/** + * This file contains two parts: + * + * 1. Various constants used in the Fortran bindings. + * 2. A special, internal OMPI function used for testing constant + * values (i.e., not an MPI API function) + * + * The constants in #1 are in this file because certain linkers (e.g., + * OSX) need to have object files with functions in them or they won't + * pull in global variables from that file. Specifically, the + * constants in #1 used to be in a .c file by themselves (with no + * functions), which led to certain cases where the OSX linker + * wouldn't "see" them because there were no functions in the + * resulting .o file that would cause the constants to be pulled for + * run-time/link-time resolution. + */ + +/* Constants for the Fortran layer. These values are referred to via + common blocks in the Fortran equivalents. See + ompi/mpi/f77/constants.h for a more detailed explanation. */ + +#define INST(upper_case, lower_case, single_u, double_u) \ +ompi_fortran_common_t lower_case = OMPI_FORTRAN_COMMON_INIT; \ +ompi_fortran_common_t upper_case = OMPI_FORTRAN_COMMON_INIT; \ +ompi_fortran_common_t single_u = OMPI_FORTRAN_COMMON_INIT; \ +ompi_fortran_common_t double_u = OMPI_FORTRAN_COMMON_INIT + +INST(MPI_FORTRAN_BOTTOM, mpi_fortran_bottom, + mpi_fortran_bottom_, mpi_fortran_bottom__); +INST(MPI_FORTRAN_IN_PLACE, mpi_fortran_in_place, + mpi_fortran_in_place_, mpi_fortran_in_place__); +INST(MPI_FORTRAN_ARGV_NULL, mpi_fortran_argv_null, + mpi_fortran_argv_null_, mpi_fortran_argv_null__); +INST(MPI_FORTRAN_ARGVS_NULL, mpi_fortran_argvs_null, + mpi_fortran_argvs_null_, mpi_fortran_argvs_null__); +INST(MPI_FORTRAN_ERRCODES_IGNORE, mpi_fortran_errcodes_ignore, + mpi_fortran_errcodes_ignore_, mpi_fortran_errcodes_ignore__); +INST(MPI_FORTRAN_STATUS_IGNORE, mpi_fortran_status_ignore, + mpi_fortran_status_ignore_, mpi_fortran_status_ignore__); +INST (MPI_FORTRAN_STATUSES_IGNORE, mpi_fortran_statuses_ignore, + mpi_fortran_statuses_ignore_, mpi_fortran_statuses_ignore__); + /* This is an internal test function for Open MPI; it does not have a profiled equivalent. */