Skip to content

Commit 9779813

Browse files
authored
Merge pull request #8077 from bwbarrett/bugfix/visibility
Fix 3rd-party package CPPFLAGS (and others) handlinge
2 parents 6c46da3 + 78dfe45 commit 9779813

File tree

6 files changed

+149
-30
lines changed

6 files changed

+149
-30
lines changed

config/aclocal_subcfg.m4

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,33 +73,47 @@ AC_DEFUN([PAC_CONFIG_SUBDIR_ARGS],[
7373
--disable-option-checking)
7474
;;
7575
*)
76-
# MPICH note: this is a more robust version of the "precious
77-
# variable" propagation code that was present in the previous
78-
# incarnation of this macro
76+
# strip out precious variables from ac_configure_args,
77+
# which will include precious variables that are currently
78+
# set and were set on the command line or in the
79+
# environment at the time configure was invoked. Instead,
80+
# we add all precious variables which have been tagged as
81+
# set, so that we can more closely control the environment
82+
# of sub-configures.
83+
is_precious=0
7984
for pac_pvar in $ac_precious_vars ; do
8085
# check if configure argument token contains the
8186
# precious variable, i.e. "name_of_prec_var=".
8287
if ( echo $pac_arg | grep "^$pac_pvar=" >/dev/null 2>&1 ) ; then
83-
# check if current precious variable is set in env
84-
eval pvar_set=\${$pac_pvar+set}
85-
if test "$pvar_set" = "set" ; then
86-
# Append 'name_of_prec_var=value_of_prec_var'
87-
# to the subconfigure arguments list, where
88-
# value_of_prec_var is fetched from the env.
89-
# this also overrides any value set on the command line
90-
eval pac_pval=\${$pac_pvar}
91-
pac_arg="$pac_pvar=$pac_pval"
92-
break
93-
fi
88+
is_precious=1
89+
break
9490
fi
9591
done
96-
case $pac_arg in
97-
*\'*) pac_arg=`AS_ECHO(["$pac_arg"]) | sed "s/'/'\\\\\\\\''/g"` ;;
98-
esac
99-
AS_VAR_APPEND([pac_sub_configure_args], [" '$pac_arg'"]) ;;
92+
if test $is_precious -eq 0; then
93+
case $pac_arg in
94+
*\'*) pac_arg=`AS_ECHO(["$pac_arg"]) | sed "s/'/'\\\\\\\\''/g"` ;;
95+
esac
96+
AS_VAR_APPEND([pac_sub_configure_args], [" '$pac_arg'"])
97+
fi ;;
10098
esac
10199
done
102100
101+
# add all precious values with a set token to the configure
102+
# args. If the caller hasn't artificially manipulated the
103+
# environment, this will simply be any precious variables as
104+
# they were originally specified on the top-level configure
105+
# line (or in the environment at start of configure).
106+
# However, callers may manipulate that environment, preferably
107+
# with the OPAL_SUBDIR_ENV macros.
108+
for temp_var in $ac_precious_vars; do
109+
eval temp_var_set=\$ac_env_${temp_var}_set
110+
if test "$temp_var_set" = "set" ; then
111+
eval temp_val=\$$temp_var
112+
temp_arg="$temp_var=$temp_val"
113+
AS_VAR_APPEND([pac_sub_configure_args], [" '$temp_arg'"])
114+
fi
115+
done
116+
103117
# Always prepend --prefix to ensure using the same prefix
104118
# in subdir configurations.
105119
# MPICH note: see tt#983 for an example of why this is necessary

config/ompi_setup_prrte.m4

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ AC_DEFUN([OMPI_SETUP_PRRTE],[
4949
])
5050

