h5 compiler wrappers now pass all arguments passed to it to the compile line (#3954)

* The issue was that the "allargs" variable was not being used in the final command of the compiler wrapper. Any entries containing an escaped quote (\", \') or other non-matching argument (*) would not be passed to the compile line. I have fixed this problem by ensuring all arguments passed to the compiler wrapper are now included in the compile line.

* added testing for compiler wrappers
This commit is contained in:
Scot Breitenfeld 2024-01-30 12:20:58 -06:00 committed by Larry Knox
parent c6a0abde93
commit f57a0dbec6
6 changed files with 156 additions and 38 deletions

View File

@ -62,7 +62,7 @@ host_os="@host_os@"
prog_name="`basename $0`"
allargs=""
misc_args=""
compile_args=""
libraries=""
link_args=""
@ -202,7 +202,6 @@ for arg in $@ ; do
case "$arg" in
-c)
allargs="$allargs $arg"
compile_args="$compile_args $arg"
if test "x$do_link" = "xyes" -a -n "$output_file"; then
@ -213,7 +212,6 @@ for arg in $@ ; do
dash_c="yes"
;;
-o)
allargs="$allargs $arg"
dash_o="yes"
if test "x$dash_c" = "xyes"; then
@ -225,14 +223,12 @@ for arg in $@ ; do
fi
;;
-E|-M|-MT)
allargs="$allargs $arg"
compile_args="$compile_args $arg"
dash_c="yes"
do_link="no"
;;
-l*)
libraries=" $libraries $arg "
allargs="$allargs $arg"
;;
-prefix=*)
prefix="`expr "$arg" : '-prefix=\(.*\)'`"
@ -264,14 +260,14 @@ for arg in $@ ; do
;;
*\"*)
qarg="'"$arg"'"
allargs="$allargs $qarg"
misc_args="$misc_args $qarg"
;;
*\'*)
qarg='\"'"$arg"'\"'
allargs="$allargs $qarg"
qarg='"'"$arg"'"'
misc_args="$misc_args $qarg"
;;
*)
allargs="$allargs $qarg"
misc_args="$misc_args $qarg"
if test -s "$arg"; then
ext=`expr "$arg" : '.*\(\..*\)'`
@ -313,7 +309,7 @@ if test "x$do_compile" = "xyes"; then
compile_args="-c $compile_args"
fi
$SHOW $CC -I$includedir $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CFLAGS $CFLAGS $compile_args
$SHOW $CC -I$includedir $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CFLAGS $CFLAGS $misc_args $compile_args
status=$?
if test "$status" != "0"; then

View File

@ -47,6 +47,8 @@ prog1_o=${H5TOOL}_prog1.o
prog2=${H5TOOL}_prog2.$suffix
prog2_o=${H5TOOL}_prog2.o
applib=libapp${H5TOOL}.a
args=${H5TOOL}_args.$suffix
args_o=${H5TOOL}_args.o
# short hands
# Caution: if some *.h5 files must be cleaned here, list them by names.
@ -134,16 +136,38 @@ int main (void)
}
EOF
# Generate args:
# An application main that test misc command line arguments being passed.
cat > $args <<EOF
#include <string>
#include <iostream>
#include "H5Cpp.h"
#ifndef H5_NO_NAMESPACE
using namespace H5;
#endif
const H5std_string FILE_NAME( "args.h5" );
int main (void)
{
char c = SGL_QUOTE; // 'H'
char *s = DBL_QUOTE; // "HDF"
int val = MISC; // 42
H5File file( FILE_NAME, H5F_ACC_TRUNC );
return 0;
}
EOF
# Parse option
# None
# Print a line-line message left justified in a field of 70 characters
# Print a line-line message left justified in a field of 74 characters
# beginning with the word "Testing".
#
TESTING() {
SPACES=" "
echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
echo "Testing $* $SPACES" | cut -c1-74 | tr -d '\012'
}
@ -231,6 +255,10 @@ echo "***"Just preprocess, no compile, no link.
TOOLTEST -E $hdf5main
TOOLTEST -E $appmain $prog1 $prog2
# HDF5 program that depends on input args.
echo "***"Simple Compile and Link in one step with user-supplied arguments.
TOOLTEST -DSGL_QUOTE=\'H\' -DDBL_QUOTE=\"HDF\" -DMISC=42 $args
##############################################################################
# END
##############################################################################

View File

