ExternalLibraries/HDF5 fails to correctly set up include paths when auto-detecting library

Create issue
Issue #2235 open
Roland Haas created an issue

The current HDF5 ExternalLibaries detect.sh script does not correctly set HDF5_INC_PATH and HDF5_LIB_PATH on OSX Mojave using Hombrew and gcc-8.

This is the result of multiple issues:

  1. Homebrew does not provide a pkg-config file for HDF5: https://github.com/Homebrew/homebrew-core/issues/28826
  2. gcc-8 from Homebrew on Mojave does not by default look in /usr/local/include for include files (see the output of gcc-8 -xc -E -v /dev/null), https://github.com/Homebrew/homebrew-core/issues/35181
  3. we hard-code the list of "system" include paths (and library paths) in Cactus/lib/sbin/strip-incdirs.sh

This is an issue when using generic.cfg only, the (hand-crafted) osx-homebrew.cfg works around this issue like so:

# We need to explicitly set HDF5_INC_DIRS and HDF5_LIB_DIRS explicitly
# to prevent the configure scripts from stripping them. We also then
# need to set HDF5_LIBS manually.
HDF5_DIR  = /usr/local
HDF5_INC_DIRS  = /usr/local/include
HDF5_LIB_DIRS  = /usr/local/lib
HDF5_LIBS = hdf5hl_fortran hdf5_fortran hdf5_hl hdf5

indicating that the issue existed before.

MacPorts is not affected b/c it stores its include files in /opt/local which is not stripped out.

Comments (21)

  1. Roland Haas reporter

    Looking at the code and the Homebrew cfg file it seems that the actual work around in the cfg file is:

    # the configure scripts strip /usr/local from XXX_DIR to avoid chosing system
    # libraries, however OSX does not search in /usr/local by default, so
    # we add it by hand.
    LIBDIRS = /usr/local/lib
    SYS_INC_DIRS = /usr/local/include
    
  2. Steven R. Brandt

    Does homebrew not set up pkg-config? Is pkg-config absent? I found that if a pkg-config command is not in the path, HDF5 counts that as a failure to find something in the pkg-config path.

    I'm thinking that it might be useful to have simfactory (or maybe even the Makefile) stop and print out an error message if pkg-config, which, xargs, or hostname are not present, or if USER or HOME are not set. All these sorts of things can cause problems.

  3. Roland Haas reporter

    Homebrew (at least if asked to do so) does install pkg-config, however unfortunately Homebrew does not provide a pkg-confg file for HDF5. pkg-config is in the path, there just is no hdf5.pc file.

    That is what the linked in ticket in my point "1." is about. Homebrew does not provide a pkgconfig file because HDF5 itself does only provide one when compiled using cmake it seem, and it seems homebrew does not use cmake.

    Note that this issue is not actually new but already existed in (at least) the previous (two) release(s) since I have fixes for it in the osx-homebrew.cfg file. The reason this has come up again is trying to switch OSX and Linux to both use generic.cfg or at least work without having to specify an optionlist or special machine ini file to setup-silent.

    Note further that due to the way we filter out paths we think the compiler looks for even if no -L or -I is given, even having a pkg-config file would not help, since we would still filter out the "-I/usr/local/include" that is required on a Mac b/c gcc (Homebrew or MacPorts, and also the clang-gcc-wrapper) does not look in /usr/local/include (that is what my point 2. is about).

  4. Roland Haas reporter

    I am trying to come up with a better way to handle this is in the branch rhaas/strip-dirs of the flesh but the changes are bit too invasive to put them in just before the release and there will be use visible changes, though I believe the changes are towards the "fewer surprises" direction which I would think are acceptable.

  5. Steven R. Brandt

    I'm wondering if we want an option to the build system (maybe some environment variable) to disable the automatic building of packages if something isn't found, i.e. HDF5, lapack, etc. It's really annoying to find the build system compiling HDF5 when I think I've set things up so it won't.

  6. Roland Haas reporter

    There already is such an option: setting HDF5_DIR = NO_BUILD will not let it build HDF5 and will instead fail.

  7. Steven R. Brandt

    No, I mean a global option CCTK_DONT_BUILD_ANYTHING=yes or something. And I wouldn't want to have to put it in a cfg file.

  8. Roland Haas reporter

    I would like to add the fragment from osx-homebrew.cfg that actually helped

    # some compilers do not search in /usr/local/lib and /usr/local/include
    # by default, but some package managers install there
    LIBDIRS = /usr/local/lib
    SYS_INC_DIRS = /usr/local/include
    

  9. Log in to comment