Skip to content

Port netcdf-c to Windows#34935

Merged
scheibelp merged 9 commits intospack:developfrom
johnwparent:win-paraview/port-netdfs
Mar 21, 2023
Merged

Port netcdf-c to Windows#34935
scheibelp merged 9 commits intospack:developfrom
johnwparent:win-paraview/port-netdfs

Conversation

@johnwparent
Copy link
Copy Markdown
Contributor

@johnwparent johnwparent commented Jan 13, 2023

Ports of Netcdf-c to be compatible with Windows - end goal of supporting Paraview on Windows.

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Jan 13, 2023

Hi @johnwparent! I noticed that the following package(s) don't yet have maintainers:

  • netcdf-cxx

Are you interested in adopting any of these package(s)? If so, simply add the following to the package class:

    maintainers = ["johnwparent"]

If not, could you contact the developers of this package and see if they are interested? You can quickly see who has worked on a package with spack blame:

$ spack blame netcdf-cxx

Thank you for your help! Please don't add maintainers without their consent.

You don't have to be a Spack expert or package developer in order to be a "maintainer," it just gives us a list of users willing to review PRs or debug issues relating to this package. A package can have multiple maintainers; just add a list of GitHub handles of anyone who wants to volunteer.

@spackbot-app spackbot-app bot requested review from WardF and skosukhin January 13, 2023 20:55
@johnwparent johnwparent linked an issue Jan 13, 2023 that may be closed by this pull request
@skosukhin
Copy link
Copy Markdown
Member

I guess it makes sense to reference #33564 here.

@zackgalbreath
Copy link
Copy Markdown
Contributor

@spackbot run pipeline

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Jan 27, 2023

I've started that pipeline for you!

@scheibelp
Copy link
Copy Markdown
Member

@spackbot run pipeline

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Feb 4, 2023

I've started that pipeline for you!

Copy link
Copy Markdown
Member

@scheibelp scheibelp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one question and one request


IF(MPI_C_INCLUDE_PATH)
target_include_directories(netcdf PUBLIC ${MPI_C_INCLUDE_PATH})
+ target_link_libraries(netcdf MPI::MPI_C)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These patches appear to be fundamental - do you know if there are any PRs for netcdf-c adding this functionality?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I must have missed this comment last week. Yes, there are, I made a PR implementing the relevant changes in netcdf around when I made this PR. FWIW the include change was not included in my changes as it seems as if there is some debate as to that point between netcdfc and hdf5.

Copy link
Copy Markdown
Member

@scheibelp scheibelp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a couple requests

scheibelp
scheibelp previously approved these changes Feb 10, 2023
@scheibelp scheibelp enabled auto-merge (squash) February 10, 2023 23:37
@scheibelp
Copy link
Copy Markdown
Member

Interestingly, the CI appears to fail legitimately here too, but for paraview (after building netcdf-c and netcdf-cxx):

__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path/linux-amzn2-x86_64_v3/gcc-7.3.1/libxml2-2.10.3-g6w7zcj4juhpgptfzeoauubewsgcsvmn/lib/libxml2.so  -lpthread && :
/usr/bin/ld: cannot find -lhdf5_hl-shared
/usr/bin/ld: cannot find -lhdf5-shared
collect2: error: ld returned 1 exit status

Paraview depends on netcdf-c (but not netcdf-cxx) so this would have something to do with locating hdf5 as part of the netcdf-c build: it's possible that the netcdf-c build needs to be updated to locate hdf5, and this in turn helps the paraview build. Alternatively, it may be that paraview needs to be updated to locate hdf5 itself, and whatever prior logic existed in netcdf-c was simply obscuring a mistake in the paraview build.

@johnwparent
Copy link
Copy Markdown
Contributor Author

@scheibelp I have determined the origin of the error (Netcdfc's cmake is the culprit) and am in the process of creating yet another patch and upstream PR to netcdfc to fix this.

depends_on("autoconf", type="build", when="@4.7.0,main")
depends_on("automake", type="build", when="@4.7.0,main")
depends_on("libtool", type="build", when="@4.7.0,main")
depends_on("m4", type="build")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure, we don't need m4 when building with cmake (e.g. here)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

netcdf-c master (and any subsequent releases post 4.9.0) will likely need this enabled yes, however for the time being netcdf-c builds perfectly fine without it as the files m4 is looking to generate are checked into source. I'll add the dep back for linux platforms, but as Spack does not currently support installing m4 for Windows, we won't add it as a dep for Windows.

NetCDF-C patches

Fixup netcdf HDF5+zlib detection

Netcdf's cmake is unable to detect that HDF5 was compiled with zlib
Add a patch that allows for said detection

netcdf-c patch ill formed cmakelists

Add netcdf linker patch
@johnwparent johnwparent force-pushed the win-paraview/port-netdfs branch from d9c8cf6 to a7ba778 Compare March 20, 2023 17:49
@johnwparent johnwparent changed the title Port netcdf-c[xx] to Windows Port netcdf-c to Windows Mar 20, 2023
@scheibelp scheibelp merged commit 2e9d0e1 into spack:develop Mar 21, 2023
# need to know whether to add "-lz" to the symbol
# tests below.
- CHECK_C_SOURCE_COMPILES("#include <H5public.h>
+ CHECK_C_SOURCE_COMPILES("#include <H5pubconf.h>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnwparent This patch reverts Unidata/netcdf-c#1731 and H5public.h does include H5pubconf.h. So, why is it needed on Windows?

I am asking because I am refactoring the netcdf-c package now and figuring out whether we need all the patches we apply.

Comment on lines +181 to +192
class BackupStep:
@property
def _nc_config_backup_dir(self):
return join_path(self.pkg.metadata_dir, "spack-nc-config")

@run_after("install")
def backup_nc_config(self):
# We expect this to be run before filter_compiler_wrappers:
nc_config_file = self.prefix.bin.join("nc-config")
if os.path.exists(nc_config_file):
mkdirp(self._nc_config_backup_dir)
install(nc_config_file, self._nc_config_backup_dir)
Copy link
Copy Markdown
Member

@alalazo alalazo Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to decorate with run_after a method from a class that is not a builder, we need to set explicitly the correct metaclass:

class BackupStep(metaclass=spack.builder.PhaseCallbacksMeta):
    ...

Copy link
Copy Markdown
Contributor Author

@johnwparent johnwparent Apr 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this or any of the other several multi build gotchas documented anywhere that I seem to be missing?
Edit: This is clearly a python language thing rather than a spack thing, but could still use a more obvious callout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Paraview Support on Windows

5 participants