I want to fix the library search paths (again) There are several documented problems. See https://github.com/parrot/parrot/issues/368 + http://trac.parrot.org/parrot/ticket/1589 '.' at the beginning. should be moved to the end (gh #368) or removed at all (tt #1589). If removed our tests will not work, so would need to add it if not installed. And several yet undocumented problems.
- There is no library search path test. I'm working on it in the branch library_path-gh368 - The documentation is missing or wrong. E.g. --- a/docs/pdds/pdd10_embedding.pod +++ b/docs/pdds/pdd10_embedding.pod @@ -291,8 +291,31 @@ to through the following functions: Parrot_api_add_include_search_path Parrot_api_add_dynext_search_path -There is currently no way to remove search paths once set, or to examine the -complete list of search paths. This may be added later. +or hooked via a custom defined: + + #ifdef PARROT_PLATFORM_LIB_PATH_INIT_HOOK + PARROT_PLATFORM_LIB_PATH_INIT_HOOK(interp, lib_paths); + #endif + +The search paths are accessible via vtable calls to indexed string arrays +from the ParrotInterpreter array, at the index C<interp[.IGLOBALS_LIB_PATHS]>. +See F<include/libpaths.pasm> resp. F<parrot/library.h> for the indices. + +For example in pir: + + .local pmc interp + getinterp interp + .local pmc lib_paths + lib_paths = interp[.IGLOBALS_LIB_PATHS] + .local pmc include_path + include_path = lib_paths[.PARROT_LIB_PATH_INCLUDE] + .local pmc library_path + library_path = lib_paths[.PARROT_LIB_PATH_LIBRARY] + .local pmc dynext_path + dynext_path = lib_paths[.PARROT_LIB_PATH_DYNEXT] + .local pmc lang_path + lang_path = lib_paths[.PARROT_LIB_PATH_LANG] + =head3 Strings and PMCs - I was able to print and change the search paths easily: .include 'iglobals.pasm' .include 'libpaths.pasm' .sub main :main .local pmc interp getinterp interp .local pmc lib_paths lib_paths = interp[.IGLOBALS_LIB_PATHS] .local pmc dynext_path dynext_path = lib_paths[.PARROT_LIB_PATH_DYNEXT] .local pmc p while_1: p = pop dynext_path say p if dynext_path goto while_1 .end - I detected various horrible ineffiences. The installed path overrides the build_dir path. So I came up with these rules, in the test to check for proper loadlib libpath order. (DYNEXT) if parrot is installed: $ENV{PARROT_LIBRARY} dynext/ $prefix/parrot/$version/dynext/ ./ if not installed: $ENV{PARROT_LIBRARY} dynext/ $build_dir/runtime/parrot/dynext ./ There should be no duplicates, unless the user added a path manually a PARROT env or via cmdline If installed $build_dir/ should NOT be searched. There is no business poking there. If not installed the installed libpath should NOT be at the top, better not be searched at all. E.g. if we deprecate a library, delete it locally, and the test picks up the installed version instead. This is fragile. Keep "./" at end, not at the beginning. Similar for INCLUDE and LIBRARY and the experimental LANG. The paths are currently on an uninstalled parrot like this. libs.pir: .include 'iglobals.pasm' .include 'libpaths.pasm' .sub main :main .local pmc interp getinterp interp .local pmc lib_paths lib_paths = interp[.IGLOBALS_LIB_PATHS] .local pmc idx, desc idx = new 'FixedIntegerArray', 4 desc = new 'FixedStringArray', 4 idx[0] = .PARROT_LIB_PATH_INCLUDE desc[0] = "PARROT_LIB_PATH_INCLUDE" idx[1] = .PARROT_LIB_PATH_LIBRARY desc[1] = "PARROT_LIB_PATH_LIBRARY" idx[2] = .PARROT_LIB_PATH_DYNEXT desc[2] = "PARROT_LIB_PATH_DYNEXT" idx[3] = .PARROT_LIB_PATH_LANG desc[3] = "PARROT_LIB_PATH_LANG" $I0 = 0 while_idx: .local pmc path $I1 = idx[$I0] $S1 = desc[$I0] path = lib_paths[$I1] .local pmc p .local int i, size size = path i = 0 print $S1 say ":" while_1: p = path[i] say p i = i + 1 if i < size goto while_1 $I0 = $I0 + 1 if $I0 < 4 goto while_idx .end => $ ./parrot libs.pir PARROT_LIB_PATH_INCLUDE: /home/rurban/Perl/parrot/parrot-git/ /home/rurban/Perl/parrot/parrot-git/runtime/parrot/include/ /usr/local/lib/parrot/4.11.0-devel/include/ ./ /home/rurban/Perl/parrot/parrot-git/ /home/rurban/Perl/parrot/parrot-git/runtime/parrot/include/ /usr/local/lib/parrot/4.11.0-devel/include/ ./ PARROT_LIB_PATH_LIBRARY: /home/rurban/Perl/parrot/parrot-git/runtime/parrot/library/ /usr/local/lib/parrot/4.11.0-devel/library/ ./ /home/rurban/Perl/parrot/parrot-git/runtime/parrot/library/ /usr/local/lib/parrot/4.11.0-devel/library/ ./ PARROT_LIB_PATH_DYNEXT: dynext/ /home/rurban/Perl/parrot/parrot-git/runtime/parrot/dynext/ /usr/local/lib/parrot/4.11.0-devel/dynext/ /home/rurban/Perl/parrot/parrot-git/runtime/parrot/dynext/ /usr/local/lib/parrot/4.11.0-devel/dynext/ PARROT_LIB_PATH_LANG: /home/rurban/Perl/parrot/parrot-git/runtime/parrot/languages/ /usr/local/lib/parrot/4.11.0-devel/languages/ ./ /home/rurban/Perl/parrot/parrot-git/runtime/parrot/languages/ /usr/local/lib/parrot/4.11.0-devel/languages/ ./ Note the duplicates. On an installed parrot: $ ./installable_parrot libs.pir PARROT_LIB_PATH_INCLUDE: ./ /usr/local/lib/parrot/4.11.0-devel/include/ /usr/local/lib/parrot/4.11.0-devel/include/ PARROT_LIB_PATH_LIBRARY: ./ /usr/local/lib/parrot/4.11.0-devel/library/ /usr/local/lib/parrot/4.11.0-devel/library/ PARROT_LIB_PATH_DYNEXT: dynext/ /usr/local/lib/parrot/4.11.0-devel/dynext/ /usr/local/lib/parrot/4.11.0-devel/dynext/ PARROT_LIB_PATH_LANG: ./ /usr/local/lib/parrot/4.11.0-devel/languages/ /usr/local/lib/parrot/4.11.0-devel/languages/ -- Reini Urban http://cpanel.net/ http://www.perl-compiler.org/ _______________________________________________ http://lists.parrot.org/mailman/listinfo/parrot-dev