如何修改 erts 模块

How to modify erts modules

我想修改模块erl_prim_loader,但是发现没有生效。 此文件似乎不是从 $ERL_ROOT/lib/erts-10.1/ebin/erl_prim_loader.beam

加载的

这是一个预加载的模块,因此需要一个额外的步骤才能使修改生效。来自 a message by John Högberg to erlang-questions on 2019-04-29:

prim_file is a prebuilt module that's statically embedded into the emulator, and the emulator crashes if there are any problems initializing it. In this case you've added a function to the NIF but haven't yet rebuilt the module, so it crashes when trying to inject the non-existent my_truncate_nif/1.

To update these prebuilt modules, you need to run:

./otp_build update_preloaded --no-commit

Try doing this on a clean build without changes to the NIF (C code), and then rebuild the emulator with the changes applied. Note that you will need to rebuild the emulator every time you update the preloaded modules for the changes to take effect.

Hope that helps!