Subject: | $DynaLoader::do_expand causes failures on Win32 |
I tried to convert a large Perl project to a single-file script with the following command:
pp -P -B proj.pl
When I run the resulting a.pl file, I get the following errors:
Can't locate loadable object for module Sys::Hostname in @INC (@INC contains: [...].) at D:/Tools/Perl/site/lib/PAR/Heavy.pm line 104
Can't locate loadable object for module Socket in @INC (@INC contains: [...].) at D:/Tools/Perl/site/lib/PAR/Heavy.pm line 104
Compilation failed in require at IO/Socket.pm line 12.
BEGIN failed--compilation aborted at IO/Socket.pm line 12.
[...]
The mentioned packages are correctly included in the a.pl file. I checked the cache directory under TEMP, and Hostname.dll and Socket.dll were there just fine.
I debugged this issue by using the PERL_DL_DEBUG environment variable, and by adding debugging code to the files in the cache directory. The problem went away when I did the following change:
Heavy.pm, line 103 (function _bootstrap):
local $DynaLoader::do_expand = 1;
->
local $DynaLoader::do_expand = 0;
I don't know why do_expand is set to 1 here, but in my setup it causes a call to the dummy dl_expandspec function set in _init_dynaloader on line 38 of Heavy.pm. This dummy function does nothing, causing all files to be reported as missing.
When I did this change to the Heavy.pm file under the Perl directory, I was able to build a working script from my project. Please investigate, and you'll probably come up with a better fix!
I am running PAR 0.83 on ActiveState Perl v5.8.3 (MSWin32-x86-multi-thread).