Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: gap root path unification #5941

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

fingolfin
Copy link
Member

@fingolfin fingolfin commented Feb 18, 2025

This is not yet quite done, but the goal is to ensure that the GAP kernel and library use the same (identical, egal) plist of root paths.

This has multiple benefits:

  • we replace gnarly C code messing with pointers, manual memory allocation, careful copying around of memory blocks, and which is limited to a hard coded maximum of 16 GAP roots, and also limits the length of paths
  • the replacement is simple C code, that produces a plist of strings objects
  • this plist can then be shared with the GAP library (this part is not yet done! not because it is hard, but just because I did not yet get around to doing it)
  • kernel and library thus get an identical list of root paths, avoiding weird issues caused by them differing
  • most post-processing of the root paths, such as turning relative paths into absolute paths, or removing duplicates, can be done entirely on the GAP level

TODO:

  • actually pass the root path list to the library
  • restore the code which expands ~ into $HOME
  • fix HPC-GAP compat
  • fix workspace support
  • figure out implications for GAP workspaces:
    • ... because right now, if we load a workspace, then the root path list of the kernel is computed fresh, while that of the library is restored from the workspace
    • with this PR, the restore should also replace the root path list of the kernel
    • for most cases this shouldn't make a difference, but it should be possible to construct examples where it makes a visible difference. I think this is fine right now, but this warrants some more carefully thinking
  • more testing & debugging...
  • possibly split off parts of the PR into separate PR so they can be reviewed and merged more easily

Note that most likely right workspaces are simply broken, but if so I know why and this will be addressed by the above.

Resolves #4675

Replace one IS_PLIST check by a direct tnum comparison,
split 2 and 3 argument variant implementation
Most arguments are handled in the first stage. In particular all
that are relevant for the GC. The second stage is only for the
arguments which add GAP roots paths: those involve storing
strings, which can be of arbitrary size. We'd like to switch their
handling from C strings to GAP strings, but that requires the
memory manager to be initialized. With this patch, it *is*
initialized before we parse the root paths.
@fingolfin fingolfin marked this pull request as draft February 18, 2025 10:44
fi;
od;
# Append the new root paths.
GAPInfo.RootPaths:= Immutable( Concatenation( GAPInfo.RootPaths,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've replaced this now with a loop that uses Add to add each path separately. Various reasons

  • the "skip paths already in the list" is more powerful if we do it after ensuring the trailing slash is there
  • for HPC-GAP compatibility we may have to switch GAPInfo.RootPaths from a plist to an atomic list, where Add is supported but not Append

Anyway this is of course also a natural place to turn relative paths in absolute ones, call realpath, etc. -- but that goes beyond the scope of this PR

*/
Char * SyFindGapRootFile(const Char * filename, Char * buf, size_t size)
Obj SyFindGapRootFile(const Char * filename)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately changing SyFindGapRootFile to return a string object currently clashes with work space restoring as it is called during that when restoring loaded compiled modules (including kernel extensions)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kernel: replace more C string manipulation by GAP string objects
1 participant