[v12.x] tools: fix mkcodecache when run with ASAN
Fixes: https://github.com/nodejs/node/issues/32835
PR-URL: https://github.com/nodejs/node/pull/32850
(The first commit is a clean cherry-pick, the second/fixup commit fixes this up for v12.x)
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
commit message follows commit guidelines