Bug fixes for package netcdf-cxx4 on macOS, align netcdf-cxx4 with netcdf-fortran#29246
Conversation
…e-sensitive filesystems; build package netcdf-cxx4 consistently with netcdf-fortran
| variant('shared', default=True, description='Enable shared library') | ||
| variant('pic', default=True, description='Produce position-independent code (for shared libs)') | ||
| variant('doxygen', default=True, description='Enable doxygen docs') | ||
| variant('doc', default=False, description='Enable doxygen docs') |
There was a problem hiding this comment.
I support this renaming. Thank you!
| # can correctly link to all the dependencies even when the | ||
| # building takes place outside of Spack environment, i.e. | ||
| # without Spack's compiler wrappers. | ||
| config_flags = [self.spec['netcdf-c'].libs.search_flags] |
There was a problem hiding this comment.
The variable config_flags is set but seems not to be used anywhere.
There was a problem hiding this comment.
This is copied from the netcdf-fortran package as well, but I missed returning the flags. Since you said it's not needed, I'll remove it here and in netcdf-fortran. Yes, I noticed that there are no .la files and I was wondering why netcdf-fortran had this code.
| # On macOS, we also need to add this to ldflags | ||
| if self.spec.satisfies("platform=darwin"): | ||
| flags = [self.spec['netcdf-c'].libs.search_flags, | ||
| self.spec['netcdf-c'].libs.link_flags] + flags |
There was a problem hiding this comment.
I am curious to learn why you think link_flags should be added. As far as I know, the configure script appends -lnetcdf automatically.
There was a problem hiding this comment.
Definitely needed on macOS (in this or another way). I built netcdf-c with spack and netcdf-fortran as-is in the current spack repo, but netcdf-cxx4 did not have the -L.../netcdf-c/lib -lnetcdf in the linker line.
| if '+mpi' in netcdf_c_spec or '+parallel-netcdf' in netcdf_c_spec: | ||
| config_args.append('CC=%s' % self.spec['mpi'].mpicc) | ||
| config_args.append('FC=%s' % self.spec['mpi'].mpifc) | ||
| config_args.append('F77=%s' % self.spec['mpi'].mpif77) |
There was a problem hiding this comment.
I doubt that setting FC and F77 is needed for this package. I would add setting CXX and check whether CC is needed. In any case, thanks for trying to make this consistent.
There was a problem hiding this comment.
Of course, good point. I'll remove Fortran and check if we still need to set CC.
| # Unidata has fixed this in their development track: | ||
| # https://github.com/Unidata/netcdf-cxx4/commit/41c0233cb964a3ee1d4e5db5448cd28d617925fb | ||
| os.rename('VERSION', 'config.VERSION') | ||
| super(NetcdfCxx4, self).build(spec, prefix) |
There was a problem hiding this comment.
could you, please, check whether this can be replaced with (also for version 4.3.0):
patch('https://github.com/Unidata/netcdf-cxx4/commit/e7cc5bab02cf089dc79616456a0a951fee979fe9.patch',
sha256='ba466b887c7ad2710e6d394046bc0742a2f4043d98bd21d5b08f33dc9d7f392d',
when='@:4.3.1 platform=darwin')I have used Unidata/netcdf-cxx4@e7cc5ba because that's the commit in the master upstream.
There was a problem hiding this comment.
Ok, I got this - will update the sha hash in my next test:
==> Error: ChecksumError: sha256 checksum failed for /Users/heinzell/work/jedi-stack/spack-stack-new-joint/spack-stack-develop-20220215/cache/build_stage/spack-stage-u032oec1/e7cc5bab02cf089dc79616456a0a951fee979fe9.patch
Expected ba466b887c7ad2710e6d394046bc0742a2f4043d98bd21d5b08f33dc9d7f392d but got 4ddf6db9dc0c5f754cb3d68b1dbef8c385cf499f6e5df8fbccae3749336ba84a
There was a problem hiding this comment.
My bad, should be 4ddf6db9dc0c5f754cb3d68b1dbef8c385cf499f6e5df8fbccae3749336ba84a indeed.
There was a problem hiding this comment.
You might need to run spack clean -m after the update and before the attempt to build.
There was a problem hiding this comment.
Sure, I have learned (the hard way) that making spack forget isn't that easy ... The patch works just fine.
|
I have just realized that I contradict myself regarding the MPI wrappers. See #17051, which also explains why we need to add Not that I really mind building with the MPI wrappers (btw, the comment in this PR refers to the Fortran-related documentation, is there one for C++?) but I normally try to avoid overlinking and would like to learn why exactly we should use the wrappers. |
I can try building without the MPI wrappers. Maybe that problem is solved by linking against the netcdf-c library. I remember I got the missing MPI symbols first, so I put the MPI wrappers in place, before I ran into and fixed the netcdf-c linker problem. |
|
@climbfuji thanks, please, keep in mind that the direct dependency on MPI might be unintended. For example, see #6632 |
Without any MPI wrapper, I get this: Will try with just the mpicxx wrapper next. |
Same problem with just the MPICXX wrapper, as expected. |
|
@climbfuji could you, please, tell me which MPI library you use? I find it strange that Spack compiler wrapper does not inject the required |
mpich-3.4.3 installed via homebrew (i.e. an external package for spack) |
This was a rudiment from the times when the package was fetched with git, which broke timestamp order of the automatically generated Autoconf files.
This makes it consistent with other packages from the NetCDF constellation: always build the static libraries and additionally build the shared ones when '+shared'.
This makes it consistent with other packages from the NetCDF constellation: build the shared libraries with the PIC flag and the static ones without it (the default for Autotools) when '~pic', and build the static libraries with PIC when '+pic' (to make them injectable into other shared libraries).
Bugfix/netcdf cxx4 macos
|
@skosukhin @WardF I think this is ready to merge with your (Sergey's updates). Would you be able to review this? Thanks a lot in advance! |
|
@skosukhin @WardF I have tested this to the bones on numerous systems (macOS, Linux, Cray) with several compilers (clang, gnu, intel) in the last ten days. Can we get this merged? Thanks a lot in in advance for your time. |
|
@skosukhin @WardF I am sorry that I have to keep asking, but can we get this merged, please? It passed all the CI tests and works on all our platforms. I just updated the branch once again ... thanks very much! |
|
@climbfuji none of us can actually do the merge. All I can do is write LGTM. |
Thanks, @skosukhin - appreciate your time. |
|
Any update on this PR? |
scheibelp
left a comment
There was a problem hiding this comment.
I had a couple questions
(I can merge this once those are resolved)
|
Thanks! |
|
Thanks indeed! |
Bug fixes for package netcdf-cxx4 so that it builds on macOS semi case-sensitive filesystems; this includes additional changes to build netcdf-cxx4 consistently with netcdf-fortran. * netcdf-fortran: remove unused config_flags * netcdf-fortran: avoid building without the optimization flags * netcdf-cxx4: do not enforce autoreconf. This was a rudiment from the times when the package was fetched with git, which broke timestamp order of the automatically generated Autoconf files. * netcdf-cxx4: inject PIC flags for C++ when '+pic' * netcdf-cxx4: inject C/CXXFLAGS via the wrapper * netcdf-cxx4: fix the underlinking problem for platforms other than darwin (add netcdf-c libs netcdf-cxx4 ldlibs flags) * netcdf-cxx4: remove redundant extension of CPPFLAGS * netcdf-cxx4: only need to use MPI compiler wrapper when building C (vs both C and C++) * netcdf-cxx4: remove variant 'static' This makes it consistent with other packages from the NetCDF constellation: always build the static libraries and additionally build the shared ones when '+shared'. * netcdf-cxx4: do not configure --with/--without-pic. This makes it consistent with other packages from the NetCDF constellation: build the shared libraries with the PIC flag and the static ones without it (the default for Autotools) when '~pic', and build the static libraries with PIC when '+pic' (to make them injectable into other shared libraries). * netcdf-cxx4: run the tests serially * netcdf-cxx4: build the plugins only when the tests are run Co-authored-by: Sergey Kosukhin <[email protected]>
This PR fixes a problem building netcdf-cxx4 (all the way up to the latest public release 4.3.1) on macOS with its semi case-sensitive file systems. An additional bug fix is required to get the correct library dependency on netcdf-c into the netcdf-cxx4 build on macOS, which uses
libtool.The PR also aligns the netcdf-cxx4 package config with the (better maintained) netcdf-fortran package config.
Fixes #29245
Fixes #26559
This PR was tested on macOS Monterey with [email protected] (and [email protected]), as well as on a Cray (NOAA-GFDL Gaea) with [email protected].