# New Ticket Created by Mike Mattie # Please include the string: [perl #42898] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42898 >
hello, Building on commit #18446 this patch honors PARROT_PREFER_SOURCE. quick background: to get the install/working-copy to work the same extensions should not be used with .load_bytecode. Sometimes it will be compiled, sometimes not. The default behavior implemented in #18446 was to first preserve compatibility with the existing code-base by trying a path as it was given first. If that fails it will try appending extensions, from the lowest level compiled objects (.pbc) to the highest level source (.pir). This is the perl5 use behavior and what you would expect running out of a install target. Some developers did not like having to run a "make clean" to run the latest version of the source if there were stale objects lying around. This patch addresses that issue by honoring PARROT_PREFER_SOURCE. Currently the value is ignored. If it is set in the environment variable table it will reverse the normal extension guessing order, trying the highest level form of the code first. Developers who wish to avoid a make clean can now either avoid compiling files, or simply set this environment variable. As noted in the comments if the value of PARROT_PREFER_SOURCE is ever interpreted I think it should be a path spec for directories where source is preferred over compiled objects. Currently that is not implemented, but it can be if someone makes a more concrete case for it. This patch should be discussed, during which I will add the necessary tests and documentation changes. I have deferred this until now , when the behavior is complete enough to document. patch: This patch is based off rev 18446 with the spelling fixes from #42897 applied. harness: when I ran the test-suite I got a failure from t/perl/Parrot_Docs.t. A subsequent run of prove to double check it resulted in a pass. Strange. End result the test-suite passed unless someone can reproduce the failure with the harness. Cheers, Mike Mattie - [EMAIL PROTECTED]
--- BASE/src/library.c 2007-05-07 03:21:37.000000000 -0700 +++ rev-18446/src/library.c 2007-05-07 03:07:31.000000000 -0700 @@ -24,6 +24,53 @@ #include "library.str" /* + load_prefer is a toggle to prefer either the most low level form of a module + (compiled) or the highest level form of a module. + + Users will typically want the compiled versions. This is also the perl5 + behavior as well. + + Developers who don't like to run a clean target imbetween changes can set the + environment variable PARROT_PREFER_SOURCE (value does not matter). + + If a value for PARROT_PREFER_SOURCE is honored it should be a path spec of + directories for which source will be loaded over compiled objects. + */ + +#define COMPILE_FIRST 0 +#define SOURCE_FIRST 1 + +static int load_prefer = COMPILE_FIRST; + +static int +query_load_prefer ( Interp* interp ) { + int free_it; + char *env; + + env = Parrot_getenv("PARROT_PREFER_SOURCE", &free_it); + + if (env) { + if (free_it) + free(env); + + return 1; + } + + return 0; +} + +/* + extension guessing init to catch a ride with + parrot_init_library_paths on the init path. + */ + +static void +init_extension_guessing(Interp* interp) { + if( query_load_prefer(interp) ) + load_prefer = SOURCE_FIRST; +} + +/* =item C<void parrot_init_library_paths(Interp *)> @@ -59,6 +106,8 @@ PMC *iglobals, *lib_paths, *paths; STRING *entry; + init_extension_guessing(interp); + iglobals = interp->iglobals; /* create the lib_paths array */ lib_paths = pmc_new(interp, enum_class_FixedPMCArray); @@ -312,18 +361,30 @@ return result; /* - start guessing now. this version tries to find the lowest form of the - code, starting with bytecode and working up to PIR. note the atypical - loop control. This is so the array can easily be processed in reverse. + start guessing now. with load_prefer defaulting to COMPILE_FIRST + it tries the most compiled form first. with load_prefer set to + SOURCE_FIRST it will try the highest level source first. */ - for( guess = 0 ; guess <= LOAD_EXT_CODE_LAST ; guess++ ) { - with_ext = string_copy(interp, path); - with_ext = string_append(interp, - with_ext, const_string(interp, load_ext_code[guess])); + if ( COMPILE_FIRST == load_prefer ) { + for( guess = 0 ; guess <= LOAD_EXT_CODE_LAST ; guess++ ) { + with_ext = string_copy(interp, path); + with_ext = string_append(interp, + with_ext, const_string(interp, load_ext_code[guess])); + + if ( (result = try_load_path(interp, with_ext)) ) + return result; + } + } + else { + for( guess = LOAD_EXT_CODE_LAST ; guess >= 0 ; guess-- ) { + with_ext = string_copy(interp, path); + with_ext = string_append(interp, + with_ext, const_string(interp, load_ext_code[guess])); - if ( (result = try_load_path(interp, with_ext)) ) - return result; + if ( (result = try_load_path(interp, with_ext)) ) + return result; + } } return NULL;
signature.asc
Description: PGP signature