Fix GNATprove child-package source resolution using base names - #194
Conversation
41034a2 to
707c546
Compare
|
Thanks for the detailed writeup -- I was able to reproduce the reported failure on a project component directory and dug into the root cause. What I found changes the picture: the failure is a file-argument resolution bug in GNATprove itself, not an inability to analyze the autocoded base classes. With the root cause fixed, Root causeGNATprove 15.1.0 (the version pinned in
The pattern is exact: every rejected file has a dash in its name (a child-package source); every top-level unit resolves either way. The rejection happens before any analysis starts, with the familiar Since
Notably, the "autocoded base classes cannot be analyzed" premise doesn't hold up: passing all 10 sources of the component (base class included) as basenames, GNATprove runs the full pipeline and exits 0 -- 66 units loaded, everything without Suggested minimal fixBasenames resolve through the same project source table (the directory of every closure file is already passed via + " -XSOURCE_DIRS="
+ ",".join(dep_dirs)
+ " "
# GNATprove (as of 15.1.0) fails to resolve child-package sources, ie.
# "parent-child.ads", when passed as absolute paths, reporting that
# they are "not a file or compilation unit of any project". Passing
# base names avoids this. The directory of every source file is
# already included in SOURCE_DIRS above, so base names resolve
# unambiguously.
+ " ".join([os.path.basename(f) for f in source_files])
+ directValidated in the Adamant container:
On the
|
707c546 to
00c259d
Compare
00c259d to
70eb841
Compare
Summary
redo provefails in any component directory whose source set includes autocoded child units (parent-child.ads). GNATprove (as of 15.1.0) rejects those units when they are passed as absolute paths, before analysis begins:The cause is path resolution, not analysis. GNATprove resolves the same child units when they are passed as base names, and
build_prove.pywas passing absolute paths.Fix
Pass the source arguments to GNATprove as base names. The directory of every source is already on
-XSOURCE_DIRS, so base names resolve unambiguously. One line inredo/rules/build_prove.py.Diagnosis and fix from @dinkelk (#194 review).
Validation
In the Adamant container, on a component containing a hand-written SPARK package alongside its autocoded child units. The before/after differ only in this one line; the built source set is identical.
admt provein the component directory fails atcomponent-<name>.ads is not a file or compilation unit of any project, before any analysis runs.admt proveruns to completion and reproduces the package's full proof through the build system — 10 checks, 0 unproved, 0 justified (6 run-time, 1 assertion, 1 functional contract, 1 data dependency, 1 termination; 8 discharged by the provers, 2 by flow), atlevel: 2, mode: gold, with the summary beside the component underbuild/prove/gnatprove/gnatprove.out.doc/example_architecture/spark_package(a top-level SPARK unit) builds and proves clean. Base names and absolute paths both resolve for non-child units, so the change is a no-op there.Closes #192.
Prior approach (superseded) —
packages:scoping inall.prove.yaml