Skip to content

Commit 7cc0a83

Browse files
authored
Merge pull request #2641 from jsquyres/pr/v2.x/fix-cflags-uniq
v2.x: fix CFLAGS uniqueness
2 parents 5fd4f85 + 38ff750 commit 7cc0a83

File tree

3 files changed

+104
-7
lines changed

3 files changed

+104
-7
lines changed

config/ompi_fortran_check_real16_c_equiv.m4

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
1010
dnl University of Stuttgart. All rights reserved.
1111
dnl Copyright (c) 2004-2005 The Regents of the University of California.
1212
dnl All rights reserved.
13-
dnl Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved.
13+
dnl Copyright (c) 2008-2016 Cisco Systems, Inc. All rights reserved.
1414
dnl Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
1515
dnl Copyright (c) 2015 Research Organization for Information Science
1616
dnl and Technology (RIST). All rights reserved.
@@ -49,7 +49,7 @@ AC_DEFUN([OMPI_FORTRAN_CHECK_REAL16_C_EQUIV],[
4949
[AC_MSG_CHECKING([if intel compiler _Quad == REAL*16])
5050
CFLAGS_save="$CFLAGS"
5151
CFLAGS="$CFLAGS -Qoption,cpp,--extended_float_types"
52-
OPAL_UNIQ([CFLAGS])
52+
OPAL_FLAGS_UNIQ([CFLAGS])
5353
OMPI_FORTRAN_CHECK_REAL16_EQUIV_TYPE([_Quad], [q])
5454
AS_IF([test "$happy" = "yes"],
5555
[OMPI_FORTRAN_REAL16_C_TYPE="_Quad"
@@ -59,7 +59,7 @@ AC_DEFUN([OMPI_FORTRAN_CHECK_REAL16_C_EQUIV],[
5959
])
6060
AS_IF([test "$opal_cv_c_compiler_vendor" = "gnu" && test "$ac_cv_type___float128" = "yes"],
6161
[AC_MSG_CHECKING([if gnu compiler __float128 == REAL*16])
62-
OPAL_UNIQ([CFLAGS])
62+
OPAL_FLAGS_UNIQ([CFLAGS])
6363
OMPI_FORTRAN_CHECK_REAL16_EQUIV_TYPE([__float128], [q])
6464
AS_IF([test "$happy" = "yes"],
6565
[OMPI_FORTRAN_REAL16_C_TYPE="__float128"

opal/mca/pmix/pmix112/pmix/config/pmix_functions.m4

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,103 @@ dnl #######################################################################
317317
dnl #######################################################################
318318
dnl #######################################################################
319319

320+
# Remove all duplicate -I, -L, and -l flags from the variable named $1
321+
AC_DEFUN([PMIX_FLAGS_UNIQ],[
322+
# 1 is the variable name to be uniq-ized
323+
pmix_name=$1
324+
325+
# Go through each item in the variable and only keep the unique ones
326+
327+
pmix_count=0
328+
for val in ${$1}; do
329+
pmix_done=0
330+
pmix_i=1
331+
pmix_found=0
332+
333+
# Loop over every token we've seen so far
334+
335+
pmix_done="`expr $pmix_i \> $pmix_count`"
336+
while test "$pmix_found" = "0" && test "$pmix_done" = "0"; do
337+
338+
# Have we seen this token already? Prefix the comparison
339+
# with "x" so that "-Lfoo" values won't be cause an error.
340+
341+
pmix_eval="expr x$val = x\$pmix_array_$pmix_i"
342+
pmix_found=`eval $pmix_eval`
343+
344+
# Check the ending condition
345+
346+
pmix_done="`expr $pmix_i \>= $pmix_count`"
347+
348+
# Increment the counter
349+
350+
pmix_i="`expr $pmix_i + 1`"
351+
done
352+
353+
# Check for special cases where we do want to allow repeated
354+
# arguments (per
355+
# http://www.open-mpi.org/community/lists/devel/2012/08/11362.php
356+
# and
357+
# https://github.com/open-mpi/ompi/issues/324).
358+
359+
case $val in
360+
-Xclang)
361+
pmix_found=0
362+
pmix_i=`expr $pmix_count + 1`
363+
;;
364+
-framework)
365+
pmix_found=0
366+
pmix_i=`expr $pmix_count + 1`
367+
;;
368+
--param)
369+
pmix_found=0
370+
pmix_i=`expr $pmix_count + 1`
371+
;;
372+
esac
373+
374+
# If we didn't find the token, add it to the "array"
375+
376+
if test "$pmix_found" = "0"; then
377+
pmix_eval="pmix_array_$pmix_i=$val"
378+
eval $pmix_eval
379+
pmix_count="`expr $pmix_count + 1`"
380+
else
381+
pmix_i="`expr $pmix_i - 1`"
382+
fi
383+
done
384+
385+
# Take all the items in the "array" and assemble them back into a
386+
# single variable
387+
388+
pmix_i=1
389+
pmix_done="`expr $pmix_i \> $pmix_count`"
390+
pmix_newval=
391+
while test "$pmix_done" = "0"; do
392+
pmix_eval="pmix_newval=\"$pmix_newval \$pmix_array_$pmix_i\""
393+
eval $pmix_eval
394+
395+
pmix_eval="unset pmix_array_$pmix_i"
396+
eval $pmix_eval
397+
398+
pmix_done="`expr $pmix_i \>= $pmix_count`"
399+
pmix_i="`expr $pmix_i + 1`"
400+
done
401+
402+
# Done; do the assignment
403+
404+
pmix_newval="`echo $pmix_newval`"
405+
pmix_eval="$pmix_name=\"$pmix_newval\""
406+
eval $pmix_eval
407+
408+
# Clean up
409+
410+
unset pmix_name pmix_i pmix_done pmix_newval pmix_eval pmix_count
411+
])dnl
412+
413+
dnl #######################################################################
414+
dnl #######################################################################
415+
dnl #######################################################################
416+
320417
# PMIX_APPEND_UNIQ(variable, new_argument)
321418
# ----------------------------------------
322419
# Append new_argument to variable if not already in variable. This assumes a

opal/mca/pmix/pmix112/pmix/config/pmix_setup_cc.m4

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ AC_DEFUN([PMIX_SETUP_CC],[
7272
if test "$WANT_DEBUG" = "1" && test "$enable_debug_symbols" != "no" ; then
7373
CFLAGS="$CFLAGS -g"
7474

75-
PMIX_UNIQ(CFLAGS)
75+
PMIX_FLAGS_UNIQ(CFLAGS)
7676
AC_MSG_WARN([-g has been added to CFLAGS (--enable-debug)])
7777
fi
7878

@@ -138,7 +138,7 @@ AC_DEFUN([PMIX_SETUP_CC],[
138138
fi
139139

140140
CFLAGS="$CFLAGS_orig $add"
141-
PMIX_UNIQ(CFLAGS)
141+
PMIX_FLAGS_UNIQ(CFLAGS)
142142
AC_MSG_WARN([$add has been added to CFLAGS (--enable-picky)])
143143
unset add
144144
fi
@@ -188,7 +188,7 @@ AC_DEFUN([PMIX_SETUP_CC],[
188188
fi
189189
CFLAGS="$CFLAGS_orig$add"
190190

191-
PMIX_UNIQ(CFLAGS)
191+
PMIX_FLAGS_UNIQ(CFLAGS)
192192
AC_MSG_WARN([$add has been added to CFLAGS])
193193
unset add
194194
fi
@@ -217,7 +217,7 @@ AC_DEFUN([PMIX_SETUP_CC],[
217217
fi
218218

219219
CFLAGS="${CFLAGS_orig}${add}"
220-
PMIX_UNIQ([CFLAGS])
220+
PMIX_FLAGS_UNIQ([CFLAGS])
221221
if test "$add" != "" ; then
222222
AC_MSG_WARN([$add has been added to CFLAGS])
223223
fi

0 commit comments

Comments
 (0)