5151
AC_DEFUN([OMPI_SETUP_PRRTE_INTERNAL], [
52-
OPAL_VAR_SCOPE_PUSH([internal_prrte_args internal_prrte_extra_libs internal_prrte_happy deprecated_prefix_by_default print_prrte_warning])
52+
OPAL_VAR_SCOPE_PUSH([internal_prrte_args internal_prrte_extra_libs internal_prrte_happy deprecated_prefix_by_default print_prrte_warning internal_prrte_CPPFLAGS])
5353

5454
opal_show_subtitle "Configuring PRRTE"
5555

@@ -91,6 +91,7 @@ AC_DEFUN([OMPI_SETUP_PRRTE_INTERNAL], [
9191
AS_IF([test "$enable_internal_rte" = "no"],
9292
[internal_prrte_happy="no"])
9393

94+
internal_prrte_CPPFLAGS=
9495
internal_prrte_args="--with-proxy-version-string=$OPAL_VERSION --with-proxy-package-name=\"Open MPI\" --with-proxy-bugreport=\"https://www.open-mpi.org/community/help/\""
9596
internal_prrte_libs=
9697

@@ -99,20 +100,23 @@ AC_DEFUN([OMPI_SETUP_PRRTE_INTERNAL], [
99100
# user did not specify an option. PRTE defaults to not enabling
100101
# prefix-by-default, but open mpi wants that behavior.
101102
AS_IF([test -n "$deprecated_prefix_by_default"],
102-
[internal_prrte_args="internal_prrte_args --enable-prte-prefix-by-default=$deprecated_prefix_by_default"],
103+
[internal_prrte_args="$internal_prrte_args --enable-prte-prefix-by-default=$deprecated_prefix_by_default"],
103104
[test -z "$enable_prte_prefix_by_default"],
104105
[internal_prrte_args="$internal_prrte_args --enable-prte-prefix-by-default"])
105106

106107
AS_IF([test "$opal_libevent_mode" = "internal"],
107108
[internal_prrte_args="$internal_prrte_args --with-libevent-header=$opal_libevent_header"
109+
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_libevent_CPPFLAGS"
108110
internal_prrte_libs="$internal_prrte_libs $opal_libevent_LIBS"])
109111

110112
AS_IF([test "$opal_hwloc_mode" = "internal"],
111113
[internal_prrte_args="$internal_prrte_args --with-hwloc-header=$opal_hwloc_header"
114+
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_hwloc_CPPFLAGS"
112115
internal_prrte_libs="$internal_prrte_libs $opal_hwloc_LIBS"])
113116

114117
AS_IF([test "$opal_pmix_mode" = "internal"],
115118
[internal_prrte_args="$internal_prrte_args --with-pmix-header=$opal_pmix_header"
119+
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_pmix_CPPFLAGS"
116120
internal_prrte_libs="$internal_prrte_libs $opal_pmix_LIBS"])
117121

118122
AS_IF([test "$internal_prrte_happy" = "yes"],
@@ -133,23 +137,23 @@ AC_DEFUN([OMPI_SETUP_PRRTE_INTERNAL], [
133137
AC_MSG_WARN([--disable-internal-rte option.])
134138
AC_MSG_ERROR([Cannot continue])])])
135139

136-
dnl AS_IF([test ! -z $with_prrte_platform && test "$with_prrte_platform" != "yes"],
137-
dnl [internal_prrte_args="$internal_prrte_args --with-platform=$with_prrte_platform"])
138-
139140
# add the extra libs
140141
internal_prrte_args="$internal_prrte_args --with-prte-extra-lib=\"$internal_prrte_libs\" --with-prte-extra-ltlib=\"$internal_prrte_libs\""
141142

142143
# Pass all our compiler/linker flags to PRRTE, so that it
143144
# picks up how to build an internal HWLOC, libevent, and PMIx, plus
144145
# picks up any user-specified compiler flags from the master
145146
# configure run.
146-
export CFLAGS CPPFLAGS LDFLAGS
147+
OPAL_SUBDIR_ENV_CLEAN([opal_prrte_configure])
148+
AS_IF([test -n "$internal_prrte_CPPFLAGS"],
149+
[OPAL_SUBDIR_ENV_APPEND([CPPFLAGS], [$internal_prrte_CPPFLAGS])])
147150
PAC_CONFIG_SUBDIR_ARGS([3rd-party/prrte], [$internal_prrte_args],
148151
[[--with-libevent=internal], [--with-hwloc=internal],
149152
[--with-libevent=external], [--with-hwloc=external],
150153
[--with-pmix=internal], [--with-pmix=external],
151-
[--with-platform=.*]],
154+
[--with-platform=[[^ ]]*]],
152155
[], [internal_prrte_happy="no"])
156+
OPAL_SUBDIR_ENV_RESTORE([opal_prrte_configure])
153157
OPAL_3RDPARTY_DIST_SUBDIRS="$OPAL_3RDPARTY_DIST_SUBDIRS prrte"
154158

155159
AS_IF([test "$internal_prrte_happy" = "no" -a "$enable_internal_rte" != "no"],

config/opal_config_hwloc.m4

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,18 @@ AC_DEFUN([_OPAL_CONFIG_HWLOC_INTERNAL], [
154154
# Note: To update the version of hwloc shipped, update the
155155
# constant in autogen.pl.
156156
OPAL_EXPAND_TARBALL([3rd-party/hwloc_tarball], [3rd-party/hwloc_directory], [configure])
157+
OPAL_SUBDIR_ENV_CLEAN([opal_hwloc_configure])
157158
PAC_CONFIG_SUBDIR_ARGS([3rd-party/hwloc_directory], [], [],
158159
[subconfig_happy=1], [subconfig_happy=0])
160+
OPAL_SUBDIR_ENV_RESTORE([opal_hwloc_configure])
159161
160162
AS_IF([test "$subconfig_happy" = "1"],
161163
[internal_hwloc_location="3rd-party/hwloc_directory"
162164
# note: because we only ship/commit a tarball (and not the source
163165
# directory), the source is always expanded in the builddir, so we
164166
# only need to add a -I to the builddir.
165-
CPPFLAGS="$CPPFLAGS -I$OMPI_TOP_BUILDDIR/$internal_hwloc_location/include -I$OMPI_TOP_SRCDIR/$internal_hwloc_location/include"
167+
opal_hwloc_CPPFLAGS="-I$OMPI_TOP_BUILDDIR/$internal_hwloc_location/include -I$OMPI_TOP_SRCDIR/$internal_hwloc_location/include"
168+
CPPFLAGS="$CPPFLAGS $opal_hwloc_CPPFLAGS"
166169
# No need to update LDFLAGS, because they will install into
167170
# our tree and in the mean time are referenced by their .la
168171
# files.

config/opal_config_libevent.m4

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,19 @@ AC_DEFUN([_OPAL_CONFIG_LIBEVENT_INTERNAL], [
183183
# Libevent, so we will never actually fix said warnnings and 2)
184184
# some of the warning options cause failures with compilers that
185185
# fake being GCC (I'm looking at you, PGI).
186+
OPAL_SUBDIR_ENV_CLEAN([opal_libevent_configure])
186187
PAC_CONFIG_SUBDIR_ARGS([3rd-party/libevent_directory],
187188
[--disable-dns --disable-http --disable-rpc --disable-openssl --enable-thread-support --disable-evport --disable-gcc-warnings],
188189
[], [subconfig_happy=1], [subconfig_happy=0])
190+
OPAL_SUBDIR_ENV_RESTORE([opal_libevent_configure])
189191
190192
AS_IF([test "$subconfig_happy" = "1"],
191193
[internal_libevent_location="3rd-party/libevent_directory"
192194
# note: because we only ship/commit a tarball (and not the source
193195
# directory), the source is always expanded in the builddir, so we
194196
# only need to add a -I to the builddir.
195-
CPPFLAGS="$CPPFLAGS -I$OMPI_TOP_BUILDDIR/$internal_libevent_location -I$OMPI_TOP_BUILDDIR/$internal_libevent_location/include"
197+
opal_libevent_CPPFLAGS="-I$OMPI_TOP_BUILDDIR/$internal_libevent_location -I$OMPI_TOP_BUILDDIR/$internal_libevent_location/include"
198+
CPPFLAGS="$CPPFLAGS $opal_libevent_CPPFLAGS"
196199
# No need to update LDFLAGS, because they will install into
197200
# our tree and in the mean time are referenced by their .la
198201
# files.

config/opal_config_pmix.m4

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ dnl LD_LIBRARY_PATH.
5757
dnl * CPPFLAGS, LDFLAGS - Updated opal_pmix_CPPFLAGS and
5858
dnl opal_pmix_LDFLAGS.
5959
AC_DEFUN([OPAL_CONFIG_PMIX], [
60-
OPAL_VAR_SCOPE_PUSH([external_pmix_happy internal_pmix_happy internal_pmix_args internal_pmix_libs])
60+
OPAL_VAR_SCOPE_PUSH([external_pmix_happy internal_pmix_happy internal_pmix_args internal_pmix_libs internal_pmix_CPPFLAGS])
6161
6262
opal_show_subtitle "Configuring PMIx"
6363
@@ -71,13 +71,16 @@ AC_DEFUN([OPAL_CONFIG_PMIX], [
7171
# make dist always works.
7272
internal_pmix_args="--without-tests-examples --disable-pmix-binaries --disable-pmix-backward-compatibility --disable-visibility"
7373
internal_pmix_libs=
74+
internal_pmix_CPPFLAGS=
7475
7576
AS_IF([test "$opal_libevent_mode" = "internal"],
7677
[internal_pmix_args="$internal_pmix_args --with-libevent=cobuild"
78+
internal_pmix_CPPFLAGS="$internal_pmix_CPPFLAGS $opal_libevent_CPPFLAGS"
7779
internal_pmix_libs="$internal_pmix_libs $opal_libevent_LIBS"])
7880
7981
AS_IF([test "$opal_hwloc_mode" = "internal"],
8082
[internal_pmix_args="$internal_pmix_args --with-hwloc=cobuild"
83+
internal_pmix_CPPFLAGS="$internal_pmix_CPPFLAGS $opal_hwloc_CPPFLAGS"
8184
internal_pmix_libs="$internal_pmix_libs $opal_hwloc_LIBS"])
8285
8386
AS_IF([test ! -z "$internal_pmix_libs"],
@@ -87,12 +90,15 @@ AC_DEFUN([OPAL_CONFIG_PMIX], [
8790
# picks up how to build an internal HWLOC and libevent, plus
8891
# picks up any user-specified compiler flags from the master
8992
# configure run.
90-
export CFLAGS CPPFLAGS LDFLAGS
93+
OPAL_SUBDIR_ENV_CLEAN([opal_pmix_configure])
94+
AS_IF([test -n "$internal_pmix_CPPFLAGS"],
95+
[OPAL_SUBDIR_ENV_APPEND([CPPFLAGS], [$internal_pmix_CPPFLAGS])])
9196
PAC_CONFIG_SUBDIR_ARGS([3rd-party/openpmix], [$internal_pmix_args],
9297
[[--with-libevent=internal], [--with-hwloc=internal],
9398
[--with-libevent=external], [--with-hwloc=external],
94-
[--with-pmix=.*], [--with-platform=.*]],
99+
[--with-pmix=[[^ ]]*], [--with-platform=[[^ ]]*]],
95100
[internal_pmix_happy=1])
101+
OPAL_SUBDIR_ENV_RESTORE([opal_pmix_configure])
96102
OPAL_3RDPARTY_DIST_SUBDIRS="$OPAL_3RDPARTY_DIST_SUBDIRS openpmix"])
97103
98104
# unless internal specifically requested by the user, try to find

config/opal_subdir_env.m4

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
dnl -*- autoconf -*-
2+
dnl
3+
dnl Copyright (c) 2020 Amazon.com, Inc. or its affiliates. All Rights
4+
dnl reserved.
5+
dnl $COPYRIGHT$
6+
dnl
7+
dnl Additional copyrights may follow
8+
dnl
9+
dnl $HEADER$
10+
dnl
11+
12+
dnl OPAL_SUBDIR_ENV_CLEAN([prefix])
13+
dnl
14+
dnl Save all precious variables with the specified prefix and reset
15+
dnl all precious variables to their state at the start of configure.
16+
dnl That is, if a precious variable (say CPPFLAGS) was set on the
17+
dnl configure command line or in the environment at the start of
18+
dnl configure, it will be reset to that stored value. Otherwise, it
19+
dnl will be unset. The current state is recorded so that it can be
20+
dnl restored with OPAL_SUBDIR_ENV_RESTORE. Useful for wrapping calles
21+
dnl to subconfigure scripts.
22+
AC_DEFUN([OPAL_SUBDIR_ENV_CLEAN], [
23+
for temp_var in $ac_precious_vars; do
24+
# save all set variables, with a <prefix>_<name>_set and
25+
# <prefix>_<name>_value format. _set will always be saved,
26+
# _value if _set evaluates to "set".
27+
#
28+
# Because we may modify the environment with
29+
# OPAL_SUBDIR_ENV_APPEND, also store the original values of
30+
# ac_env_<name>_set in <prefix>_ac_env_<name>_set
31+
eval temp_var_set=\${${temp_var}+set}
32+
eval $1_${temp_var}_set=$temp_var_set
33+
eval $1_ac_env_${temp_var}_set=\$ac_env_${temp_var}_set
34+
if test "$temp_var_set" = "set" ; then
35+
eval $1_${temp_var}_value=\$${temp_var}
36+
fi
37+
unset tmp_var_set
38+
39+
# restore the variables that were set at the start of
40+
# configure and unset the ones that were not.
41+
eval temp_var_orig_set=\$ac_env_${temp_var}_set
42+
if test "$temp_var_set" = "set" ; then
43+
eval ${temp_var}=\$ac_env_${temp_var}_value
44+
else
45+
unset $temp_var
46+
fi
47+
done
48+
])
49+
50+
dnl OPAL_SUBDIR_ENV_RESTORE([prefix])
51+
dnl
52+
dnl Match with call to OPAL_SUBDIR_ENV_CLEAN. Restore will return all
53+
dnl precious variables to their state at the time that
54+
dnl OPAL_SUBDIR_ENV_CLEAN was called. If a variable was set at that
55+
dnl time, it will be set to that value. Otherwise, it will be unset.
56+
dnl
57+
dnl The state of the ac_env_<var>_set value is also restored to its
58+
dnl value from when OPAL_SUBDIR_ENV_CLEAN is called. The
59+
dnl ac_env_<var>_set variables may be manipulated by
60+
dnl OPAL_SUBDIR_ENV_APPEND.
61+
AC_DEFUN([OPAL_SUBDIR_ENV_RESTORE], [
62+
for temp_var in $ac_precious_vars; do
63+
# always restore the value of ac_env_<name>_set
64+
eval ac_env_${temp_var}_set=\$$1_ac_env_${temp_var}_set
65+
66+
# conditionally restore any variable values that were set at
67+
# CLEAN time
68+
eval temp_var_set=\$$1_${temp_var}_set
69+
if test "$temp_var_set" = "set" ; then
70+
eval ${temp_var}=\$$1_${temp_var}_value
71+
fi
72+
73+
unset $1_${temp_var}_value
74+
unset $1_${temp_var}_set
75+
unset $1_ac_env_${temp_var}_set
76+
done
77+
])
78+
79+
dnl OPAL_SUBDIR_ENV_APPEND([precious variable], [append value])
80+
dnl
81+
dnl Append the contents of [append value] to precious variable
82+
dnl [precious variable] and set the ac_env_<param>_set variable so
83+
dnl that PAC_CONFIG_SUBDIR_ARGS can pick up the variables for
84+
dnl subconfigure runs. Most useful between a call to
85+
dnl OPAL_SUBDIR_ENV_CLEAN and OPAL_SUBDIR_ENV_RESTORE
86+
AC_DEFUN([OPAL_SUBDIR_ENV_APPEND], [
87+
ac_env_$1_set="set"
88+
AS_IF([test -z "$$1"], [$1=$2], [$1="$$1 $2"])
89+
])

0 commit comments

Comments
 (0)