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 <cwills@sinenomine.net>
Reviewed-by: Ben Huntsman <ben@huntsmans.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
Andrew Deason 2023-05-22 16:13:42 -05:00 committed by Michael Meffie
parent dba6ec9548
commit 810f3f97fe
2 changed files with 31 additions and 1 deletions

View File

@ -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], [ AC_DEFUN([AIX7_PATH_CC], [
# On AIX, we need to use the xlc compiler. Starting with AIX 7.2, a new # 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 # 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], AS_IF([test x"$CC" = x],
[AC_PATH_PROGS([CC], [ibm-clang cc])]) [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], AS_IF([test x"$CC" = x],
[AC_MSG_FAILURE([m4_join([ ], [AC_MSG_FAILURE([m4_join([ ],
[Could not find the ibm-clang or cc compiler.], [Could not find the ibm-clang or cc compiler.],

View File

@ -405,7 +405,10 @@ case $AFS_SYSNAME in
[ [
# Assume this is XL C 16.1 or earlier # Assume this is XL C 16.1 or earlier
AC_MSG_RESULT([xlc]) 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" XCFLAGS="-K -D_NONSTD_TYPES -D_MBI=void"
XCFLAGS64=-q64 XCFLAGS64=-q64
] ]