@ -60,7 +60,7 @@ host_os="@host_os@"
prog_name="`basename $0`"
allargs=""
misc_args=""
compile_args=""
libraries=""
link_args=""
@ -198,7 +198,6 @@ for arg in $@ ; do
case "$arg" in
-c)
allargs="$allargs $arg"
compile_args="$compile_args $arg"
if test "x$do_link" = "xyes" -a -n "$output_file"; then
@ -209,7 +208,6 @@ for arg in $@ ; do
dash_c="yes"
;;
-o)
allargs="$allargs $arg"
dash_o="yes"
if test "x$dash_c" = "xyes"; then
@ -221,14 +219,12 @@ for arg in $@ ; do
fi
;;
-E|-M|-MT)
allargs="$allargs $arg"
compile_args="$compile_args $arg"
dash_c="yes"
do_link="no"
;;
-l*)
libraries=" $libraries $arg "
allargs="$allargs $arg"
;;
-prefix=*)
prefix="`expr "$arg" : '-prefix=\(.*\)'`"
@ -254,15 +250,15 @@ for arg in $@ ; do
;;
*\"*)
qarg="'"$arg"'"
allargs="$allargs $qarg"
misc_args="$misc_args $qarg"
;;
*\'*)
qarg='\"'"$arg"'\"'
allargs="$allargs $qarg"
qarg='"'"$arg"'"'
misc_args="$misc_args $qarg"
;;
*)
allargs="$allargs $qarg"
misc_args="$misc_args $qarg"
if [ -s "$arg" ] ; then
ext=`expr "$arg" : '.*\(\..*\)'`
@ -300,7 +296,7 @@ if test "x$do_compile" = "xyes"; then
compile_args="-c $compile_args"
fi
$SHOW $CXX -I$includedir $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CXXFLAGS $CXXFLAGS $compile_args
$SHOW $CXX -I$includedir $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CXXFLAGS $CXXFLAGS $misc_args $compile_args
status=$?
if test "$status" != "0"; then

View File

@ -66,6 +66,8 @@ prog1=${H5TOOL}_prog1.$suffix
prog1_o=${H5TOOL}_prog1.o
prog2=${H5TOOL}_prog2.$suffix
prog2_o=${H5TOOL}_prog2.o
args=${H5TOOL}_args.$suffix
args_o=${H5TOOL}_args.o
applib=libapp${H5TOOL}.a
# short hands
@ -277,16 +279,85 @@ main (void)
}
EOF
# Generate HDF5 v1.14 Main Program:
# This makes unique V1.14 API calls.
cat > $v114main <<EOF
/* This is a V1.14 API calls example Program. */
#include "hdf5.h"
#define H5FILE_NAME "tmp.h5"
#define SPACE1_RANK 3
int
main (void)
{
hid_t sid; /* Dataspace ID */
hid_t fapl = -1; /* File access property list ID */
int rank; /* Logical rank of dataspace */
hsize_t dims[] = {3, 3, 15};
size_t sbuf_size=0;
herr_t ret; /* Generic return value */
hsize_t start[] = {0, 0, 0};
hsize_t stride[] = {2, 5, 3};
hsize_t count[] = {2, 2, 2};
hsize_t block[] = {1, 3, 1};
/* Create the file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
/* Set low/high bounds in the fapl */
ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST,
H5F_LIBVER_LATEST);
/* Create the dataspace */
sid = H5Screate_simple(SPACE1_RANK, dims, NULL);
/* Set the hyperslab selection */
ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block);
/* Encode simple dataspace in a buffer with the fapl setting */
ret = H5Sencode(sid, NULL, &sbuf_size, fapl);
/* Encode simple dataspace in a buffer with the fapl setting */
ret = H5Sencode2(sid, NULL, &sbuf_size, fapl);
printf("HDF5 C program created with V1.14 API ran successfully. ");
/* "File %s generated.\n", H5FILE_NAME);
remove(H5FILE_NAME); */
return 0;
}
EOF
# Generate args:
# An application main that test misc command line arguments being passed.
cat > $args <<EOF
#include "hdf5.h"
#define H5FILE_NAME "check_args.h5"
int
main (void)
{
char c = SGL_QUOTE; /* 'H' */
char *s = DBL_QUOTE; /* "HDF" */
int val = MISC; /* 42 */
hid_t file; /* file and dataset handles */
file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
H5Fclose(file);
printf("HDF5 C Sample program ran successfully. File %s generated.\n", H5FILE_NAME);
remove(H5FILE_NAME);
return 0;
}
EOF
# Parse option
# None
# Print a line-line message left justified in a field of 70 characters
# Print a line-line message left justified in a field of 71 characters
# beginning with the word "Testing".
#
TESTING() {
SPACES=" "
echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
echo "Testing $* $SPACES" | cut -c1-71 | tr -d '\012'
}
@ -450,6 +521,10 @@ else
TOOLTEST $v112main
fi
# Group 6: # HDF5 program that depends on input args.
echo "***"Simple Compile and Link in one step with user-supplied arguments.
TOOLTEST -DSGL_QUOTE=\'H\' -DDBL_QUOTE=\"HDF\" -DMISC=42 $args
##############################################################################
# END
##############################################################################

View File

