mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-02-11 16:01:00 +08:00
Remove version-check for relnum in H5check. (#812)
* Remove version-check for relnum in H5check. * Add in release exception code check * Fix typos * Fix more typos * Rework comments * format change * format whitespace * Library version must be less than or equal to headers * Need the NOT version of the compare * Enable release+1 check for PASS * Add release note * Update note
This commit is contained in:
parent
74f1590d47
commit
cfcdf21518
@ -463,6 +463,25 @@ New Features
|
|||||||
|
|
||||||
Library:
|
Library:
|
||||||
--------
|
--------
|
||||||
|
- Change how the release part of version, in major.minor.release is checked
|
||||||
|
for compatibility
|
||||||
|
|
||||||
|
The HDF5 library uses a function, H5check_version, to check that
|
||||||
|
the version defined in the header files, which is used to compile an
|
||||||
|
application is compatible with the version codified in the library, which
|
||||||
|
the application loads at runtime. This previously required an exact match
|
||||||
|
or the library would print a warning, dump the build settings and then
|
||||||
|
abort or continue. An environment variable controlled the logic.
|
||||||
|
|
||||||
|
Now the function first checks that the library release version, in
|
||||||
|
major.minor.release, is not older than the version in the headers.
|
||||||
|
Secondly, if the release version is different, it checks if either
|
||||||
|
the library version or the header version is in the exception list, in
|
||||||
|
which case the release part of version, in major.minor.release, must
|
||||||
|
be exact. An environment variable still controls the logic.
|
||||||
|
|
||||||
|
(ADB - 2021/07/27)
|
||||||
|
|
||||||
- gcc warning suppression macros were moved out of H5public.h
|
- gcc warning suppression macros were moved out of H5public.h
|
||||||
|
|
||||||
The HDF5 library uses a set of macros to suppress warnings on gcc.
|
The HDF5 library uses a set of macros to suppress warnings on gcc.
|
||||||
|
63
src/H5.c
63
src/H5.c
@ -70,6 +70,10 @@ hbool_t H5_PKG_INIT_VAR = FALSE;
|
|||||||
/* Library Private Variables */
|
/* Library Private Variables */
|
||||||
/*****************************/
|
/*****************************/
|
||||||
|
|
||||||
|
/* Library incompatible release versions */
|
||||||
|
const unsigned VERS_RELEASE_EXCEPTIONS[] = {0};
|
||||||
|
const unsigned VERS_RELEASE_EXCEPTIONS_SIZE = 0;
|
||||||
|
|
||||||
/* statically initialize block for pthread_once call used in initializing */
|
/* statically initialize block for pthread_once call used in initializing */
|
||||||
/* the first global mutex */
|
/* the first global mutex */
|
||||||
#ifdef H5_HAVE_THREADSAFE
|
#ifdef H5_HAVE_THREADSAFE
|
||||||
@ -870,6 +874,9 @@ done:
|
|||||||
* called from user to verify that the versions of header files
|
* called from user to verify that the versions of header files
|
||||||
* compiled into the application match the version of the hdf5
|
* compiled into the application match the version of the hdf5
|
||||||
* library.
|
* library.
|
||||||
|
* Within major.minor.release version, the expectation
|
||||||
|
* is that all release versions are compatible, exceptions to
|
||||||
|
* this rule must be added to the VERS_RELEASE_EXCEPTIONS list.
|
||||||
*
|
*
|
||||||
* Return: Success: SUCCEED
|
* Return: Success: SUCCEED
|
||||||
*
|
*
|
||||||
@ -886,6 +893,15 @@ done:
|
|||||||
"linked with a different version of static or shared HDF5 library.\n" \
|
"linked with a different version of static or shared HDF5 library.\n" \
|
||||||
"You should recompile the application or check your shared library related\n" \
|
"You should recompile the application or check your shared library related\n" \
|
||||||
"settings such as 'LD_LIBRARY_PATH'.\n"
|
"settings such as 'LD_LIBRARY_PATH'.\n"
|
||||||
|
#define RELEASE_MISMATCH_WARNING \
|
||||||
|
"Warning! ***HDF5 library release mismatched error***\n" \
|
||||||
|
"The HDF5 header files used to compile this application are not compatible with\n" \
|
||||||
|
"the version used by the HDF5 library to which this application is linked.\n" \
|
||||||
|
"Data corruption or segmentation faults may occur if the application continues.\n" \
|
||||||
|
"This can happen when an application was compiled by one version of HDF5 but\n" \
|
||||||
|
"linked with an incompatible version of static or shared HDF5 library.\n" \
|
||||||
|
"You should recompile the application or check your shared library related\n" \
|
||||||
|
"settings such as 'LD_LIBRARY_PATH'.\n"
|
||||||
|
|
||||||
herr_t
|
herr_t
|
||||||
H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
|
H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
|
||||||
@ -914,7 +930,8 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
|
|||||||
disable_version_check = (unsigned int)HDstrtol(s, NULL, 0);
|
disable_version_check = (unsigned int)HDstrtol(s, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (H5_VERS_MAJOR != majnum || H5_VERS_MINOR != minnum || H5_VERS_RELEASE != relnum) {
|
/* H5_VERS_MAJOR and H5_VERS_MINOR must match */
|
||||||
|
if (H5_VERS_MAJOR != majnum || H5_VERS_MINOR != minnum || H5_VERS_RELEASE > relnum) {
|
||||||
switch (disable_version_check) {
|
switch (disable_version_check) {
|
||||||
case 0:
|
case 0:
|
||||||
HDfprintf(stderr, "%s%s", version_mismatch_warning,
|
HDfprintf(stderr, "%s%s", version_mismatch_warning,
|
||||||
@ -949,8 +966,52 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
|
|||||||
break;
|
break;
|
||||||
} /* end switch */
|
} /* end switch */
|
||||||
|
|
||||||
|
} /* end if (H5_VERS_MAJOR != majnum || H5_VERS_MINOR != minnum || H5_VERS_RELEASE > relnum) */
|
||||||
|
|
||||||
|
/* H5_VERS_RELEASE should be compatible, we will only add checks for exceptions */
|
||||||
|
if (H5_VERS_RELEASE != relnum) {
|
||||||
|
for (unsigned i = 0; i < VERS_RELEASE_EXCEPTIONS_SIZE; i++) {
|
||||||
|
/* Check for incompatible headers or incompatible library */
|
||||||
|
if (VERS_RELEASE_EXCEPTIONS[i] == relnum || VERS_RELEASE_EXCEPTIONS[i] == H5_VERS_RELEASE) {
|
||||||
|
switch (disable_version_check) {
|
||||||
|
case 0:
|
||||||
|
HDfprintf(
|
||||||
|
stderr, "%s%s", version_mismatch_warning,
|
||||||
|
"You can, at your own risk, disable this warning by setting the environment\n"
|
||||||
|
"variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.\n"
|
||||||
|
"Setting it to 2 or higher will suppress the warning messages totally.\n");
|
||||||
|
/* Mention the versions we are referring to */
|
||||||
|
HDfprintf(stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", majnum, minnum,
|
||||||
|
relnum, (unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR,
|
||||||
|
(unsigned)H5_VERS_RELEASE);
|
||||||
|
|
||||||
|
/* Bail out now. */
|
||||||
|
HDfputs("Bye...\n", stderr);
|
||||||
|
HDabort();
|
||||||
|
case 1:
|
||||||
|
/* continue with a warning */
|
||||||
|
/* Note that the warning message is embedded in the format string.*/
|
||||||
|
HDfprintf(stderr,
|
||||||
|
"%s'HDF5_DISABLE_VERSION_CHECK' "
|
||||||
|
"environment variable is set to %d, application will\n"
|
||||||
|
"continue at your own risk.\n",
|
||||||
|
version_mismatch_warning, disable_version_check);
|
||||||
|
/* Mention the versions we are referring to */
|
||||||
|
HDfprintf(stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", majnum, minnum,
|
||||||
|
relnum, (unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR,
|
||||||
|
(unsigned)H5_VERS_RELEASE);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* 2 or higher: continue silently */
|
||||||
|
break;
|
||||||
|
} /* end switch */
|
||||||
|
|
||||||
} /* end if */
|
} /* end if */
|
||||||
|
|
||||||
|
} /* end for */
|
||||||
|
|
||||||
|
} /* end if (H5_VERS_RELEASE != relnum) */
|
||||||
|
|
||||||
/* Indicate that the version check has been performed */
|
/* Indicate that the version check has been performed */
|
||||||
checked = 1;
|
checked = 1;
|
||||||
|
|
||||||
|
@ -649,10 +649,10 @@ set_tests_properties (H5TEST-tcheck_version-minor PROPERTIES
|
|||||||
WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST
|
WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST
|
||||||
WILL_FAIL "true"
|
WILL_FAIL "true"
|
||||||
)
|
)
|
||||||
|
# release + 1 should pass
|
||||||
add_test (NAME H5TEST-tcheck_version-release COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:tcheck_version> "-tr")
|
add_test (NAME H5TEST-tcheck_version-release COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:tcheck_version> "-tr")
|
||||||
set_tests_properties (H5TEST-tcheck_version-release PROPERTIES
|
set_tests_properties (H5TEST-tcheck_version-release PROPERTIES
|
||||||
WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST
|
WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST
|
||||||
WILL_FAIL "true"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
@ -245,7 +245,7 @@ fi
|
|||||||
# HDF5_DISABLE_VERSION_CHECK, as unset, "", -1, 0, 1, 2, 3
|
# HDF5_DISABLE_VERSION_CHECK, as unset, "", -1, 0, 1, 2, 3
|
||||||
|
|
||||||
for val_disable_version_check in unset "" -1 0 1 2 3; do
|
for val_disable_version_check in unset "" -1 0 1 2 3; do
|
||||||
for wrong_version in none M m r; do
|
for wrong_version in none M m; do
|
||||||
TESTING "$val_disable_version_check" "$wrong_version"
|
TESTING "$val_disable_version_check" "$wrong_version"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user