Skip to content

Commit cb17568

Browse files
committed
build: Fix OPAL_CHECK_COMPILER_VERSION_ID escaping
Fix escapling and simplify handling of literals in the OPAL_CHECK_- COMPILER_VERSION_ID macro. The macros were under-escaped,, which was not causing problems but was also wrong. The use of m4_lower() meant that the argument to the helper macros had to be a string literal, so enforce that requirement explicitly and then remove the evals that are unnecessary given the lack of shell expansion. Signed-off-by: Brian Barrett <bbarrett@amazon.com>
1 parent 070640e commit cb17568

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

config/opal_check_compiler_version.m4

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ dnl -*- shell-script -*-
22
dnl
33
dnl Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
44
dnl Copyright (c) 2021 Cisco Systems, Inc. All rights reserved.
5+
dnl Copyright (c) 2021 Amazon.com, Inc. or its affiliates. All Rights
6+
dnl reserved.
57
dnl
68
dnl $COPYRIGHT$
79
dnl
@@ -27,86 +29,92 @@ AC_DEFUN([OPAL_CHECK_COMPILER_VERSION_ID],
2729

2830

2931
AC_DEFUN([OPAL_CHECK_COMPILER], [
30-
lower=m4_tolower($1)
31-
AC_CACHE_CHECK([for compiler $lower], opal_cv_compiler_[$1],
32+
AS_LITERAL_IF([$1], [],
33+
[m4_fatal([OPAL_CHECK_COMPILER argument must be a literal])])
34+
lower=m4_tolower([$1])
35+
AC_CACHE_CHECK([for compiler $lower], [opal_cv_compiler_$1],
3236
[
3337
CPPFLAGS_orig=$CPPFLAGS
34-
CPPFLAGS="-I${OPAL_TOP_SRCDIR}/opal/include/opal $CPPFLAGS"
38+
CPPFLAGS="-I${OPAL_TOP_SRCDIR}/opal/include $CPPFLAGS"
3539
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3640
#include <stdio.h>
3741
#include <stdlib.h>
38-
#include "opal_portable_platform.h"
42+
#include "opal/opal_portable_platform.h"
3943
]],[[
4044
FILE * f;
4145
f=fopen("conftestval", "w");
4246
if (!f) exit(1);
4347
fprintf (f, "%d", PLATFORM_COMPILER_$1);
4448
]])], [
45-
eval opal_cv_compiler_$1=`cat conftestval`;
49+
opal_cv_compiler_$1=`cat conftestval`
4650
], [
47-
eval opal_cv_compiler_$1=0
51+
opal_cv_compiler_$1=0
4852
], [
49-
eval opal_cv_compiler_$1=0
53+
opal_cv_compiler_$1=0
5054
])
5155
CPPFLAGS=$CPPFLAGS_orig
5256
])
53-
AC_DEFINE_UNQUOTED([OPAL_BUILD_PLATFORM_COMPILER_$1], $opal_cv_compiler_[$1],
57+
AC_DEFINE_UNQUOTED([OPAL_BUILD_PLATFORM_COMPILER_$1], [$opal_cv_compiler_$1],
5458
[The compiler $lower which OMPI was built with])
5559
])dnl
5660

5761
AC_DEFUN([OPAL_CHECK_COMPILER_STRING], [
58-
lower=m4_tolower($1)
59-
AC_CACHE_CHECK([for compiler $lower], opal_cv_compiler_[$1],
62+
AS_LITERAL_IF([$1], [],
63+
[m4_fatal([OPAL_CHECK_COMPILER_STRING argument must be a literal])])
64+
lower=m4_tolower([$1])
65+
AC_CACHE_CHECK([for compiler $lower], [opal_cv_compiler_$1],
6066
[
6167
CPPFLAGS_orig=$CPPFLAGS
62-
CPPFLAGS="-I${OPAL_TOP_SRCDIR}/opal/include/opal $CPPFLAGS"
68+
CPPFLAGS="-I${OPAL_TOP_SRCDIR}/opal/include $CPPFLAGS"
6369
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
6470
#include <stdio.h>
6571
#include <stdlib.h>
66-
#include "opal_portable_platform.h"
72+
#include "opal/opal_portable_platform.h"
6773
]],[[
6874
FILE * f;
6975
f=fopen("conftestval", "w");
7076
if (!f) exit(1);
7177
fprintf (f, "%s", PLATFORM_COMPILER_$1);
7278
]])], [
73-
eval opal_cv_compiler_$1=`cat conftestval`;
79+
opal_cv_compiler_$1=`cat conftestval`
7480
], [
75-
eval opal_cv_compiler_$1=UNKNOWN
81+
opal_cv_compiler_$1=UNKNOWN
7682
], [
77-
eval opal_cv_compiler_$1=UNKNOWN
83+
opal_cv_compiler_$1=UNKNOWN
7884
])
7985
CPPFLAGS=$CPPFLAGS_orig
8086
])
81-
AC_DEFINE_UNQUOTED([OPAL_BUILD_PLATFORM_COMPILER_$1], $opal_cv_compiler_[$1],
87+
AC_DEFINE_UNQUOTED([OPAL_BUILD_PLATFORM_COMPILER_$1], [$opal_cv_compiler_$1],
8288
[The compiler $lower which OMPI was built with])
8389
])dnl
8490

8591

8692
AC_DEFUN([OPAL_CHECK_COMPILER_STRINGIFY], [
87-
lower=m4_tolower($1)
88-
AC_CACHE_CHECK([for compiler $lower], opal_cv_compiler_[$1],
93+
AS_LITERAL_IF([$1], [],
94+
[m4_fatal([OPAL_CHECK_COMPILER_STRINGIFY argument must be a literal])])
95+
lower=m4_tolower([$1])
96+
AC_CACHE_CHECK([for compiler $lower], [opal_cv_compiler_$1],
8997
[
9098
CPPFLAGS_orig=$CPPFLAGS
91-
CPPFLAGS="-I${OPAL_TOP_SRCDIR}/opal/include/opal $CPPFLAGS"
99+
CPPFLAGS="-I${OPAL_TOP_SRCDIR}/opal/include $CPPFLAGS"
92100
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
93101
#include <stdio.h>
94102
#include <stdlib.h>
95-
#include "opal_portable_platform.h"
103+
#include "opal/opal_portable_platform.h"
96104
]],[[
97105
FILE * f;
98106
f=fopen("conftestval", "w");
99107
if (!f) exit(1);
100108
fprintf (f, "%s", _STRINGIFY(PLATFORM_COMPILER_$1));
101109
]])], [
102-
eval opal_cv_compiler_$1=`cat conftestval`;
110+
opal_cv_compiler_$1=`cat conftestval`
103111
], [
104-
eval opal_cv_compiler_$1=UNKNOWN
112+
opal_cv_compiler_$1=UNKNOWN
105113
], [
106-
eval opal_cv_compiler_$1=UNKNOWN
114+
opal_cv_compiler_$1=UNKNOWN
107115
])
108116
CPPFLAGS=$CPPFLAGS_orig
109117
])
110-
AC_DEFINE_UNQUOTED([OPAL_BUILD_PLATFORM_COMPILER_$1], $opal_cv_compiler_[$1],
118+
AC_DEFINE_UNQUOTED([OPAL_BUILD_PLATFORM_COMPILER_$1], [$opal_cv_compiler_$1],
111119
[The compiler $lower which OMPI was built with])
112120
])dnl

0 commit comments

Comments
 (0)