No, it does not work. It only uncovers a severe issue in Julia 1.11. I write in Julia because using the same PackageCompiler version works well with the latest Julia 1.10.9 (no matter if I have the environment variable “JULIA_NUM_THREADS” or not), and does not work with Julia 1.11.4.
Your patch is only a hotfix to make it compile at all, but the compilation takes up to 40% longer than with 1.10 and, more important, I often get errors that some threads cannot be stopped and the compilation fails. These issues also occur with your patch.
Something is is different in Julia 1.11 or PackageCompiler needs an update for Julia 1.11. I mean that it suddenly fails if users have set JULIA_NUM_THREADS and even with only one thread it does no longer run stable and takes way more time. With way more time, I directly compared Julia 1.11.4 and 1.10.9 using each only one thread.