Skip to content

Commit 259debc

Browse files
committed
fortran: ensure not to use [AM_]CPPFLAGS
Automake's Fortran compilation rules inexplicably use CPPFLAGS and AM_CPPFLAGS. Unfortunately, this can cause problems in some cases (e.g., picking up already-installed mpi.mod in a system-default include search path). So in relevant module-using Fortran compilation Makefile.am's, zero out CPPFLAGS and AM_CPPFLAGS. This has a side-effect of requiring that we compile the one .c file in the F08 library in a new, separate subdirectory (with its own Makefile.am that does _not_ have CPPFLAGS/AM_CPPFLAGS zeroed out). Signed-off-by: Jeff Squyres <[email protected]>
1 parent d523229 commit 259debc

File tree

11 files changed

+107
-17
lines changed

11 files changed

+107
-17
lines changed

config/ompi_config_files.m4

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- shell-script -*-
22
#
3-
# Copyright (c) 2009-2017 Cisco Systems, Inc. All rights reserved
3+
# Copyright (c) 2009-2019 Cisco Systems, Inc. All rights reserved
44
# Copyright (c) 2017-2018 Research Organization for Information Science
55
# and Technology (RIST). All rights reserved.
66
# Copyright (c) 2018 Los Alamos National Security, LLC. All rights
@@ -38,6 +38,7 @@ AC_DEFUN([OMPI_CONFIG_FILES],[
3838
ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-file-interfaces.h
3939
ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-removed-interfaces.h
4040
ompi/mpi/fortran/use-mpi-f08/Makefile
41+
ompi/mpi/fortran/use-mpi-f08/base/Makefile
4142
ompi/mpi/fortran/use-mpi-f08/bindings/Makefile
4243
ompi/mpi/fortran/use-mpi-f08/mod/Makefile
4344
ompi/mpi/fortran/mpiext-use-mpi/Makefile

ompi/Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# University of Stuttgart. All rights reserved.
1010
# Copyright (c) 2004-2005 The Regents of the University of California.
1111
# All rights reserved.
12-
# Copyright (c) 2008-2017 Cisco Systems, Inc. All rights reserved
12+
# Copyright (c) 2008-2019 Cisco Systems, Inc. All rights reserved
1313
# Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
1414
# Copyright (c) 2010-2011 Sandia National Laboratories. All rights reserved.
1515
# Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
@@ -92,6 +92,7 @@ SUBDIRS = \
9292
$(OMPI_MPIEXT_USEMPI_DIR) \
9393
$(OMPI_FORTRAN_USEMPI_DIR) \
9494
mpi/fortran/mpiext-use-mpi \
95+
mpi/fortran/use-mpi-f08/base \
9596
mpi/fortran/use-mpi-f08/mod \
9697
mpi/fortran/use-mpi-f08/bindings \
9798
$(OMPI_MPIEXT_USEMPIF08_DIRS) \
@@ -124,6 +125,7 @@ DIST_SUBDIRS = \
124125
mpi/fortran/use-mpi-ignore-tkr \
125126
mpi/fortran/mpiext-use-mpi \
126127
mpi/fortran/use-mpi-f08 \
128+
mpi/fortran/use-mpi-f08/base \
127129
mpi/fortran/use-mpi-f08/mod \
128130
mpi/fortran/use-mpi-f08/bindings \
129131
mpi/fortran/mpiext-use-mpi-f08 \

ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile.am

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2012 Cisco Systems, Inc. All rights reserved.
2+
# Copyright (c) 2012-2019 Cisco Systems, Inc. All rights reserved.
33
# Copyright (c) 2017 Research Organization for Information Science
44
# and Technology (RIST). All rights reserved.
55
# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
@@ -10,6 +10,13 @@
1010
# $HEADER$
1111
#
1212

13+
# Note that Automake's Fortran-buidling rules uses CPPFLAGS and
14+
# AM_CPPFLAGS. This can cause weirdness (e.g.,
15+
# https://github.com/open-mpi/ompi/issues/7253). Let's just zero
16+
# those out and rely on AM_FCFLAGS.
17+
CPPFLAGS =
18+
AM_CPPFLAGS =
19+
1320
#
1421
# Only do the stuff in this file if we're going to build
1522
# the mpi_f08 ext modules.
@@ -23,7 +30,7 @@ AM_FCFLAGS = -I$(top_builddir)/ompi/include -I$(top_srcdir)/ompi/include \
2330
$(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/base \
2431
$(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/use-mpi-f08/mod \
2532
$(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/use-mpi-f08 \
26-
-I$(top_srcdir) $(FCFLAGS_f90)
33+
-I$(top_srcdir) -I$(top_builddir) $(FCFLAGS_f90)
2734

2835
flibs =
2936

ompi/mpi/fortran/mpiext-use-mpi/Makefile.am

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2012 Cisco Systems, Inc. All rights reserved.
2+
# Copyright (c) 2012-2019 Cisco Systems, Inc. All rights reserved.
33
# Copyright (c) 2017 Research Organization for Information Science
44
# and Technology (RIST). All rights reserved.
55
# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
@@ -10,6 +10,13 @@
1010
# $HEADER$
1111
#
1212

13+
# Note that Automake's Fortran-buidling rules uses CPPFLAGS and
14+
# AM_CPPFLAGS. This can cause weirdness (e.g.,
15+
# https://github.com/open-mpi/ompi/issues/7253). Let's just zero
16+
# those out and rely on AM_FCFLAGS.
17+
CPPFLAGS =
18+
AM_CPPFLAGS =
19+
1320
#
1421
# Only do the stuff in this file if we're going to build
1522
# the mpi ext modules.
@@ -22,7 +29,7 @@ if OMPI_BUILD_FORTRAN_USEMPI_OR_USEMPIF08_EXT
2229
AM_FCFLAGS = -I$(top_builddir)/ompi/include -I$(top_srcdir)/ompi/include \
2330
$(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/base \
2431
$(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/use-mpi-ignore-tkr \
25-
-I$(top_srcdir) $(FCFLAGS_f90)
32+
-I$(top_srcdir) -I$(top_builddir) $(FCFLAGS_f90)
2633

2734
flibs =
2835

ompi/mpi/fortran/use-mpi-f08/Makefile.am

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- makefile.am -*-
22
#
3-
# Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
3+
# Copyright (c) 2006-2019 Cisco Systems, Inc. All rights reserved.
44
# Copyright (c) 2012-2013 The University of Tennessee and The University
55
# of Tennessee Research Foundation. All rights
66
# reserved.
@@ -23,6 +23,13 @@
2323

2424
include $(top_srcdir)/Makefile.ompi-rules
2525

26+
# Note that Automake's Fortran-buidling rules uses CPPFLAGS and
27+
# AM_CPPFLAGS. This can cause weirdness (e.g.,
28+
# https://github.com/open-mpi/ompi/issues/7253). Let's just zero
29+
# those out and rely on AM_FCFLAGS.
30+
CPPFLAGS =
31+
AM_CPPFLAGS =
32+
2633
# This Makefile is only relevant if we're building the "use mpi_f08"
2734
# MPI bindings.
2835
if OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS
@@ -32,7 +39,7 @@ AM_FCFLAGS = -I$(top_builddir)/ompi/include \
3239
$(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/$(OMPI_FORTRAN_USEMPI_DIR) \
3340
$(OMPI_FC_MODULE_FLAG)mod \
3441
$(OMPI_FC_MODULE_FLAG)bindings \
35-
-I$(top_srcdir) $(FCFLAGS_f90)
42+
-I$(top_srcdir) -I$(top_builddir) $(FCFLAGS_f90)
3643

3744
MOSTLYCLEANFILES = *.mod
3845

@@ -801,8 +808,7 @@ pmpi_api_files = \
801808
lib@OMPI_LIBMPI_NAME@_usempif08_la_SOURCES = \
802809
$(mpi_api_files) \
803810
$(pmpi_api_files) \
804-
mpi-f08.F90 \
805-
buffer_detach.c
811+
mpi-f08.F90
806812

807813
# These are generated; do not ship them
808814
nodist_lib@OMPI_LIBMPI_NAME@_usempif08_la_SOURCES =
@@ -818,12 +824,17 @@ endif
818824
#
819825
# Include the mpi_f08-based MPI extensions in libmpi_usempif08, too.
820826
#
827+
# Also include the one .c file that we need in this library -- because
828+
# we zero out CPPFLAGS and AM_CPPFLAGS in this Makefile.am, we have to
829+
# compile that .c file in a separate directory / Makefile.
830+
#
821831

822832
lib@OMPI_LIBMPI_NAME@_usempif08_la_LIBADD = \
823833
$(OMPI_MPIEXT_USEMPIF08_LIBS) \
824834
$(top_builddir)/ompi/mpi/fortran/mpif-h/lib@OMPI_LIBMPI_NAME@_mpifh.la \
825835
$(top_builddir)/ompi/lib@[email protected] \
826-
mod/libusempif08_internal_modules.la
836+
mod/libusempif08_internal_modules.la \
837+
base/libusempif08_ccode.la
827838
lib@OMPI_LIBMPI_NAME@_usempif08_la_DEPENDENCIES = $(module_sentinel_files)
828839
lib@OMPI_LIBMPI_NAME@_usempif08_la_LDFLAGS = -version-info $(libmpi_usempif08_so_version)
829840

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# -*- makefile -*-
2+
#
3+
# Copyright (c) 2019 Cisco Systems, Inc. All rights reserved.
4+
#
5+
# $COPYRIGHT$
6+
#
7+
# Additional copyrights may follow
8+
#
9+
# $HEADER$
10+
#
11+
12+
include $(top_srcdir)/Makefile.ompi-rules
13+
14+
# This Makefile is only relevant if we're building the "use mpi_f08"
15+
# MPI bindings.
16+
if OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS
17+
18+
# This directory only exists so that we can separate C compilation
19+
# from Fortran compilation. Specifically: note that Automake's
20+
# Fortran-buidling rules uses CPPFLAGS and AM_CPPFLAGS. This can
21+
# cause weirdness (e.g.,
22+
# https://github.com/open-mpi/ompi/issues/7253). So when compiling
23+
# Fortran, we should zero out CPPFLAGS and AM_CPPFLAGS.
24+
25+
# HOWEVER, we have one .c file in the use-mpi-f08 library. So we have
26+
# to split it out to its own directory / Makefile.am where CPPFLAGS /
27+
# AM_CPPFLAGS are *not* zeroed out.
28+
29+
noinst_LTLIBRARIES = libusempif08_ccode.la
30+
31+
libusempif08_ccode_la_SOURCES = \
32+
buffer_detach.c
33+
34+
endif

ompi/mpi/fortran/use-mpi-f08/bindings/Makefile.am

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- makefile -*-
22
#
3-
# Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
3+
# Copyright (c) 2006-2019 Cisco Systems, Inc. All rights reserved.
44
# Copyright (c) 2012-2013 The University of Tennessee and The University
55
# of Tennessee Research Foundation. All rights
66
# reserved.
@@ -20,6 +20,13 @@
2020

2121
include $(top_srcdir)/Makefile.ompi-rules
2222

23+
# Note that Automake's Fortran-buidling rules uses CPPFLAGS and
24+
# AM_CPPFLAGS. This can cause weirdness (e.g.,
25+
# https://github.com/open-mpi/ompi/issues/7253). Let's just zero
26+
# those out and rely on AM_FCFLAGS.
27+
CPPFLAGS =
28+
AM_CPPFLAGS =
29+
2330
# This Makefile is only relevant if we're building the "use mpi_f08"
2431
# MPI bindings.
2532
if OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS
@@ -29,7 +36,7 @@ AM_FCFLAGS = -I$(top_builddir)/ompi/include \
2936
$(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/$(OMPI_FORTRAN_USEMPI_DIR) \
3037
$(OMPI_FC_MODULE_FLAG). \
3138
$(OMPI_FC_MODULE_FLAG)../mod \
32-
-I$(top_srcdir) $(FCFLAGS_f90)
39+
-I$(top_srcdir) -I$(top_builddir) $(FCFLAGS_f90)
3340

3441
MOSTLYCLEANFILES = *.mod
3542

ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- makefile -*-
22
#
3-
# Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
3+
# Copyright (c) 2006-2019 Cisco Systems, Inc. All rights reserved.
44
# Copyright (c) 2012-2013 The University of Tennessee and The University
55
# of Tennessee Research Foundation. All rights
66
# reserved.
@@ -20,6 +20,13 @@
2020

2121
include $(top_srcdir)/Makefile.ompi-rules
2222

23+
# Note that Automake's Fortran-buidling rules uses CPPFLAGS and
24+
# AM_CPPFLAGS. This can cause weirdness (e.g.,
25+
# https://github.com/open-mpi/ompi/issues/7253). Let's just zero
26+
# those out and rely on AM_FCFLAGS.
27+
CPPFLAGS =
28+
AM_CPPFLAGS =
29+
2330
# This Makefile is only relevant if we're building the "use mpi_f08"
2431
# MPI bindings.
2532
if OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS
@@ -28,7 +35,7 @@ AM_FCFLAGS = -I$(top_builddir)/ompi/include \
2835
-I$(top_srcdir)/ompi/include \
2936
$(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/$(OMPI_FORTRAN_USEMPI_DIR) \
3037
$(OMPI_FC_MODULE_FLAG). \
31-
-I$(top_srcdir) $(FCFLAGS_f90)
38+
-I$(top_srcdir) -I$(top_builddir) $(FCFLAGS_f90)
3239

3340
MOSTLYCLEANFILES = *.mod
3441

ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515

1616
include $(top_srcdir)/Makefile.ompi-rules
1717

18+
# Note that Automake's Fortran-buidling rules uses CPPFLAGS and
19+
# AM_CPPFLAGS. This can cause weirdness (e.g.,
20+
# https://github.com/open-mpi/ompi/issues/7253). Let's just zero
21+
# those out and rely on AM_FCFLAGS.
22+
CPPFLAGS =
23+
AM_CPPFLAGS =
24+
1825
# This Makefile is only relevant if we're building the ignore-TKR "use
1926
# mpi" MPI bindings.
2027
if OMPI_BUILD_FORTRAN_USEMPI_IGNORE_TKR_BINDINGS

ompi/mpi/fortran/use-mpi-tkr/Makefile.am

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# University of Stuttgart. All rights reserved.
1111
# Copyright (c) 2004-2005 The Regents of the University of California.
1212
# All rights reserved.
13-
# Copyright (c) 2006-2018 Cisco Systems, Inc. All rights reserved
13+
# Copyright (c) 2006-2019 Cisco Systems, Inc. All rights reserved
1414
# Copyright (c) 2007 Los Alamos National Security, LLC. All rights
1515
# reserved.
1616
# Copyright (c) 2014-2016 Research Organization for Information Science
@@ -32,6 +32,13 @@ include $(top_srcdir)/Makefile.ompi-rules
3232
# this directory -- instead, they compile
3333
# ompi/fortran/use-mpi-ignore-tkr.
3434

35+
# Note that Automake's Fortran-buidling rules uses CPPFLAGS and
36+
# AM_CPPFLAGS. This can cause weirdness (e.g.,
37+
# https://github.com/open-mpi/ompi/issues/7253). Let's just zero
38+
# those out and rely on AM_FCFLAGS.
39+
CPPFLAGS =
40+
AM_CPPFLAGS =
41+
3542
if OMPI_BUILD_FORTRAN_USEMPI_TKR_BINDINGS
3643

3744
########################################################################
@@ -41,7 +48,7 @@ if OMPI_BUILD_FORTRAN_USEMPI_TKR_BINDINGS
4148
# current directory) because it is generated.
4249

4350
AM_FCFLAGS = -I$(top_builddir)/ompi/include -I$(top_srcdir)/ompi/include \
44-
$(OMPI_FC_MODULE_FLAG). -I$(srcdir) -I. \
51+
$(OMPI_FC_MODULE_FLAG). -I$(top_srcdir) -I$(top_builddir) -I. \
4552
-I$(top_builddir)/ompi/mpi/fortran/use-mpi-tkr $(FCFLAGS_f90)
4653

4754
# Do different things if the top-level configure decided that we're

0 commit comments

Comments
 (0)