From 08643c38342a14f7ed3f1bf4574f62ee8fc62f18 Mon Sep 17 00:00:00 2001 From: Izaak Beekman Date: Fri, 24 Jan 2025 17:02:24 -0500 Subject: [PATCH] Update fparse-llvm to match cparse-llvm & use sif Ensure that the selective isntrumentation file can get passed to the flang front end plugin and that the arguments to the wrapper script match those in cparse-llvm (where applicable) --- CMakeLists.txt | 4 ++-- src/fparse-llvm.in | 52 ++++++++++++++++++---------------------------- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f488aeb..4a3b61c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -631,11 +631,11 @@ set(FORTRAN_TESTS_SOURCES_LIST # Add a smoke test of the fparse-llvm script add_test(NAME fparse_llvm_smoke_test - COMMAND ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/fparse-llvm -h) + COMMAND ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/fparse-llvm --help) set_tests_properties(fparse_llvm_smoke_test PROPERTIES LABELS smoke - PASS_REGULAR_EXPRESSION "Usage" + PASS_REGULAR_EXPRESSION "USAGE" ) foreach(test_source IN LISTS FORTRAN_TESTS_SOURCES_LIST) diff --git a/src/fparse-llvm.in b/src/fparse-llvm.in index 13239de..7f10b21 100755 --- a/src/fparse-llvm.in +++ b/src/fparse-llvm.in @@ -25,7 +25,8 @@ readonly _SALTFM_PLUGIN_SO=libsalt-flang-plugin.so readonly _VERSION=@SALT_VERSION_MAJOR@.@SALT_VERSION_MINOR@ # get the absolute path of this script -readonly _SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +readonly _SCRIPT_DIR SALT_PLUGIN_SO="${_SCRIPT_DIR}/../@CMAKE_INSTALL_LIBDIR@/${_SALTFM_PLUGIN_SO}" FORTRAN_CONFIG_FILE="${_SCRIPT_DIR}/../@CMAKE_INSTALL_DATADIR@/@CMAKE_PROJECT_NAME@/config_files/config.yaml" @@ -39,33 +40,20 @@ OPTIONS: Generic Options: - --help - Display available options (--help-hidden for more) - --help-list - Display list of available options (--help-list-hidden for more) + --help - Display available options --version - Display the version of this program TAU instrumentor options: -To pass options directly to the compiler, use - tooling [options] -- [compiler options] --config_file= - Specify path to SALT configuration YAML file - --extra-arg= - Additional argument to append to the compiler command line - --extra-arg-before= - Additional argument to prepend to the compiler command line - -p - Build path - --tau_instrument_inline - Instrument inlined functions (default: false) --tau_output= - Specify name of output instrumented file --tau_select_file= - Provide a selective instrumentation specification file - --tau_use_cxx_api - Use TAU's C++ instrumentation API + --show - Print the command line that would be executed by the wrapper script EOF # Add a help/usage message function function usage { - echo "Usage: $0 [-h] [-o output_file] [-show] input_file [args]" - echo " -h: print this help message and exit" - echo " --tau_output=output_file: specify the output file name" - echo " -show: print the command line without running it" - echo " input_file: the Fortran source file to parse and instrument" - echo " args: additional arguments to pass to the flang compiler (include flags etc.)" - + echo "$_USAGE" } if [[ $# -eq 0 ]]; then @@ -166,38 +154,35 @@ done #echo "Passed command line arguments: $*" args=() -original_args=("$@") -expecting_output_file=false expecting_arg_to_forward=false show=false for arg in "$@"; do #echo "working on arg: $arg" - if [[ $arg == -h ]]; then + if [[ $arg == --help ]]; then usage exit 0 - elif $expecting_output_file; then - output_file="$arg" - expecting_output_file=false - shift || true - #echo "args remaining: $*" + elif [[ $arg == --version ]]; then + echo "SALT FM Version: ${_VERSION}" + flang-new -version + exit 0 elif $expecting_arg_to_forward; then args+=("$arg") expecting_arg_to_forward=false shift #echo "args remaining: $*" - elif [[ $arg == --tau_output ]]; then - shift - expecting_output_file=true - #echo "args remaining: $*" elif [[ $arg == --tau_output=* ]]; then output_file="${arg#--tau_output=}" shift || true #echo "args remaining: $*" + elif [[ $arg == --tau_select_file=* ]]; then + select_file="${arg#--tau_select_file=}" + shift || true + #echo "args remaining: $*" elif [[ $arg == *.[Ff]90 || $arg == *.[Ff] || $arg == *.[Ff]03 ]]; then input_file="$arg" shift || true #echo "args remaining: $*" - elif [[ $arg == -show ]]; then + elif [[ $arg == --show ]]; then show=true shift || true #echo "args remaining: $*" @@ -214,7 +199,7 @@ for arg in "$@"; do if [[ "${arg:-}" == -Werror ]]; then args+=("$arg") fi - # Flang frontend oesn't (yet) support -Wall, -Wextra, etc. only -Werror, so throw others away + # Flang frontend doesn't (yet) support -Wall, -Wextra, etc. only -Werror, so throw others away shift || true #echo "Added whitelisted warning flag: $arg" elif [[ ${arg:-} =~ ${_WHITELISTED_REGEX} ]]; then @@ -256,6 +241,7 @@ if [[ -z "${output_file:-}" ]]; then fi fi + echo "output file: ${output_file:-\"\" }" echo "Remaining Arguments: ${args[*]}" @@ -269,10 +255,12 @@ cmd=(flang-new "${args[@]}") if $show; then echo "SALT_FORTRAN_CONFIG_FILE=\"${FORTRAN_CONFIG_FILE}\"" + echo "SALT_FORTRAN_SELECT_FILE=\"${select_file:-}\"" echo "cmd: ${cmd[*]}" else echo "SALT_FORTRAN_CONFIG_FILE=\"${FORTRAN_CONFIG_FILE}\"" + echo "SALT_FORTRAN_SELECT_FILE=\"${select_file:-}\"" echo "Running: ${cmd[*]}" - SALT_FORTRAN_CONFIG_FILE="${FORTRAN_CONFIG_FILE}" "${cmd[@]}" + SALT_FORTRAN_SELECT_FILE="${select_file:-}" SALT_FORTRAN_CONFIG_FILE="${FORTRAN_CONFIG_FILE}" "${cmd[@]}" exit $? fi