Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.mod files not installed to --includedir? #2

Closed
apthorpe opened this issue Oct 16, 2020 · 6 comments
Closed

.mod files not installed to --includedir? #2

apthorpe opened this issue Oct 16, 2020 · 6 comments

Comments

@apthorpe
Copy link
Contributor

I've successfully built zofu and installed it locally using:

cd <zofu project root> # The project root created from git clone
meson build --prefix /home/bob/.local/ --libdir=lib --includedir=finclude/zofu
ninja -C build
ninja -C build install

I confirmed installation by looking under ~/.local (aka /home/bob/.local) and found

~/.local/bin/zofu-driver
~/.local/finclude/zofu
~/.local/lib/libzofu.so
~/.local/lib/pkgconfig/zofu.pc

All looks reasonable except ~/.local/finclude/zofu is an empty directory; I expected to find zofu's .mod files installed there. They appear to be generated properly under <zofu project root>/build/libzofu.so.p

I can manually compile, link, and run test_integer_asserts.F90 with

gfortran check.F90 test_integer_asserts.F90 -L/home/bob/.local/lib -I<zofu project root>/build/libzofu.so.p -o test_integer_asserts -lzofu
LD_LIBRARY_PATH=/home/bob/.local/lib ./test_integer_asserts

Just wondering if there's an issue with ninja install not properly installing the .mod files generated in build/libzofu.so.p to --includedir? If it helps any, I'm running on Linux Mint 19.3 (ubuntu-ish) with the most recent release of meson (0.55.3). Let me know if there are further tests I can do on my end to help resolve this.

@apthorpe
Copy link
Contributor Author

Just confirmed the same issue exists under Windows. See https://gitlab.com/apthorpe/sofire2/-/blob/41-try-new-test-frameworks/contrib/zofu/README.md

@acroucher
Copy link
Owner

acroucher commented Oct 18, 2020

Meson does not yet have a proper built-in mechanism for installing Fortran module files from a built library:
mesonbuild/meson#5374

Zofu has some extra lines in the meson.build file for doing it manually (see line 50).
However that relies on the module files being in a specific place in the build directory, so it knows where to copy them from. It assumes they are in build/zofu@sha which is where they have been up to now.

It sounds like the Meson folks may have moved them in the 0.55 release, if you now have them in a directory called build/libzofu.so.p.

Could you try:

  • changing the dir in meson.build:52 from 'zofu@sha' to 'libzofu.so.p' and seeing if that cures it on Meson 0.55.3
  • reverting to Meson 0.54 and trying that, to confirm it's a change in Meson 0.55 (could do it with pip install in a virtualenv if you don't want to change the Meson on your system)

Then I might harangue the Meson developers and ask them again to implement a proper way of installing Fortran mod files. Meantime I may have to look at doing some sort of version-specific thing in the Zofu meson.build as a workaround.

@apthorpe
Copy link
Contributor Author

I've been working on a (hopefully friendly) PR which adds CMake build and packaging support. meson adds a dependency on Python which isn't used anywhere else in my project (see https://gitlab.com/apthorpe/sofire2) so it was easier for me to convert meson.build to a (mostly) equivalent CMakeLists.txt which resolves the installation issue, adds packaging for Linux, OSX, and Windows, plus generates documentation with FORD if its available. I'll explain more in the forthcoming PR description, but the intent is to reduce build dependencies for my specific CI situation and make Zofu more accessible, and absolutely not to suggest that you replace meson. I've also built a few convenience functions for composing tests in CMake (building unit test binaries; adding to CTest test plan) which may provide some inspiration for equivalents in meson. Consider it more of contrib code and an answer to "how do I do this with CMake since I'm already using it?" than anything else. Big picture: it makes Zofu more accessible to devs regardless of their chosen (or enforced) toolchain.

FWIW, nobody knows how to deal with .mod files. CMake provides a way to specify where generated .mod files get stored for a build target, but that's about it. They're kind of an artifactual disaster...

@acroucher
Copy link
Owner

I'm happy if we can add CMake support, though I don't use it myself.

Any chance you could just try making that change to the meson.build file anyway and seeing if it fixes the problem for you? If it does, that will help me code up a workaround.

@apthorpe
Copy link
Contributor Author

Sure; I'll see if I can get your suggested fix to work with meson.build and fold that in with the PR. Again, thanks for the code and the encouragement.

@apthorpe
Copy link
Contributor Author

I just submitted a PR (#3) with a brittle workaround to the installation issue. It's not great but it illustrates the issue and points toward a better solution. Otherwise, all the CMake-related files have extensive documentation should others want to build or use Zofu via CMake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants