Skip to content

Commit

Permalink
Fixed handling of ROSE configuration when the names of the specified …
Browse files Browse the repository at this point in the history
…C and C++ compiler do not conform to any convention. Random names are now allowed.
  • Loading branch information
Daniel J. Quinlan committed Feb 2, 2016
1 parent 0efa703 commit caf8847
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 92 deletions.
18 changes: 4 additions & 14 deletions config/compiler-defs.m4
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,7 @@ dnl predefined by a specific compiler
# DQ (4/1/2005): Modified to get compiler name from path
compilerName=`basename $BACKEND_CXX_COMPILER`
echo "Using back-end C++ compiler = \"$BACKEND_CXX_COMPILER\" compiler name = \"$compilerName\" for processing of unparsed source files from ROSE preprocessors."
# Calling available macro from Autoconf.
# AX_COMPILER_VENDOR
# C_compilerVendorName= $ax_cv_c_compiler_vendor
# Cxx_compilerVendorName= $ax_cv_cxx_compiler_vendor
# echo "Using back-end (from compiler-defs) C compiler = \"$BACKEND_CXX_COMPILER\" compiler name = $ax_cv_c_compiler_vendor for processing of unparsed source files from ROSE preprocessors."
echo "Using back-end (from compiler-defs) C++ compiler = \"$BACKEND_CXX_COMPILER\" compiler vendor name = $ax_cv_cxx_compiler_vendor"
# echo "Exiting (from compiler-defs) after computing the compiler vendor name for the C and C++ compilers."
# exit 1
# echo "Using back-end C++ compiler = \"$BACKEND_CXX_COMPILER\" compiler name = \"$compilerName\" for processing of unparsed source files from ROSE preprocessors."
compilerVendorName=$ax_cv_cxx_compiler_vendor
Expand All @@ -40,9 +30,9 @@ compilerVendorName=$ax_cv_cxx_compiler_vendor
# clang|clang++|clang-*|clang++-*)
clang)
macroString="{\"--preinclude\", \"rose_edg_required_macros_and_functions.h\"}"
# compilerVendorName=llvm
echo "Support for clang as a backend for compiling ROSE generated code \"$BACKEND_CXX_COMPILER\" ";
echo "Support for clang as a backend for compiling ROSE generated code \"$macroString\" ";
# compilerVendorName=llvm
# echo "Support for clang as a backend for compiling ROSE generated code \"$BACKEND_CXX_COMPILER\" ";
# echo "Support for clang as a backend for compiling ROSE generated code \"$macroString\" ";
;;
# Support for GNU gcc or g++ as a backend for compiling ROSE generated code
Expand Down
77 changes: 48 additions & 29 deletions config/create_system_headers
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ process_headers()
# make sure the source directory structure exists
if [ ! -d "$2" -o ! -r "$2" -o ! -x "$2" ]
then
echo "*****************************************"
echo "Parameter 1 = $1"
echo "Parameter 2 = $2"
echo "Parameter 3 = $3"
echo "*****************************************"
echo "ERROR: Directory $2 is invalid"
echo "************* FAILING ***** FAILING *****************"
exit 2
Expand Down Expand Up @@ -112,18 +117,15 @@ process_headers()
# check for correct number of arguments and
# whether a source directory has been specified
# if [ $# -eq 3 ]; then
if [ $# -eq 4 ]; then
if [ $# -eq 5 ]; then
:
else
# echo "ERROR: Usage is $0 <compiler> <target_dir> <source_dir>"
echo "ERROR: Usage is $0 <compiler> <target_dir> <source_dir> <language>"
echo "ERROR: Usage is $0 <compiler> <target_dir> <source_dir> <language> <compilerVendorName>"
exit 1
fi

echo "In main(): parameter 1 = $1 parameter 2 = $2 parameter 3 = $3 parameter 4 = $4"



# echo "In main(): parameter 1 = $1 parameter 2 = $2 parameter 3 = $3 parameter 4 = $4 parameter 5 = $5"

# for now assume that if a compiler is specified that it is installed
# see if the full path name has been specified for compiler and if
Expand All @@ -132,30 +134,34 @@ compilerName="`basename $1`"
compilerBinDir="`dirname $1`"
roseHome="$3"
language="$4"
compilerVendorName="$5"

echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
echo "compilerName = $compilerName"
echo "compilerBinDir = $compilerBinDir"
echo "roseHome = $roseHome"
echo "language = $language"
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
# echo "In script file: create system headers: Using back-end compiler = \"$1\" compiler vendor name = $compilerVendorName for processing of unparsed source files from ROSE preprocessors."
# echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
# echo "compilerName = $compilerName"
# echo "compilerBinDir = $compilerBinDir"
# echo "roseHome = $roseHome"
# echo "language = $language"
# echo "compilerVendorName = $compilerVendorName"
# echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"

# DQ (2/2/2016): We don't compiler ROSE using ROSE as the backend (this was from when we had
# to support ROSE compiling ROSE, but this should not require specialized support now).
# DQ (8/24/2009): Allow either "roseTranslator" or "roseAnalysis"
# if [ "$compilerName" == "roseTranslator" ]
# if [ "$compilerName" == "roseTranslator" || "$compilerName" == "roseAnalysis" ]
if [ "$compilerName" = "roseTranslator" ]
then
compilerName="g++"
echo "Changed compilerName from roseTranslator to $compilerName"

echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
echo "After change: compilerName = $compilerName"
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
elif [ "$compilerName" = "roseAnalysis" ]
then
compilerName="g++"
echo "Changed compilerName from roseAnalysis to $compilerName"
fi
# if [ "$compilerName" = "roseTranslator" ]
# then
# compilerName="g++"
# echo "Changed compilerName from roseTranslator to $compilerName"
# echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
# echo "After change: compilerName = $compilerName"
# echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
# elif [ "$compilerName" = "roseAnalysis" ]
# then
# compilerName="g++"
# echo "Changed compilerName from roseAnalysis to $compilerName"
# fi

# we try to ensure that paths can be given, to enable using different versions of the same compiler
if [ "$compilerBinDir" != "." ]
Expand Down Expand Up @@ -204,8 +210,10 @@ then
exit 1
fi

# Comment this out for debugging
# if true; then
# DQ (2/1/2016): Simplify the logic to avoid use of the backend compiler name.
if [ "x$language" = "xc" -o "x$language" = "xcxx" ]; then
if [ "x$language" = "xc" -o "x$language" = "xc++" ]; then

echo "In create system headers: this is processing C or C++: language = $language"

Expand All @@ -232,15 +240,21 @@ else
echo "ERROR: Usage is create_system_headers compiler target_dir src_dir language"
exit 1
fi
# fi

# echo "local script variable compilerHeadersDirCmd = $compilerHeadersDirCmd"
# echo "Building separate header directories"

# DQ (2/2/2016): Debugging new compiler vendor detection.
# echo "shell script to be run next: $roseHome/config/get_compiler_header_dirs"

# DQ (2/2/2016): When the shell script returns an error we don't catch it.
iDir=0
sh "$roseHome/config/get_compiler_header_dirs" "$1" | while read dirName
# sh "$roseHome/config/get_compiler_header_dirs" "$1" | while read dirName
sh "$roseHome/config/get_compiler_header_dirs" "$1" "$language" "$compilerVendorName" | while read dirName
do
iDir=`expr "$iDir" + 1 `
echo "processing header file directory $dirName to be mapped to $mainTargetDir/hdrs${iDir}"
iDir=`expr "$iDir" + 1 `
echo "processing header file compiler name = $1 directory = $dirName to be mapped to $mainTargetDir/hdrs${iDir} roseHome = $roseHome compilerVendorName = $compilerVendorName"

# DQ (1/14/2007): Added "&" so that this would happen in parallel (to improve performance of configure on multi-core machines).
# JJW (7/18/2008): Commented it out because the process does not take too
Expand All @@ -249,6 +263,11 @@ sh "$roseHome/config/get_compiler_header_dirs" "$1" | while read dirName
process_headers "$1" "$dirName" "$mainTargetDir/hdrs${iDir}" "$roseHome" # &
done

if [ "${PIPESTATUS[0]}" -ne 0 ]; then
echo "get_compiler_header_dirs failed"
exit 1
fi

# DQ (1/14/2007): It is not required to wait until the calls to process_headers complete
# wait

Expand Down
72 changes: 58 additions & 14 deletions config/generate-backend-compiler-specific-headers.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ dnl it depends upon the CHOOSE BACKEND COMPILER macro to have already been calle
[
# BP : 11/20/2001, create a directory to store header files which are compiler specific
compilerName="`basename $BACKEND_CXX_COMPILER`"
# echo "In GENERATE BACKEND CXX COMPILER SPECIFIC HEADERS: Using back-end C++ compiler = \"$BACKEND_CXX_COMPILER\" compiler vendor name = $ax_cv_cxx_compiler_vendor for processing of unparsed source files from ROSE preprocessors."
chmod u+x "${srcdir}/config/create_system_headers"
if test "$ROSE_CXX_HEADERS_DIR" = ""; then
dnl AC_MSG_NOTICE([ROSE_CXX_HEADERS_DIR not set ...])
Expand All @@ -22,18 +25,32 @@ dnl it depends upon the CHOOSE BACKEND COMPILER macro to have already been calle
echo "absolutePath_srcdir = ${absolutePath_srcdir}"
# This is a way to make this a global shaell variable, but it is better to pass it as a parameter to the function.
# export danLanguage="cxx"
danLanguage="cxx"
echo "In generate backend compiler specific headers: danLanguage = $danLanguage"
# export language="cxx"
# This language name is used as a parameter to the backend compiler, so it must be "c" or "c++"
language="c++"
# echo "In generate backend compiler specific headers: language = $language"
# Use the full path name to generate the header from the correctly specified version of the backend compiler
mkdir -p "./include-staging/${compilerName}_HEADERS"
# DQ (2/2/2016): Adding additional parameters to this function call.
# "${srcdir}/config/create_system_headers" "${BACKEND_CXX_COMPILER}" "./include-staging/${compilerName}_HEADERS" "${absolutePath_srcdir}"
"${srcdir}/config/create_system_headers" "${BACKEND_CXX_COMPILER}" "./include-staging/${compilerName}_HEADERS" "${absolutePath_srcdir}" "${danLanguage}"
"${srcdir}/config/create_system_headers" "${BACKEND_CXX_COMPILER}" "./include-staging/${compilerName}_HEADERS" "${absolutePath_srcdir}" "${language}" "${ax_cv_cxx_compiler_vendor}"
error_code=$?
echo "error_code = $error_code"
if test $error_code != 0; then
echo "Error in generate backend CXX compiler specific headers: call to ${srcdir}/config/create_system_headers: nonzero exit code returned to caller error_code = $error_code"
exit 1
fi
echo "BACKEND_CXX_COMPILER_MAJOR_VERSION_NUMBER = $BACKEND_CXX_COMPILER_MAJOR_VERSION_NUMBER"
echo "BACKEND_CXX_COMPILER_MINOR_VERSION_NUMBER = $BACKEND_CXX_COMPILER_MINOR_VERSION_NUMBER"
# DQ (2/2/2016): Debugging new support for detected the compiler vendor.
# echo "Exiting after call to create_system_headers in GENERATE BACKEND CXX COMPILER SPECIFIC HEADERS"
# exit 1
# DQ (8/14/2010): GNU 4.5 includes some code that will not compile and appears to not be valid C++ code.
# We fixup a specific GNU 4.5 issues use of "return { __mask };"
if test x$BACKEND_CXX_COMPILER_MAJOR_VERSION_NUMBER == x4; then
Expand Down Expand Up @@ -84,8 +101,6 @@ dnl it depends upon the CHOOSE BACKEND COMPILER macro to have already been calle
fi
fi
error_code=$?
echo "error_code = $error_code"
if test $error_code != 0; then
Expand Down Expand Up @@ -137,9 +152,22 @@ compilerNameCxx="`basename ${BACKEND_CXX_COMPILER}`"
# fi
# includeString="{\"${compilerNameCxx}_HEADERS\"`${srcdir}/$ROSE_HOME/config/dirincludes "./include-staging/" "${compilerNameCxx}_HEADERS"`, `${srcdir}/config/get_compiler_header_dirs ${BACKEND_CXX_COMPILER} | while read dir; do echo $EO \\\"$dir\\\",$EC\ ; done` \"/usr/include\"}"
if ! compilerHeaderDirs="$(${srcdir}/config/get_compiler_header_dirs ${BACKEND_CXX_COMPILER} | while read dir; do echo $EO \"$dir\",$EC\ ; done; exit ${PIPESTATUS[0]})"; then
# Set new variables to pass in the function call below.
compilerVendorName=$ax_cv_cxx_compiler_vendor
language="c++"
# DQ (2/2/2016): Adding additional parameters to this function call.
# if ! compilerHeaderDirs="$(${srcdir}/config/get_compiler_header_dirs ${BACKEND_CXX_COMPILER} | while read dir; do echo $EO \"$dir\",$EC\ ; done; exit ${PIPESTATUS[0]})"; then
if ! compilerHeaderDirs="$(${srcdir}/config/get_compiler_header_dirs ${BACKEND_CXX_COMPILER} ${language} ${compilerVendorName} | while read dir; do echo $EO \"$dir\",$EC\ ; done; exit ${PIPESTATUS[0]})"; then
AC_MSG_FAILURE([$compilerHeaderDirs])
fi
# DQ (2/2/2016): Added error checking (though this already appears to be present).
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
echo "In SETUP BACKEND CXX COMPILER SPECIFIC REFERENCES: get_compiler_header_dirs failed"
exit 1
fi
includeString="{\"${compilerNameCxx}_HEADERS\"`${srcdir}/$ROSE_HOME/config/dirincludes "./include-staging/" "${compilerNameCxx}_HEADERS"`, $compilerHeaderDirs"
includeString="$includeString \"/usr/include\"}"
Expand All @@ -151,7 +179,8 @@ AC_DEFUN([GENERATE_BACKEND_C_COMPILER_SPECIFIC_HEADERS],
[
compilerName="`basename $BACKEND_C_COMPILER`"
echo "C compilerName = ${compilerName}"
# echo "C compilerName = ${compilerName}"
# echo "In GENERATE BACKEND C COMPILER SPECIFIC HEADERS: Using back-end C++ compiler = \"$BACKEND_CXX_COMPILER\" compiler vendor name = $ax_cv_cxx_compiler_vendor for processing of unparsed source files from ROSE preprocessors."
chmod u+x "${srcdir}/config/create_system_headers"
Expand All @@ -171,22 +200,26 @@ AC_DEFUN([GENERATE_BACKEND_C_COMPILER_SPECIFIC_HEADERS],
echo "absolutePath_srcdir = ${absolutePath_srcdir}"
# This is a way to make this a global shaell variable, but it is better to pass it as a parameter to the function.
# export danLanguage="c"
danLanguage="c"
echo "In generate backend compiler specific headers: danLanguage = $danLanguage"
# export language="c"
language="c"
# echo "In generate backend compiler specific headers: language = $language"
# Use the full path name to generate the header from the correctly specified version of the backend compiler
mkdir -p "./include-staging/${compilerName}_HEADERS"
# "${srcdir}/config/create_system_headers" "${BACKEND_C_COMPILER}" "./include-staging/${compilerName}_HEADERS" "${absolutePath_srcdir}"
"${srcdir}/config/create_system_headers" "${BACKEND_C_COMPILER}" "./include-staging/${compilerName}_HEADERS" "${absolutePath_srcdir}" "${danLanguage}"
"${srcdir}/config/create_system_headers" "${BACKEND_C_COMPILER}" "./include-staging/${compilerName}_HEADERS" "${absolutePath_srcdir}" "${language}" "${ax_cv_cxx_compiler_vendor}"
error_code=$?
echo "error_code = $error_code"
if test $error_code != 0; then
echo "Error in ${srcdir}/config/create_system_headers: nonzero exit code returned to caller error_code = $error_code"
echo "Error in generate backend C compiler specific headers: call to ${srcdir}/config/create_system_headers: nonzero exit code returned to caller error_code = $error_code"
exit 1
fi
# DQ (2/2/2016): Debugging new support for detected the compiler vendor.
# echo "Exiting after call to create_system_headers in GENERATE BACKEND C COMPILER SPECIFIC HEADERS"
# exit 1
# DQ (9/15/2010): Copy the upc.h header file from the config directory to our include-staging/${compilerName}_HEADERS directory.
# It might be that these should be put into a UPC specific subdirectory (so that the C compiler can't accedentally find them), but this should be discussed.
echo "Copying UPC header files into ./include-staging/${compilerName}_HEADERS directory ..."
Expand Down Expand Up @@ -265,9 +298,20 @@ compilerNameC="`basename $BACKEND_C_COMPILER`"
# fi
# includeString="{\"${compilerNameC}_HEADERS\"`${srcdir}/$ROSE_HOME/config/dirincludes "./include-staging/" "${compilerNameC}_HEADERS"`, `${srcdir}/config/get_compiler_header_dirs ${BACKEND_C_COMPILER} | while read dir; do echo $EO \\\"$dir\\\",$EC\ ; done` \"/usr/include\"}"
if ! compilerHeaderDirs="$(${srcdir}/config/get_compiler_header_dirs ${BACKEND_C_COMPILER} | while read dir; do echo $EO \"$dir\",$EC\ ; done; exit ${PIPESTATUS[0]})"; then
compilerVendorName=$ax_cv_cxx_compiler_vendor
language="c"
# if ! compilerHeaderDirs="$(${srcdir}/config/get_compiler_header_dirs ${BACKEND_C_COMPILER} | while read dir; do echo $EO \"$dir\",$EC\ ; done; exit ${PIPESTATUS[0]})"; then
if ! compilerHeaderDirs="$(${srcdir}/config/get_compiler_header_dirs ${BACKEND_C_COMPILER} ${language} ${compilerVendorName} | while read dir; do echo $EO \"$dir\",$EC\ ; done; exit ${PIPESTATUS[0]})"; then
AC_MSG_FAILURE([$compilerHeaderDirs])
fi
# DQ (2/2/2016): Added error checking (though this already appears to be present).
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
echo "In SETUP BACKEND C COMPILER SPECIFIC REFERENCES: get_compiler_header_dirs failed"
exit 1
fi
includeString="{\"${compilerNameC}_HEADERS\"`${srcdir}/$ROSE_HOME/config/dirincludes "./include-staging/" "${compilerNameC}_HEADERS"`, $compilerHeaderDirs"
includeString="$includeString \"/usr/include\"}"
Expand Down
38 changes: 25 additions & 13 deletions config/get_compiler_header_dirs
Original file line number Diff line number Diff line change
@@ -1,35 +1,47 @@
#!/bin/sh

if test $# -ne 1; then
echo "Usage: $0 <compilerName>" >&2
# DQ (2/2/2016): This script currently takes the name of the backend
# compiler, but what we want to do instead is hand it the vendor name.

if test $# -ne 3; then
echo "Usage: $0 <compilerName> <language> <compilerVendorName>" >&2
exit 1
fi

compilerName="`basename $1`"
language=$2
compilerVendorName=$3

# echo "In get_compiler_header_dirs: compilerName = $compilerName" >&2
# echo "In get_compiler_header_dirs: compilerVendorName = $compilerVendorName" >&2
# echo "In get_compiler_header_dirs: language = $language" >&2

case "$compilerName" in
# case "$compilerName" in
case "$compilerVendorName" in
# DQ (3/21/2014): Added support for the MPI versions of the Intel compiler (as named on LC machines).
# Support for compiling ROSE with GNU g++ compiler
g++*|gcc*|icpc|icc|mpiicpc|mpiicc|mpicc|mpic++|mpiCC|mpicxx|cc|c++|xt-xcc|xt-xc++|clang|clang++)
if [ "$compilerName" = "gcc" -o "$compilerName" = "icc" -o "$compilerName" = "mpicc" -o "$compilerName" = "mpiicc" -o "$compilerName" = "xt-xcc" -o "$compilerName" = "cc" -o "$compilerName" = "clang" ]
then
language="c"
else
language="c++"
fi
# g++*|gcc*|icpc|icc|mpiicpc|mpiicc|mpicc|mpic++|mpiCC|mpicxx|cc|c++|xt-xcc|xt-xc++|clang|clang++)
gnu|intel|clang)

$1 -v -E -x $language /dev/null 2>&1 | sed -n '/^#include </,/^End/p' | sed '/^#include </d; /^End/d; /\/usr\/include$/d; /\/Library\/Frameworks$/d; /[(]framework directory[)]$/d'
;;

# Support for compiling ROSE with ROSE (must use translator named: "roseTranslator"
roseTranslator*|testTranslator*|roseCodeGeneration*|testCodeGeneration*|roseAnalysis*|testAnalysis*|roseAstFileIO*|testAstFileIO*)
# roseTranslator*|testTranslator*|roseCodeGeneration*|testCodeGeneration*|roseAnalysis*|testAnalysis*|roseAstFileIO*|testAstFileIO*)
rose)
tmpFile="/tmp/tmp`uname -n`$$.C"
echo "int main(int argc, char **argv){return 0;}" > "$tmpFile"
#$1 -v -E $tmpFile 2>&1 # | sed -n '/^#include </,/^End/p' | sed '/^#include </d; /^End/d; /\/usr\/include$/d'"
$1 -v -E $tmpFile 2>&1 | sed -n '/^#include </,/^End/p' | sed '/^#include </d; /^End/d; /\/usr\/include$/d; /\/Library\/Frameworks$/d; /[(]framework directory[)]$/d'
;;
*) echo "ERROR: Not able to recognize compiler $1"

# DQ (2/2/2016): Added case for unknown compiler vendor (m4 macro will return this value).
unknown) echo "ERROR: Not able to recognize compiler (vendor marked as unknown) $1"
exit 1
;;

*) echo "ERROR: Not able to recognize compiler (error) $1"
exit 1
;;
esac
esac

Loading

0 comments on commit caf8847

Please sign in to comment.