diff --git a/configure.ac b/configure.ac index 0c0dc4bd9d..21113cedc3 100644 --- a/configure.ac +++ b/configure.ac @@ -592,7 +592,7 @@ AC_CHECK_HEADERS([alloca.h aio.h arpa/inet.h dirent.h \ stdarg.h sys/stat.h sys/statvfs.h sys/time.h sys/tree.h \ sys/types.h sys/uio.h sys/utsname.h sys/wait.h syslog.h \ time.h termios.h ulimit.h unistd.h util.h utmp.h malloc.h \ - ifaddrs.h sys/sysctl.h crt_externs.h]) + ifaddrs.h sys/sysctl.h crt_externs.h regex.h]) # Needed to work around Darwin requiring sys/socket.h for # net/if.h @@ -730,7 +730,7 @@ OMPI_CHECK_FUNC_LIB([dirname], [gen]) # Darwin doesn't need -lm, as it's a symlink to libSystem.dylib OMPI_CHECK_FUNC_LIB([ceil], [m]) -AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf openpty isatty htonl ntohl htons ntohs getpwuid fork waitpid execve pipe ptsname setsid mmap mallopt tcgetpgrp posix_memalign strsignal sysconf syslog _NSGetEnviron]) +AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf openpty isatty htonl ntohl htons ntohs getpwuid fork waitpid execve pipe ptsname setsid mmap mallopt tcgetpgrp posix_memalign strsignal sysconf syslog regcmp regexec regfree _NSGetEnviron]) # # Make sure we can copy va_lists (need check declared, not linkable) diff --git a/opal/tools/wrappers/opal_wrapper.c b/opal/tools/wrappers/opal_wrapper.c index e4dc7960dd..7bb181e004 100644 --- a/opal/tools/wrappers/opal_wrapper.c +++ b/opal/tools/wrappers/opal_wrapper.c @@ -32,6 +32,9 @@ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ +#ifdef HAVE_REGEX_H +#include +#endif #ifdef HAVE_SYS_WAIT_H #include #endif /* HAVE_SYS_WAIT_H */ @@ -176,26 +179,36 @@ static int find_options_index(const char *arg) { int i, j; +#ifdef HAVE_REGEXEC + int args_count; + regex_t res; +#endif for (i = 0 ; i <= parse_options_idx ; ++i) { if (NULL == options_data[i].compiler_args) { continue; } + +#ifdef HAVE_REGEXEC + args_count = opal_argv_count(options_data[i].compiler_args); + for (j = 0 ; j < args_count ; ++j) { + if (0 != regcomp(&res, options_data[i].compiler_args[j], REG_NOSUB)) { + return -1; + } + + if (0 == regexec(&res, arg, (size_t) 0, NULL, 0)) { + return i; + } + + regfree(&res); + } +#else for (j = 0 ; j < opal_argv_count(options_data[i].compiler_args) ; ++j) { - /* BWB: If in the future, we want to allow architecture - flags to be wildcard specified (like, say, - -xarch=amd64*), this strcmp would have to be changed to - something that understands wildcards. This is the only - change that will have to be made, provided you didn't - want to add some extra logic to have a general - -xarch=amd64* rule and another one that was an exact - match (like, say, -xarch=amd64a). Then this entire - loop will have to be modified, but no other parts of - this file would have to change. */ if (0 == strcmp(arg, options_data[i].compiler_args[j])) { return i; } } +#endif } return -1;