Repository navigation
Conversation
…ry option Libobject.object_declaration gets an optional erase_function (identity by default) that removes source positions from an object, returning its argument physically when there is nothing to erase. With rocq compile -position-free-library, Library.save_library_struct applies it to md_objects and md_syntax_objects, so to both the .vo and its digest. Declaremods traverses module, module type, include, keep and escape nodes the way substitution does. Constants get an eraser (cst_loc). Test: compile a file twice changing only comments and layout and compare the .vo, and the .vo of an importer.
…ions Erasers for the NOTATION (notation_location), SYNTAX-EXTENSION (synext_location) and ABBREVIATION (abbrev_src) objects. The test now has notations, an abbreviation and a notation inside a functor, used through an instantiation.
…he cost on About The INDUCTIVE object keeps the locations of the type and constructor names. The test also checks that About shows no "Declared in" for an imported constant when the library was built with the option, and that it does without.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft: opt-in source-position-free library output (
-position-free-library)Draft PR for discussing the shape. It follows #22826 and is not ready to merge: Ltac and hints are still in progress.
What this does
With
rocq compile -position-free-library, we write the objects of the library without source positions, both in the.vo(and.vos) file and in the digest that importers record. For a library whose objects are all covered (see below), an edit that only moves positions, such as adding a comment or a blank line or reformatting, then leaves the whole.vobyte-identical. An edit inside an opaque proof still changes the opaque segment, as it should. Without the flag nothing changes.The hook is an optional field of
Libobject.object_declaration:Library.save_library_structapplies it, under the flag, tomd_objectsandmd_syntax_objects, the record behind both the disk output and the digest.Declaremods.erase_library_objectstraverses module, module type, include, keep and escape nodes the waysubst_objectsdoes. The file format androcqchkare unchanged.Covered in this PR
cst_loc);INDUCTIVEobject keeps the locations of the names).Still in progress (not in this PR)
Until these are covered, a file that defines tactics or hints still contains positions, so its
.vocan change on a comment-only edit.Sharing
Each eraser returns its argument physically (
==) when there is nothing to erase, and the traversals useList.Smart.mapand the like, so the sharing of values is kept. The flag does not fix sharing that depends on the input: the one case reported in the issue, two equal values shared differently, still gives different files.Cost
Imported declarations lose their source position, for example the "Declared in" line of
About. Libraries compiled without the flag are unaffected.Tests
test-suite/misc/position_free_library.shcompiles a file twice, editing only comments and layout, and compares the whole.vowithcmp, as well as the.voof an importer. A control build without the flag must differ,rocqchkaccepts the result, andAboutshows no "Declared in" for an imported constant. The file has constants, a functor instantiated in an importer, notations, an abbreviation and inductive types.make success miscfails the same four tests with and without this patch in our environment (misc/bench-render,misc/rocqchk_vm_bytecode,misc/vm_structured_constants: missingcamlzipandpython3;misc/qed-time: timing).The reference manual entry and a changelog entry are included. The changelog file is named
XXXXX-position-free-library-Added.rstand we will rename it to the PR number.Left for review
refinLibrary, set fromCoqcargs..vosoutput is position-free too, becausesave_library_structfeeds both.Loc.t(constants, notations, abbreviations, inductives). We will cover any others you point us to.Questions that block the next commits
Libobject.object_declaration, identity by default likesubst_function. Would you rather have a separate registry keyed by object name, leavingobject_declarationunchanged?glob_tactic_expr, so erasing it needs a pass over the tactic syntax, with matching hooks besideGensubst.register_subst0andGentactic.register_subst. Should that be its own pass (a newTaceraseof about 300 lines that mirrorsTacsubst, with no change toTacsubstbut a second traversal to keep in sync), or a traversal shared withTacsubst(thesubstargument becomes a record of leaf operations that substitution and erasure instantiate differently, which touches about 100 call sites ofplugins/ltac/tacsubst.ml)? We have not written the refactor and would not before hearing from you.