@ -42,11 +42,13 @@ myos=`uname -s`
myhostnama=`uname -n`
# Generate some source files and library for tests.
suffix=f90 # source file suffix
suffix=F90 # source file suffix
hdf5main=${H5TOOL}_hdf5main.$suffix
hdf5main_o=${H5TOOL}_hdf5main.o
appmain=${H5TOOL}_appmain.$suffix
appmain_o=${H5TOOL}_appmain.o
args=${H5TOOL}_args.$suffix
args_o=${H5TOOL}_args.o
prog1=${H5TOOL}_prog1.$suffix
prog1_o=${H5TOOL}_prog1.o
prog2=${H5TOOL}_prog2.$suffix
@ -106,7 +108,7 @@ cat > $hdf5main <<EOF
IMPLICIT NONE
CHARACTER(LEN=8), PARAMETER :: filename = "apptmp.h5" ! File name
CHARACTER(LEN=9), PARAMETER :: filename = "apptmp.h5" ! File name
INTEGER(HID_T) :: file_id ! File identifier
INTEGER :: error ! Error flag
@ -118,17 +120,38 @@ cat > $hdf5main <<EOF
END PROGRAM FILEEXAMPLE
EOF
# Generate an args Main Program:
# An application main that test misc command line arguments being passed.
cat > $args <<EOF
PROGRAM ARGS
USE HDF5 ! This module contains all necessary modules
IMPLICIT NONE
CHARACTER(LEN=1), PARAMETER :: chr1 = SGL_QUOTE ! 'H'
CHARACTER(LEN=3), PARAMETER :: chr3 = DBL_QUOTE ! "HDF"
INTEGER, PARAMETER :: val = MISC ! 42
CHARACTER(LEN=9), PARAMETER :: filename = "argtmp.h5" ! File name
INTEGER(HID_T) :: file_id ! File identifier
INTEGER :: error ! Error flag
CALL h5open_f (error)
CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error)
CALL h5fclose_f(file_id, error)
CALL h5close_f(error)
END PROGRAM ARGS
EOF
# Parse option
# None
# Print a line-line message left justified in a field of 70 characters
# Print a line-line message left justified in a field of 73 characters
# beginning with the word "Testing".
#
TESTING() {
SPACES=" "
echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
echo "Testing $* $SPACES" | cut -c1-73 | tr -d '\012'
}
@ -199,6 +222,10 @@ $RANLIB $applib
TOOLTEST $appmain $applib
TOOLTEST $appmain_o $applib
# HDF5 program that depends on input args.
echo "***"Simple Compile and Link in one step with user-supplied arguments.
TOOLTEST -DSGL_QUOTE=\'H\' -DDBL_QUOTE=\"HDF\" -DMISC=42 $args
# No preprocess test since -E is not a common option for Fortran compilers.
##############################################################################

View File

@ -60,7 +60,7 @@ host_os="@host_os@"
prog_name="`basename $0`"
allargs=""
misc_args=""
compile_args=""
link_args=""
link_objs=""
@ -176,7 +176,6 @@ for arg in $@ ; do
case "$arg" in
-c)
allargs="$allargs $arg"
compile_args="$compile_args $arg"
if test "x$do_link" = "xyes" -a -n "$output_file"; then
@ -187,7 +186,6 @@ for arg in $@ ; do
dash_c="yes"
;;
-o)
allargs="$allargs $arg"
dash_o="yes"
if test "x$dash_c" = "xyes"; then
@ -199,14 +197,12 @@ for arg in $@ ; do
fi
;;
-E|-M|-MT)
allargs="$allargs $arg"
compile_args="$compile_args $arg"
dash_c="yes"
do_link="no"
;;
-l*)
link_args="$link_args $arg"
allargs="$allargs $arg"
;;
-prefix=*)
prefix="`expr "$arg" : '-prefix=\(.*\)'`"
@ -238,14 +234,14 @@ for arg in $@ ; do
;;
*\"*)
qarg="'"$arg"'"
allargs="$allargs $qarg"
misc_args="$misc_args $qarg"
;;
*\'*)
qarg='\"'"$arg"'\"'
allargs="$allargs $qarg"
qarg='"'"$arg"'"'
misc_args="$misc_args $qarg"
;;
*) allargs="$allargs $arg"
*) misc_args="$misc_args $arg"
if [ -s "$arg" ] ; then
ext=`expr "$arg" : '.*\(\..*\)'`
if [ "$ext" = ".f" -o "$ext" = ".F" -o \
@ -293,7 +289,7 @@ if test "x$do_compile" = "xyes"; then
fi
$SHOW $FC $H5BLD_FCFLAGS $FCFLAGS ${F9XSUFFIXFLAG} ${fmodules} $compile_args
$SHOW $FC $H5BLD_FCFLAGS $FCFLAGS ${F9XSUFFIXFLAG} ${fmodules} $misc_args $compile_args
status=$?
if test "$status" != "0"; then