#15454·meson

Passing of source-path between libraries

Author: yannickulrichCreated Jan 9, 2026Updated Sep 11, 2026

Describe the bug

I'm trying to build a Fortran project in multiple stages. For example,

meson
lib1 = static_library('lib1', ['lib1.f95'])
dep1 = declare_dependency(
  link_with : lib1,
)
lib2 = static_library('lib2', ['lib2.f95'], dependencies : dep1)

Here, lib1 produces a Fortran module file that is imported by lib2.

When running ninja to build this for the first time it compiles lib1 and then lib2, as expected. If I change something in lib2 that does not impact the generated module file, the object files in lib2 do not need to be recompiled.

This happens because the output of liblib2.a.p/depscan.json is

json
{
  "version": 1,
  "revision": 0,
  "rules": [
    {
      "primary-output": "liblib2.a.p/lib2.f95.o",
      "requires": [
        {
          "logical-name": "lib1"
        }
      ],
      "provides": [
        {
          "logical-name": "lib2",
          "source-path": "../lib2.f95",
          "compiled-module-path": "liblib2.a.p/lib2.mod"
        }
      ],
      "outputs": [
        "liblib2.a.p/lib2.mod"
      ]
    }
  ]
}

lib1 does not include the source-path or the compiled-module-path which should have been ../lib1.f95 and liblib1.a.p/lib1.mod. This is because the pickle lib2.dat doesn't contain the required information

python
pickle.load(open("build/liblib2.a.p/lib2.dat", "rb"))
TargetDependencyScannerInfo(private_dir='liblib2.a.p', source2object={'../lib2.f95': 'liblib2.a.p/lib2.f95.o'}, sources=[('../lib2.f95', 'fortran')])

To Reproduce

Minimal working example example.tar.gz

Expected behavior

On recompile, lib2 gets re-linked but not recompiled.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)? no
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) NixOS 25.11
  • what Python version are you using: 3.13.9
  • what meson --version: 1.9.1
  • what ninja --version if it's a Ninja build: 1.13.1