Repository navigation
Description
Description
Error is encountered when a Fortran benchmark for a Level-2+ BLAS routine whose Fortran source declares an EXTERNAL Fortran dependency on another stdlib package (e.g., dgemm calling xerbla, dger calling xerbla). The benchmark fails to link with a missing-symbol error for the dependency.
The underlying defect is in @stdlib/utils/library-manifest. When the resolver is queried with any task other than build (notably task: 'benchmark'), Fortran source files belonging to dependencies are not surfaced.
Fortran sources are currently declared only inside the build task entry of each Fortran-using package's manifest — so when library-manifest walks the dependency tree under task: 'benchmark', it merges each dependency's benchmark entry, which contains only C sources, and the dependency's .f files never appear in the merged result.
For example, in blas/base/xerbla/manifest.json:
task: 'build',os: 'linux',blas: '',wasm: false→src: ["./src/xerbla.f", "./src/xerbla.c"]task: 'benchmark',os: 'linux',blas: '',wasm: false→src: ["./src/xerbla.c"](no.f)
The native-addon build path works bc binding.gyp/include.gypi calls library-manifest with no explicit task, defaulting to task: 'build', where the .f declarations exist.
The same condition silently affects every merged Fortran benchmark for a Level-2+ BLAS routine that exercises a cross-package Fortran symbol. Level-1 BLAS Fortran benchmarks (e.g., daxpy, dscal, dasum) have no cross-package Fortran dependencies and link cleanly, which is why the gap has not surfaced more broadly.
The recurring local fix is a Makefile patch in the consuming package that hardcodes a relative path to a sibling package's .f file (e.g., ../../../xerbla/src/xerbla.f inside dger's benchmark Makefile). This couples one package to another package's file-tree layout. If xerbla is ever moved within the package tree (e.g., to @stdlib/blas/base/utils/xerbla), every consumer's hardcoded path silently breaks, and a contributor performing the migration has no way to discover the breakage short of running every affected benchmark. The manifest-based @stdlib/... reference model exists precisely so packages don't reach into each other's file trees this way. See @kgryte's comment on PR #11332.
A second, downstream contributor to the symptom is that tools/scripts/compile_fortran_benchmark only resolves include directories from the manifest, while its C counterpart tools/scripts/compile_c_benchmark resolves include, src, libraries, and libpath. Patching only this wrapper might be too narrow, since it wouldn't address future Fortran-linking contexts that go through library-manifest.
Per office hours discussion, the fix should live in @stdlib/utils/library-manifest so that Fortran source files are resolved uniformly when resolving a package's dependency tree, regardless of the task the caller queried.
Once the resolver is correct, downstream cleanup for the Fortran benchmark wrapper in tools/scripts/ should consume the resolved source list (mirroring its C counterpart), and the merged Fortran benchmark Makefiles' hardcoded SOURCE_FILES defaults should match the C-benchmark Makefile convention.
Related Issues
Related PRs #11332 and #11333.
Questions
No.
Demo
No response
Reproduction
# In a checkout of stdlib develop:
cd lib/node_modules/@stdlib/blas/base/dger/benchmark/fortran
makeExpected Results
Benchmark links successfully; xerbla resolves via the manifest dependency graph (dger's manifest already lists @stdlib/blas/base/xerbla as a dependency under task: 'benchmark'.
Actual Results
Undefined symbols for architecture arm64:
"_xerbla", referenced from:
_dger in ccCfvnCt.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
make: *** [benchmark.length.out] Error 1Linker fails with an unresolved reference to xerbla. The dependency's .f source is never surfaced because library-manifest only declares Fortran sources under task: 'build'.
Version
develop
Environments
N/A
Browser Version
No response
Node.js / npm Version
No response
Platform
Reproduces on any platform with gfortran + make (linux/macOS verified).
Checklist
- Read and understood the Code of Conduct.
- Searched for existing issues and pull requests.
Activity
officiallyanee commentedon May 5, 2026
batpigandme commentedon May 5, 2026
[-][BUG] Fortran source files don't propoagate through `library-manifest` dependency resolution outside `task: 'build'`[/-][+][BUG] Fortran source files don't propagate through `library-manifest` dependency resolution outside `task: 'build'`[/+]batpigandme commentedon May 5, 2026
Reconsidering this in the context of last week's office hours: I got the scope wrong in my last comment. The
langpost-filter idea is at the wrong layer, and I want to correct that before anyone starts building on it.The Fortran missing-symbol thing is actually one symptom of a bigger structural mismatch in how
library-manifestresolves dependencies.Right now when
library-manifestresolvestask: 'benchmark'for a top-level package, it propagatestask: 'benchmark'recursively to every dep in the tree. That works by accident — deps tend to have atask: 'benchmark'conf with a reasonablesrclist, so things compile. It breaks when a dep doesn't have native benchmarks at all (I thinkfloat32base assert packages were mentioned last week), and it's why Fortran symbols go missing: the dep traversal isn't expressing "what files do I contribute when I'm pulled in as someone else's dependency?" — it's just reusing each dep's own benchmark conf as a stand-in.The
langfilter idea would have been filtering an already-incompletesrclist. The list itself isn't being built correctly when crossing dep boundaries — filtering it differently doesn't help.Revised thoughts on a structural fix:
task: 'build' | 'benchmark' | 'examples'. This declares what files/includes/libraries to merge in when the package is consumed as a dep, regardless of the top-level task.library-manifest(specifically the dep-merge loop inlib/main.js, ~lines 161–204) so it uses that as-dependency conf instead of propagating the top-level task straight through.Once dep-confs explicitly list their Fortran contributions (
.ffiles), the missing-symbol case goes away. Per @kgryte's description last week, the Fortran resolution issue is general — it applies to native add-ons, examples, source implementations, and benchmarks — so it has to be fixed at this layer, not in any one compile script.What this means for the thread: the manifest-level change is bigger than a single-file (or few-file) patch — it touches every C/Fortran package's
manifest.json(hundreds of files), thelibrary-manifestrecursion, backward-compat considerations, and schema docs. Probably needs its own issue with maintainer scoping before anyone takes a stab.That said, the
compile_fortran_benchmarkparity work you identified, @officiallyanee, is still real and still actionable on its own — the wrapper is underpowered relative tocompile_c_benchmark, and fixing that doesn't depend on the manifest restructuring. That's still a helpful patch if you want to focus there.I could still be wrong about the blast radius — definitely take a peek at the dep-merge loop in
lib/main.jsyourself. And still no rush on any of it — exam season is real 🙂.officiallyanee commentedon May 5, 2026
Thanks for the pointers!
Some ref for
as-dependency: Athan's comment on missing task config, the issues raised for the same: 1 & 2.I will add the patch for the parity work as soon as I can! And would look into the blast radius too.
batpigandme commentedon May 5, 2026
Some notes from @kgryte's observations in today's office hours on the broader
library-manifestrefactor direction (we can iterate and revise, etc., just didn't want to lose the info):Two coupled fronts:
manifest.json. ESLint-style presets — you define named base configs, and other configs can extend/inherit from them, only specifying overrides. This addresses the repetition problem in packages with lots of permutations (especially BLAS with hardware-accelerated bindings). Named configs may live outside theconfsarray entirely, and multiple inheritance is on the table.manifest.jsonis a conf that says "when this package is used as a dependency, here's the minimal set of files/headers/libraries that are necessary." That's why the current dep resolution works by accident (propagating the top-level task down the tree) and breaks when a dep doesn't have a matching task conf. The dependency-mode conf would use the inheritance mechanism from the first front.Implementation plan per Athan:
@stdlib/utils/library-manifestMara's postulation
What this means for the Fortran issue specifically: the missing-symbol bug falls out of the dependency-mode conf — once deps explicitly declare their Fortran contributions (
.ffiles) in a dep-mode conf, the resolver picks them up correctly.I think the
compile_fortran_benchmarkwrapper parity issue remains (it only resolvesincludefrom the manifest, whilecompile_c_benchmarkresolvesinclude,src,libraries, andlibpath), since doesn't depend on the inheritance work. So, that could probably be its own little patch.officiallyanee commentedon May 14, 2026
Some more refs that might be useful: Eslint's old extends key & Eslint's new ideology for flat cascade
The former seems more useful in terms of design that will be required here, except I think one concern would be the merging of
dependencies, given that we have differentbasefor all different combination ofos,blas,wasmwe support.(These do differ in
buildand non-build inblaspkgs though, forsrcfiles & hence theirdependencies)officiallyanee commentedon May 14, 2026
Also a note on
compile_fortran_benchmark: achieving parity depends on having fortran source files resolved throughmanifest.json, which currently lacks them. Because if we were to go ahead then the defaults set forSOURCE_FILESin pkg-level Makefiles for benchmarks would be override by c source files in benchmark conf which would cause issues.However,
LIBRARIES,LIBPATH,osandBLASawareness can be brought to parity without depending on the manifest changes.officiallyanee commentedon May 14, 2026
Benchmarks for fortran are run under
pre-pushhook but not inCI. 😮officiallyanee commentedon Jun 26, 2026
CDoctest will potentially be affected by this issue too:
Task config mismatch for examples in source C files & usage section in READMEs : Using the example task config resolves dependencies for
examples/c/andREADMEexample blocks, but the dependency set for@exampleDoxygen blocks insrc/*.c& usage section inREADMEscan be different (e.g., includingstdlib/complex/float64/real.hto print the real component of a result). Using example config for them would over-resolve dependencies on every doctest run.Packages without a C example: Similar to the benchmark config issue (where resolving via the benchmark task failed for packages that simply don't have benchmarks), using example config could fail for packages that have
src/*.cbut noexamples/c/.Given the above, I was thinking a devDependencies block in manifest.json could help address both: it would be minimal (it would list only the direct dependencies the example needs, without pulling in transitive example-level dependencies of each dependency the way example task config does) and the doctest tool could supplement it with any additional headers it discovers at parse time (until a dedicated
docsconfig is introduced).I also came across @kgryte comment on Om's proposal regarding the same problem(ref):