From 810f3f97fec07b0fdbbc7f138318fc1a5b88f1af Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Mon, 22 May 2023 16:13:42 -0500 Subject: [PATCH] AIX: Search harder for compiler path The current logic for setting CC on AIX assumes the desired compiler is in the user's PATH. But the desired compiler may not be in the user's path, and we do not require it to be on other platforms. So, if the user hasn't specified a CC explicitly, and we don't see a compiler in the PATH, look in a few common known locations for one. This is similar to our approach on Solaris, but the structure of the known paths lets us easily use a shell glob, instead of needing to specify every single compiler version. Change-Id: I2cd16ab8bf9737edd52630d457de73546d89a19a Reviewed-on: https://gerrit.openafs.org/15457 Reviewed-by: Cheyenne Wills Reviewed-by: Ben Huntsman Reviewed-by: Michael Meffie Tested-by: BuildBot --- src/cf/cc.m4 | 27 +++++++++++++++++++++++++++ src/cf/osconf.m4 | 5 ++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/cf/cc.m4 b/src/cf/cc.m4 index 65965d8986..e5edc09f0e 100644 --- a/src/cf/cc.m4 +++ b/src/cf/cc.m4 @@ -77,6 +77,24 @@ AC_DEFUN([OPENAFS_PATH_CC], [ []) ]) +dnl OPENAFS_PATH_PROGS_GLOB(VARIABLE, PROGS-TO-CHECK-FOR, PATH-GLOB) +dnl +dnl Calls AC_PATH_PROGS(VARIABLE, PROGS-TO-CHECK-FOR, [], path), but build the +dnl path from a shell glob. If the glob doesn't match anything, don't run +dnl AC_PATH_PROGS. +AC_DEFUN([OPENAFS_PATH_PROGS_GLOB], + [path= + for item in $3 ; do + AS_IF([test -e "$item"], + [AS_IF([test x"$path" = x], + [path="$item"], + [path="$path:$item"])]) + done + AS_IF([test x"$path" != x], + [AC_PATH_PROGS([$1], [$2], [], [$path])]) + path= +]) + AC_DEFUN([AIX7_PATH_CC], [ # On AIX, we need to use the xlc compiler. Starting with AIX 7.2, a new # version of the compiler (17.1) is available, which is invoked via @@ -89,6 +107,15 @@ AC_DEFUN([AIX7_PATH_CC], [ AS_IF([test x"$CC" = x], [AC_PATH_PROGS([CC], [ibm-clang cc])]) + # If we haven't found anything, try to find ibm-clang in common locations. + AS_IF([test x"$CC" = x], + [OPENAFS_PATH_PROGS_GLOB([CC], [ibm-clang], [/opt/IBM/openxlC/*/bin])]) + + # If we haven't found anything, try to find the old xlc compiler in common + # locations. + AS_IF([test x"$CC" = x], + [OPENAFS_PATH_PROGS_GLOB([CC], [cc], [/opt/IBM/xlC/*/bin])]) + AS_IF([test x"$CC" = x], [AC_MSG_FAILURE([m4_join([ ], [Could not find the ibm-clang or cc compiler.], diff --git a/src/cf/osconf.m4 b/src/cf/osconf.m4 index 95958f988b..82c5d79505 100644 --- a/src/cf/osconf.m4 +++ b/src/cf/osconf.m4 @@ -405,7 +405,10 @@ case $AFS_SYSNAME in [ # Assume this is XL C 16.1 or earlier AC_MSG_RESULT([xlc]) - MT_CC="xlc_r" + + # Replace the last path component of $CC with xlc_r, whether + # $CC is cc, xlc, or /path/to/xlc, etc. + MT_CC="${CC%${CC##*/}}xlc_r" XCFLAGS="-K -D_NONSTD_TYPES -D_MBI=void" XCFLAGS64=-q64 ]