Bug 2390464 - Meson no longer detects Fortran module dependencies
Summary: Meson no longer detects Fortran module dependencies
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: meson
Version: 43
Hardware: Unspecified
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Zbigniew Jędrzejewski-Szmek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 2385747
TreeView+ depends on / blocked
 
Reported: 2025-08-22 20:33 UTC by Susi Lehtola
Modified: 2026-08-25 07:06 UTC (History)
8 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Susi Lehtola 2025-08-22 20:33:54 UTC
The builds of xtb have started to fail. The error is

../src/prog/argparser.f90:20:8:
   20 |    use xtb_mctc_accuracy, only : wp
      |        1
Fatal Error: Cannot open module file ‘xtb_mctc_accuracy.mod’ for reading at (1): No such file or directory
compilation terminated.

xtb is built using meson and ninja. The missing file ‘xtb_mctc_accuracy.mod’ is generated from xtb/src/mctc/accuracy.f90, which means that meson/ninja is no longer handling this dependence correctly.

Reproducible: Always

Steps to Reproduce:
try to rebuild xtb package
Actual Results:
package fails to build

Expected Results:
package builds

Comment 1 Zbigniew Jędrzejewski-Szmek 2025-09-14 14:53:25 UTC
Hmm, I haven't used the fortran support in meson, but looking at the files, the
dependency just doesn't seem to be declared:

xtb_exe = executable(sources: prog, dependencies: xtb_dep_static, …)
xtb_dep_static = declare_dependency(link_with: xtb_common, …)
xtb_common = get_option('default_library') == 'both' ? xtb_lib.get_static_lib() : xtb_lib
xtb_lib = library(srcs, …)

So srcs has to be processed before the linking phase of xtb_exe, but
nothing indicates that it needs to be processed before the compilation step
of xtb_exe.

https://github.com/mesonbuild/meson/pull/12539 looks like it could be related.
But looking at the patches in that series, I see:

    # Fortran is a bit weird (again). When you link against a library, just compiling a source file
    # requires the mod files that are output when single files are built. To do this right we would need to
    # scan all inputs and write out explicit deps for each file. That is too slow and too much effort so
    # instead just have a full dependency on the library. This ensures all required mod files are created.

So it seems that the intent was to automatically handle the dependency,
contrary to what I wrote above.

Paolo, any idea about this? I think the first question is whether the xtb
config is correct or if it justed worked by accident previously…

The build works with the following workaround:
---------------&<--------------------------------------------------------------------------
diff --git xtb.spec xtb.spec
index abb57d2d21..7a9c1c7c4f 100644
--- xtb.spec
+++ xtb.spec
@@ -87,6 +87,7 @@ character(len=*),parameter :: version = "%{version}-%{release}%{dist}"
 character(len=*),parameter :: date = "$date"
 character(len=*),parameter :: author = "Fedora project"
 EOF
+ninja -C %{_vpath_builddir} -j %{_smp_build_ncpus} %{?__meson_verbose:--verbose} libxtb.a
 %meson_build

 %install
--------------->&--------------------------------------------------------------------------

Comment 3 Paolo Bonzini 2026-08-25 07:06:34 UTC
Another workaround, that shows how this is supposed to work:

$ ninja libxtb.so.6.7.1.p/depscan.json
$ sed 's/so\.6\.7\.1/a/' libxtb.so.6.7.1.p/depscan.json > libxtb.a.p/depscan.json
$ ninja

The build.ninja rule for libxtb.a.p/depscan.json has no dependencies. I'll report the issue upstream.


Note You need to log in before you can comment on or make changes to this bug.