重新编译 nqp 后“缺少或错误的依赖版本”

`Missing or wrong version of dependency` after recompiling nqp

我正在努力学习如何调试 rakudo and nqp。所以这是我的第一次尝试:

cd $HOME/debug
git clone https://github.com/rakudo/rakudo.git
cd rakudo
perl Configure.pl --gen-moar --gen-nqp --backends=moar
make
make install # installs into ./install/bin
export PATH=${PWD}/install/bin:$PATH
export PATH=${PWD}/install/share/perl6/site/bin:$PATH
# Testing executable:
perl6 --version
# This is Rakudo version 2018.12-256-g9517c3779 built on MoarVM version 2018.12-36-g34fac5f4e
# implementing Perl 6.d.
# 
# Now modifying an nqp file:
cd nqp
# Change a file: E.g. : vim src/HLL/Compiler.nqp
# I added a line after line 293 in src/HLL/Compiler.nqp:
#   nqp::say("*** Debugging message: HLL::Compiler::command_eval() ***");
# and save it
make
make install
# Testing perl6 again..
perl6 --version

最后一条命令现在出现以下异常:

Unhandled exception: Missing or wrong version of dependency 'gen/moar/stage2/NQPHLL.nqp' (from 'src/Perl6/Pod.nqp')
   at <unknown>:1  (/home/hakon/debug/rakudo/install/share/nqp/lib/Perl6/Pod.moarvm:<dependencies+deserialize>)
 from src/vm/moar/ModuleLoader.nqp:47  (/home/hakon/debug/rakudo/install/share/nqp/lib/ModuleLoader.moarvm:)
 from src/vm/moar/ModuleLoader.nqp:40  (/home/hakon/debug/rakudo/install/share/nqp/lib/ModuleLoader.moarvm:load_module)
 from <unknown>:1  (/home/hakon/debug/rakudo/install/share/nqp/lib/Perl6/Actions.moarvm:<dependencies+deserialize>)
 from src/vm/moar/ModuleLoader.nqp:47  (/home/hakon/debug/rakudo/install/share/nqp/lib/ModuleLoader.moarvm:)
 from src/vm/moar/ModuleLoader.nqp:40  (/home/hakon/debug/rakudo/install/share/nqp/lib/ModuleLoader.moarvm:load_module)
 from <unknown>:1  (/home/hakon/debug/rakudo/install/share/nqp/lib/Perl6/Grammar.moarvm:<dependencies+deserialize>)
 from src/vm/moar/ModuleLoader.nqp:47  (/home/hakon/debug/rakudo/install/share/nqp/lib/ModuleLoader.moarvm:)
 from src/vm/moar/ModuleLoader.nqp:40  (/home/hakon/debug/rakudo/install/share/nqp/lib/ModuleLoader.moarvm:load_module)
 from <unknown>:1  (/home/hakon/debug/rakudo/install/share/perl6/runtime/perl6.moarvm:<dependencies+deserialize>)
h

所以我想,也许我还需要 运行 make 在 rakudo 上:

cd ..
make

但是这里 make 失败了:

/home/hakon/perlbrew/perls/perl-5.29.3/bin/perl5.29.3 tools/build/check-nqp-version.pl /home/hakon/debug/rakudo/install/bin/nqp-m
/home/hakon/debug/rakudo/install/bin/nqp-m tools/build/gen-cat.nqp moar src/vm/moar/ModuleLoaderVMConfig.nqp src/Perl6/ModuleLoader.nqp > gen/moar/ModuleLoader.nqp
/home/hakon/debug/rakudo/install/bin/nqp-m --module-path=blib --target=mbc --output=blib/Perl6/ModuleLoader.moarvm \
    gen/moar/ModuleLoader.nqp
*** Debugging message: HLL::Compiler::command_eval() ***
Confused at line 2, near "*** Debugg"
   at gen/moar/stage2/NQPHLL.nqp:811  (/home/hakon/debug/rakudo/install/share/nqp/lib/NQPHLL.moarvm:panic)
 from gen/moar/stage2/NQP.nqp:921  (/home/hakon/debug/rakudo/install/share/nqp/lib/nqp.moarvm:comp_unit)
 from gen/moar/stage2/NQP.nqp:782  (/home/hakon/debug/rakudo/install/share/nqp/lib/nqp.moarvm:TOP)
 from gen/moar/stage2/QRegex.nqp:2300  (/home/hakon/debug/rakudo/install/share/nqp/lib/QRegex.moarvm:parse)
 from gen/moar/stage2/NQPHLL.nqp:2031  (/home/hakon/debug/rakudo/install/share/nqp/lib/NQPHLL.moarvm:parse)
 from gen/moar/stage2/NQPHLL.nqp:1951  (/home/hakon/debug/rakudo/install/share/nqp/lib/NQPHLL.moarvm:execute_stage)
 from gen/moar/stage2/NQPHLL.nqp:1984  (/home/hakon/debug/rakudo/install/share/nqp/lib/NQPHLL.moarvm:run)
 from gen/moar/stage2/NQPHLL.nqp:1976  (/home/hakon/debug/rakudo/install/share/nqp/lib/NQPHLL.moarvm:)
 from gen/moar/stage2/NQPHLL.nqp:1971  (/home/hakon/debug/rakudo/install/share/nqp/lib/NQPHLL.moarvm:compile)
 from gen/moar/stage2/NQPHLL.nqp:1666  (/home/hakon/debug/rakudo/install/share/nqp/lib/NQPHLL.moarvm:eval)
 from gen/moar/stage2/NQPHLL.nqp:1889  (/home/hakon/debug/rakudo/install/share/nqp/lib/NQPHLL.moarvm:evalfiles)
 from gen/moar/stage2/NQPHLL.nqp:1849  (/home/hakon/debug/rakudo/install/share/nqp/lib/NQPHLL.moarvm:command_eval)
 from gen/moar/stage2/NQPHLL.nqp:1773  (/home/hakon/debug/rakudo/install/share/nqp/lib/NQPHLL.moarvm:command_line)
 from gen/moar/stage2/NQP.nqp:4135  (/home/hakon/debug/rakudo/install/share/nqp/lib/nqp.moarvm:MAIN)
 from gen/moar/stage2/NQP.nqp:1  (/home/hakon/debug/rakudo/install/share/nqp/lib/nqp.moarvm:<mainline>)
 from <unknown>:1  (/home/hakon/debug/rakudo/install/share/nqp/lib/nqp.moarvm:<main>)
 from <unknown>:1  (/home/hakon/debug/rakudo/install/share/nqp/lib/nqp.moarvm:<entry>)
make: *** [Makefile:457: blib/Perl6/ModuleLoader.moarvm] Error 1

Rakudo 构建静态 "linked" 针对用于生成它的 NQP 构建中的库,因此 Rakudo 需要在修改 NQP 后重新构建。散列用于确保永远不会使用错误版本的依赖项;如果未检测到这种情况,则极有可能出现极其奇怪的故障模式。

第二次失败是因为Rakudo构建使用了一些NQP脚本来预处理一些源文件,然后将这些源文件提供给Perl 6编译器的NQP。它使用 > 将输出重定向到文件中。因此,您的调试输出将被重定向到该文件,然后——因为它不是有效的源代码——导致构建错误。解决方案是始终在 stderr 上生成调试输出,例如使用 note.